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.

Filter by
Sorted by
Tagged with
4 votes
0 answers
237 views
+50

PBO algorithm "The Probability of Backtest Overfitting" paper

In this article by Lopez de Prado et al., an algorithm was proposed for assessing the overfit of a trading strategy: The Probability of Backtest Overfitting There is also a package for R: pbo: ...
0 votes
2 answers
52 views

QuantLib Python: Calculate ZSpread

I am trying to use quantlib-python to calculate the z-spread of a fixed rate US corporate bond using a zero curve from swap rates provided. Here is the provided ...
1 vote
1 answer
198 views

Find the right module for CDI DI BRL swaps valuation Quantlib

I'm trying to find a way to price BRL CDI Swaps with Quantlib but I can't find any solutions so far - so I was wondering if anyone encountered this issue: I don't see any solution on Quantlib. I ...
1 vote
1 answer
115 views

replicating momentum strategy - Formation Periods

I am trying to replicate the momentum strategy of the study by Jegadesh and Titman (1993) onyl using data from the past 10 years.I am trying right now to calculate the formation period returns. But I ...
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
1 answer
74 views

Portfolio optimization with Scipy in Python

I performed Scipy portfolio optimization in two scenarios: 1) when I cannot lend or borrow at the risk-free rate; 2) when I can lend and borrow at rf=1.5%. Now, optimal risky portfolio weights anyway ...
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!
3 votes
2 answers
952 views

Why there is a Deviation on my RSI indicator in comparison from one of the other Trading Markets

Hello all, and sorry for this stupid question. I am using my custom RSI indicator to which I created programmatically. I follow the equation type from here. My problem is when I compare it with the ...
5 votes
2 answers
2k views

Does Fidelity Have a Python Trading API?

I'd like to do my trading through a corporate account at Fidelity, but there does not seem to be a Python api. What I'm looking for is something like this: https://github.com/jmfernandes/robin_stocks
1 vote
1 answer
332 views

Clarifying Parkinson Python Code [closed]

I would appreciate opinions/reviews on whether my python code to calculate Parkinson Volatility index is correct. Thank you very much! ...
0 votes
1 answer
480 views

Bootstrapping the 6m Sterling Libor curve

I am trying to bootstrap the 6m sterling swap curve using the depos and swap rates codes are below. I am a newbie and have been following (or at least trying to!) the python cookbook. I wanted to know ...
1 vote
2 answers
2k views

QuantLib-Python: Getting a list of all holidays between D1 & D2 with function "holidayList"

I figured out that the C++ version of QuantLib offers a function called holidayList in the calendar class. ...
1 vote
1 answer
66 views

Can the coef be negative in cointegrated stocks?

I'm searching for cointegrated stocks using the Python CointAnalysis library. While computing stock prices on a 5 mins time frame, I found that the stocks MNST (Monster Beverage Corp.) and KDP (Keurig ...
1 vote
2 answers
285 views

$n$-day ahead forecast for asymmetric DCC-GARCH model

I am working on forecasting covariances with the use of MGARCH models. I was wondering if anyone knows how to implement a n-day ahead forecast of the aDCC (asymmetric DCC) model in R. The ...
3 votes
1 answer
691 views

TradingView STC vs any python STC

I am trying to use in a trading strategy the STC indicator, but I can not find out why its not working properly. The chart that I am using is BTC/USDT on UTC as a timeframe. Chart time: 01 Feb 22 - 16:...
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
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 ...
-4 votes
0 answers
54 views

Hull-White Matlab code

Can someone help me with a code of Hull-White model to price derivatives, in which we use A(t,T), B(t,T) and P(t,T)-the discount factor? Thank you. I already have this code, that doesn´t work. ...
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
1 answer
422 views

Include Dollar Cost Averaging Strategy in BT python

I am using bt backtesting to test between an initial lump sum into 'ETH-USD' and a dollar cost average approach. I will then look into a different mix of equally weighted crypto. What I like about bt ...
5 votes
1 answer
2k views

How to calculate average entry price for perpetual swap contracts?

I'm trying to calculate the average entry price for perpetual swap contracts for use in back-testing a trading strategy, as per Bitmex's documentation: A Perpetual Contract is a derivative product ...
2 votes
1 answer
150 views

Uncertainty on volatility prediction using GARCH(1,1)

I have daily returns data and I predict the variance for the next day using GARCH(1,1) as follows ...
7 votes
3 answers
13k views

How can I estimate the Ornstein-Uhlenbeck paramters of some mean reverting data that I have on R?

I have mean reverting data (Difference of 2 stock prices, that I want to do pairs trading on). I want to simulate my own mean reverting data as similar as possible to the real data that I have. The ...
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 : ...
1 vote
1 answer
926 views

forecast using rugarch in r

After fit the GARCH model, I want to plot the volatility forecast sigma series. I use ugarchforecast as follow: ...
1 vote
1 answer
146 views

GBP OIS Curve - Zero Rate Curve Calculation in Quantlib

