Questions tagged [programming]
For questions about programming languages, implementation, and packages in quantitative finance. Note: question must be specific to quantitative finance and must necessitate knowledge of quantitative finance in order to be on topic.
437
questions with no upvoted or accepted answers
1
vote
0
answers
270
views
Calculate display and plot relative spread using Sierra Chart
I'm trying Sierra Chart for trading Bitcoin.
I would like to display relative spread for a given volume.
spread_rel = 200.0 * (ask - bid) / (bid + ask)
where ...
1
vote
0
answers
205
views
Example code for "Gauge Invariance, Geometry and Arbitrage" paper
This paper describes an algorithm for computing arbitrage opportunites using a gauge connetion.
Has anyone written a python program or C++ or C# program that shows how to follow the steps outlines in ...
1
vote
1
answer
8k
views
estimate implied volatility using newton-raphson in python
I am trying to calculate the implied volatility using newton-raphson in python, but the value diverges instead of converge. What is wrong with the code?
...
1
vote
1
answer
193
views
Good real time API providers for treasury futures?
I'm shopping for real time data API provider for treasury futures. Can anyone share any good ones?
Thanks.
0
votes
0
answers
31
views
YUIMA: Drift and diffusion parameters must be different?
I am currently working with the Yuima package and trying the estimate the parameters of a CARMA(p,q) model to real data. Using the eacf function of the TSA package a ARMA (2,1) process is recommended ...
0
votes
0
answers
14
views
Getting standardized residuals from MSGARCH in R
After estimation by the MSGARCH package in R, I couldn't find a way to extract residuals from the estimation results.
Anyone know how to extract the residuals from MSGARCH package in R? Thanks!
0
votes
0
answers
23
views
Is there any way to view historical data on market capitalization?
Is there any way to view historical data on market capitalization?
I would like to calculate a market capitalization weighted index with only the top 10 nasdaq stocks (like nasdaq 10).
I have tried ...
0
votes
0
answers
19
views
Got different results using SEC EDGAR API and Seeking Alpha
I am trying to get the same Depreciation and Amortization (Total) we can get for AAPL on Seeking Alpha and QuickFS for instance. Here is what is their values:
However, what I am getting using the SEC ...
0
votes
0
answers
41
views
Barrier option Greeks using AD
I am trying to price a Down-and-Out Barrier option using Monte Carlo and get the Greeks using autodiff as provided by PyTorch. However, comparing the output to bumping, I get vastly different values ...
0
votes
0
answers
61
views
How to simulate a conditional expectation given a filtration
I had a question regarding how to simulate a certain conditional expectation. I am given two processes $X_1(t), X_2(t)$ which both follow their own SDE, but both are of the form
\begin{equation*}
dX_i(...
0
votes
0
answers
19
views
How to analyse success of trades by time of day, day of week, duration from the output of an MT5 Expert Advisor
I have the output of an MT5 EA in csv format. I want to analyse the output to identify best time of day, day of week, duration, buy or sell, consecutive wins and losses.
Ideally I would like to use a ...
0
votes
0
answers
109
views
Longstaff & Schwartz algorithm - Python: American option cheaper than European option
I have implemented the Longstaff & Schwartz algorithm for pricing American Option in Python, but I ran into an issue while doing some experiments: sometimes, for the same option, I get a higher ...
0
votes
1
answer
66
views
ISIN symbol pairs for DAX, MDAX, SDAX, TecDAX and Nasdaq-100
I am looking for a simple source for ISIN-symbol pairs for DAX, MDAX, SDAX, TecDAX and Nasdaq-100? I can't find anything on Yahoo and possible sources only offer searches for individual stocks, but I ...
0
votes
0
answers
103
views
Quantlib Python bootstrapping with ArithmeticOISRateHelper: cannot find a soluton for forward rate
I am trying to construct a curve based on OIS quotes. Fixed rates in those OIS are quoted againgst the arithmetic average of the floating rate. Consequently, I am using the correspoding helper class - ...
0
votes
1
answer
103
views
How to calibrate a volatility surface using SSVI with market data?
Context
I'm a beginner quant and I'm trying to calibrate an vol surface using SPX Implied Vol data. The model is from Jim Gatheral and Antoine Jacquier's paper https://www.tandfonline.com/doi/full/10....
0
votes
0
answers
77
views
Interpreting parameters on Matlab from Patons code on time varying copulas
I ran Andrew pattons code(2006) for Markov switching time varying copulas with an example code given in the Matlab tool box. This is the equation for Markov switching time varying normal copulas
I ...
0
votes
0
answers
29
views
Searching for minute binned OHLCV Cryptocurrency data from 5 January 2018 to 7 September 2018
As the title states, searching for OHLCV data (USD) from the dates listed for these coins:
[ADA, BCH, CVC, DASH, EOS, ETC, ETH, LTC, MANA, OMG, BCN, BTC, CND, DATA, ETP, GNT, NEO, NXT, QASH]
I'm a ...
0
votes
0
answers
45
views
Lognormal-mixture dynamics and calibration to market volatility smiles
Can someone assist me in replicating the code and results from page 11, Figure 3 of the paper 'Lognormal-mixture dynamics and calibration to market volatility smiles' by Damiano Brigo, Fabio Mercurio, ...
0
votes
0
answers
39
views
Implementations of stochastic collocation for Arbitrage Free SABR
I am currently reading this paper (link) on fitting arbitrage free parameters for SABR using stochastic collocation. Are there any publicly available github repos that implement solutions that are ...
0
votes
0
answers
466
views
Simulating Hull-White Model in Python
I first simulated the short rate in the Vasicek model using the following code, which is equivalent to simulating the following normal distribution $r_{t} \sim N\left(r_{0}e^{-at} + b\left(1-e^{-at}\...
0
votes
0
answers
20
views
Determining an Appropriate Locate Fee Threshold for Short Selling Based on Expected Return
I'm working on an automated stock trading program and often consider short selling as part of my strategy. For each potential short sale, there's an associated "locate fee" that I have to ...
0
votes
2
answers
111
views
From OHCLV dataset to Tick Chart
We are all familiar with time-based candlestick charts, such as 1 Minut, 15 Minuts, 1 Hour and so on.
The dataset is more or less something similar:
...
0
votes
0
answers
41
views
Heston model using YUIMA package
I am trying to estimate a Heston model using the Yuima package, but i am in trouble.
This is my script:
...
0
votes
0
answers
76
views
COS method for Wishart Heston Model
NOTE: This code is a piece of code I am using for a master's thesis, so I do not expect someone to do the work for me, but I gladly accept suggestions of any kind.
However, I am trying to get the ...
0
votes
0
answers
55
views
Profit optimal algorithm for market clearing
There is a well known offline profit optimal algorithm for market clearing (matching buy-bids with sell-bids, visit for more details) which is based on bipartite weighted matching. This algorithm ...
0
votes
0
answers
126
views
Quanto CDS pricer in Python
I am sales and would like to grasp rough levels of quanto CDS, such as BMW denominated in USD, without askin traders each time. What i'm thinking is to calculte it using Python.
But i cannot build up ...
0
votes
0
answers
234
views
Is there any way to estimate a multivariate GARCH-MIDAS model in R?
I'm writing my master thesis in economics, and would like to research the impact of both financial and macroeconomic variables on the S&P500 index. My plan was to use a GARCH model. I've stumbled ...
0
votes
0
answers
60
views
Commodity forward curve Monte-Carlo
I need to value an Asian commodity option using Monte Carlo and a log-normal model. The inputs are the commodity forward curve and the volatility surface for futures/options expiry. Unfortunately, all ...
0
votes
0
answers
115
views
CoVaR/dCoVaR modelling using bivariate DCC-GJR-GARCH
For the several weeks, I have been looking for a way to calculate and display the results of my DCC-GJR-GARCH model to picture a dynamic relationship between daily return of, let's say for example, ...
0
votes
1
answer
93
views
Uncertain Volatility Model - Option Pricing R code help
I am trying to price the following call option using the UVM method in R.
The code I wrote below keeps producing the same price for the min and max volatilities, which is wrong, however, I can't seem ...
0
votes
0
answers
66
views
Expanding window with ugarchroll in rugarch in R
I was wondering whether my code is crafted correctly to satisfy this requirement:
use 1:1000 to predict 1001, then use 1:1001 to predict 1002, and so on
rOHLC has a length of 10079
...
0
votes
1
answer
229
views
Using bid and ask prices with VectorBT library
I am creating a backtest using vectorbt library. This is my function for all the portfolio metrics:
...
0
votes
0
answers
69
views
Can anyone help me to understand why the GMV point is not on the efficient frontier?
I am following a course about portfolio construction with Python. I am able to successfully draw the efficient frontier and capital market line (CML), and the global minimum variance (GMV) point using ...
0
votes
1
answer
96
views
Garch Model with Vix as external regressor un dummy rugarch r studio
I would like to try to replicate this variance dummied model in r studio, to try to compare garch vs i.v in forecasting vol:
Data : S&P 500 log-return from 03.01.2020 to 31.12.2022
Ext regressor : ...
0
votes
0
answers
409
views
0
votes
0
answers
56
views
How do I obtain the RMSE from a QuantLib curve estimation?
I'm estimating yield curves in Python using the QuantLib package and the included Nelson Siegel, Svensson, specifications. I can get the estimated parameters, but I would like to see a measure of the ...
0
votes
0
answers
321
views
CIR model calibration - python
EDIT: or maybe to add, is the below way of calibration better than calculating as:
longer term mean b: average of interest rates
speed of reversion a: ln(1/drift)
volatility σ
I am trying to ...
0
votes
0
answers
205
views
trailing Stop Calculation for a strategy
I have converted pine script (UT-Bot by Yo_adriiiiaan) strategy to python but facing some errors. It requires TRA calculation and trailing stop calculation. Problem is that ...
0
votes
0
answers
181
views
Is my time horizon for GARCH(1,1)/ARCH(1)/EGARCH(1,1) reasonable?
I am trying to learn about volatility forecasting using three models: ARCH(1), GARCH(1, 1) and EGARCH(1, 1) using python. I wanted to know if my general procedure is correct, and specifically if my ...
0
votes
0
answers
63
views
How to use GARCH/ARCH/EGARCH volatility forecasts to compare the Black Scholes constant volatility assumption with GARCH/ARCH/EGARCH volatility
I should preface this by saying I am an undergraduate physics student, this is more of a side interest to me, so I apologise if I am missing something obvious. I am not following a formal class or ...
0
votes
0
answers
144
views
Quantlib Monte Carlo using regular Volatility Surface, not Local Volatility surface
I am trying to run a Quantlib Python Monte Carlo simulation using either the ql.BlackScholesMertonProcess or the ql.GeneralizedBlackScholesProcess. I have a vol surface that I have generated using ql....
0
votes
0
answers
226
views
How to calculate YTM of AmortizingFixedRateBond in QuantLib - Python?
I'm trying to calculate the ytm of bonds amortized in quantlib. The maturity of this bond is five years, starting from the second year to repay 25% of the face value until the last year.
The cash flow ...
0
votes
0
answers
162
views
finding the monthly covariance matrix given daily covariance matrix
consider the following problem i am trying to find the monthly covariance matrix given daily data. i have the following codeimport datetime
...
0
votes
1
answer
282
views
How to implement rolling granger causality
I am investigating two time series where the first is the daily closing stock price changes and the other is the daily changes in the PCE index.
I want to investigate how much the PCE index explains ...
0
votes
0
answers
113
views
Inconsistency between simulation and the probability of a "stock" hitting take profit before stop loss
Let's assume a stock at time $t$ is worth $X(t)$. If the returns of $X(t)$ are i.i.d. and normally distributed,the probability of $X(t)$ hitting a value $H>X(t)$ before $L<X(t)$ is $\frac{H-X(t)}...
0
votes
0
answers
34
views
How to predict what stage of business cycle we are currently in based off of unemployment indicators
I am trying to predict what part of the business cycle (Early, Mid, Late 1, Late 2) we are currently in by looking at unemployment indicators.
Qualitatively, I've reasoned that:
.
Early
Mid
Late 1
...
0
votes
0
answers
303
views
How to vectorize stop loss in backtest
I am building a custom vectorized backtester in python using pandas.
My problem is that the entry and exit signals are independent and can occur at the same time making it difficult to create a single ...
0
votes
0
answers
382
views
Monte Carlo Pricing of Barrier Options - can't figure out where I'm wrong
I'm trying to price a simple Up-and-out Barrier option using Monte Carlo; haven't even implemented the variance reduction but it's already glitching.
The code seems right, but I'm not sure where it's ...
0
votes
0
answers
228
views
how to merge these two crsp data sets
I'm not totally confident on how to merge these two monthly CRSP data sets. As I write this, it comes from two databases: crsp.mse and ...
0
votes
1
answer
274
views
Quantlib: How to bootstrap FedFunds Index having other tenors 3M, 1Wk, etc?
I am valuing few Basis Swaps having combination of USD-FedFunds-H.15-OIS-COMPOUND3M vs USD3MLibor. However, I can understand to value 'USD-FedFunds-H.15-OIS-COMPOUND1D' by using ql.FedFunds(). But ...