I am new to Quantlib and I am looking to create a Zero Rate Curve from GBP OIS to then use to calculate the present value of fixed rate bonds. I have Looked at the documentation: https://quantlib-...
1 vote
1 answer
409 views

Python - yahoo finance options data - volatility smile plot

I have plotted the IV of TSLA options using yahoo options data, but the scatter plot doesn't look right, can anyone advise why the plot looks like this? I would expect to see a vol smile plotted. EDIT ...
3 votes
1 answer
616 views

VAR-aDCC full ARCH and GARCH parameter matrices in R

I am working with the rmgarch package in R and I estimated a VAR-aDCC model. Is there any way to extract the extended version of estimates (allowing for volatility ...
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 ...
2 votes
2 answers
2k views

Is alpha vantage api for fundamental data reliable?

Can anyone speak to the reliability of the Alpha Vantage (AV) api for fundamental stock data? I have tried for a couple of stocks to get balance sheet data, and it seems close to accurate but I feel ...
1 vote
1 answer
276 views

Market impact power law fitting confusion

In many market impact papers such as "Anomalous price impact and the critical nature of liquidity in financial markets" by Tóth et al (2018), there is a standard power-law relation in the ...
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 ...
1 vote
1 answer
195 views

The best approach for screening ATH values for equities

I am trying to automate the trading strategy that I have been previously executing manually. I am having problems with figuring out the most efficient way for a specific step of the strategy. An ...
1 vote
2 answers
167 views

fast backtesting library in R

I’m looking for a fast library for backtest in R that supports limit orders, stop-losses, and take-profits. The library should be optimized for repeated historical testing and ideally ported from fast ...
0 votes
1 answer
30 views

Is End of Month (Eom) Rule overrides Unadjusted convention rule in Quantlib?

Concerning the post Is End of Month (Eom) Rule overrides convention rule in Quantlib Schedule? I noticed that with Unadjusted convention has the same behavior. Is this wanted? For example, with Target ...
0 votes
2 answers
333 views

Calculate return for a set of securities downloaded using quantmod

I downloaded adjusted closing price using quantmod for a set of securities. I want to calculate daily/weekly/monthly return for all securities. Usual dailyReturn, weeklyReturn etc not working. What do ...
1 vote
0 answers
58 views

Python Quantlib Loop to calculate cap prices: Setting of evaluationDate

I am trying to calculate cap prices for different points in time (valuation dates) with Quantlib. I have built three loops for this. The first one creates the quantlib yield curve object ts_handle ...
4 votes
1 answer
200 views

To estimate the parameters when only the characteristic function is known to us

Recently I was working with a process named Variance Gamma with Stochastic Arrival (VGSA) and trying to fit this process on a given data. To obtain VGSA, as explained in Carr et al. [2001], we take ...
0 votes
2 answers
126 views

how to make this time series reguarly spaced

in the picture below we have in the first coloumn the day of the month, in the second coloumn the time in millisecond in epoch time(elapsed from 1 january 1970), third coloumn the stock price and in ...
0 votes
1 answer
132 views

Why is my Risk Neutral Density recovery failing?

I'm working on a project to recover a known Risk Neutral Density from option prices, using the Breeden-Litzenberger formula (assuming a continuum of option_price(strike_price), the second derivative ...
2 votes
3 answers
5k views

Monte Carlo simulations in Python using quasi random standard normal numbers using sobol sequences gives erroneous values

I am trying to perform Monte Carlo Simulations using quasi random standard normal numbers. I understand that we can use sobol sequences to generate uniform numbers, and then use probability integral ...
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
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(...
1 vote
0 answers
130 views

Validator for Risk-Neutral Distributions Derived from Option Prices

I've developed a validator for risk-neutral distributions. I did this for the purpose of testing the risk-neutral distributions generated by a Spectral Analysis risk-neutral density recovery method, ...
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
1 answer
93 views

QuantLib: How to compute the forward rate using historical fixing rate and discount factor data

Let's say the valuation date is 08/24/2023. The effective date and maturity date of the swap are 03/12/2022 and 01/10/2024. I want to apply the given historical fixing rates till the valuation date ...
3 votes
2 answers
216 views

QuantLib calculations for a Canadian corporate fixed rate bond differ from BBG YAS

I am pricing a non-callable, fixed-rate, Canadian corporate bond with the following parameters: Name Value CUSIP 12657ZAT0 Evaluation Date 2/14/2024 Settlement Date 2/16/2024 Bond Issue Date 3/6/...
0 votes
1 answer
70 views

How does the isInArrears affect the quantlib IborLeg? [closed]

Deal details ...
0 votes
1 answer
76 views

Reliability of R Package on Covariance Matrix Shrinkage

I recently used a R package CovTools in R with the command CovEst.2003LW(X), where X is your sample covariance matrix as an input, to compute the shrunk covariance matrix (an estimate that is closest ...
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: ...

1
2 3 4 5
36