All Questions
Tagged with python or programming
1,854 questions
-1
votes
0
answers
23
views
Where do i get the datasets to train a quant model? [duplicate]
Where do i get the datasets to train a quant model for options trading ? recently been trying this for hours
0
votes
1
answer
56
views
What are the best libraries [closed]
What are the best libraries for developing the Quant algorithms ??
0
votes
0
answers
38
views
Interactive Brokers API - Wrong date for historical data for weekly and monthly bars
I'm currently trying to fetch historical data from Interactive Brokers using the ib_async package. Depending on the exchange I use, the weekly and monthly bars will ...
-2
votes
1
answer
59
views
QuantLib issue with creating a FixedRateBond
When trying to construct a simple bond object using QuantLib using the example from the docs, I get the following error:
...
0
votes
1
answer
69
views
Convergence of Numerical Methods on Lookback Options in R
I have been practicing using R code for my Quant course and I came across an issue when testing the convergence of numerical methods for lookback options to the analytical solutions provided by Hull ...
0
votes
1
answer
123
views
How to design an effective reward function for RL-based FX hedging strategy?
I'm working on an Reinforcement learning (RL) algorithm for optimizing a foreign exchange (FX) hedging strategy, specifically for the USD/AZN (Azerbaijani manat ₼) pair in the context of Azerbaijan's ...
1
vote
1
answer
99
views
Discrepancy in Ulcer Index calculation with the Riskfolio-Lib library
I am using the Riskfolio-Lib Python library to calculate the Ulcer Index. When I run the function, the values I get are on the order of hundredths (for example, 0.0X).
My issue is that, based on other ...
2
votes
1
answer
149
views
BusinessDayConvention failing to obtain correct accured or correct coupons in ql.FixedRateBond()
I am trying to price a fixed rate bond with Quantlib (BFCM 4 3/8 01/11/34 Corp or FR001400N3I5)
Coupon 4.375%
Freq : Annual
Day Cnt (Bloom) : ACT/ACT
Issue date 11-Jan-24
First CPn Date 11-Jan-25
Mty ...
3
votes
1
answer
138
views
Shifts in SABR model in QuantLib Python ql.SabrSwaptionVolatilityCube()
I'm able to build Swaption vol cube using ql.SabrSwaptionVolatilityCube(), but I don't see this function accepts shifts input. I did some research understand that we can apply shifts to ATM volsurface ...
1
vote
2
answers
381
views
Girsanov Theorem: how to implement it with code?
I'm trying to visualize the path transformations coming from the application of the Girsanov Theorem in a Monte Carlo Simulation.
Below the (Python) code where I'm trying to "adjust" the ...
0
votes
0
answers
84
views
EasyLanguage to Python conversion
Im trying to recreate this autocorrelation indicator from John Ehlers book Cycle Analytics for Traders but am getting a slightly different result. Any ideas? Below is the EasyLanguage code from the ...
3
votes
1
answer
135
views
QuantLib Bootstrapped Curve Tallies With Bloomberg Only Up to 1Y Tenor
I'm trying to reconstruct Bloomberg's SORA curve and have noticed that the bootstrapped curve for some reason is only accurate up to the 1Y tenor (out of 30Y), and have no idea what could be causing ...
3
votes
0
answers
106
views
How is polymorphism treated in production code?
What are the key-concepts on Polymorphism wrt derivative products? For example, if we have a collection of equity options with spot underlying and we are generating surfaces across multiple levels on ...
3
votes
1
answer
103
views
QuantLib `RangeAccrualFloatersCoupon` instanciation fails
Instanciation of RangeAccrualFloatersCoupon in Python fails with the following error, even though the 12th argument is a QuantLib schedule.
...
1
vote
1
answer
102
views
PaymentLag in ql.OvernightIndexedSwap()
How do I use maturity date of an ois instead of its tenor, I am using the following QuantLib function:
ois = ql.MakeOIS(ql.Period('3Y'), index, 0.1, nominal=1000000, settlementDays=0,
effectiveDate=ql....
2
votes
1
answer
126
views
rateslib curves: Why does changing day count convention affect discount factors?
I'm using the rateslib Python package to build a yield curve from Brazilian DI1 futures using piecewise/spline interpolation. My expectation was that changing the day count convention of the curve ...
0
votes
0
answers
69
views
Implementation of standard stretched Brownian motion in Python
I am trying to implement a standard stretched Brownian motion 1,2in Python. This requires finding a fixed point of the equation
$\mathcal{A}:CDF \to CDF$,
$\mathcal{A}F = F_\mu \circ(\phi*(Q_\nu \circ(...
2
votes
1
answer
110
views
rateslib STIRFuture throws “RFRs could not be calculated” if SOFR weekend fixings are missing — shouldn’t weekends be skipped?
I’m using rateslib 2.0.0 to calibrate a SOFR curve with a stack of STIRFuture contracts (“usd_stir” & “usd_stir1” specs). When my evaluation date is 2025-06-08 or later, the solver fails with:
...
0
votes
0
answers
66
views
Advice on pattern mining python script
I'm looking for advice on the approach of this type of scan/search. I've built a number of code blocks that look at relatively simple aspects like price changes over time, volatility, volume, various ...
0
votes
0
answers
69
views
Trouble Calibrating Heston Model via Maximum Likelihood in Python
I'm trying to calibrate the Heston stochastic volatility model using maximum likelihood estimation (MLE) on high-frequency financial data, inspired by the methodology in this study (Hybrid machine ...
1
vote
0
answers
114
views
Problem with predictive stock factors Python library (Alphalens)
I'm using the alphalens.utils.get_clean_factor_and_forward_returns() from alphalens, a Python Library for performance analysis of predictive (alpha) stock factors, to compute forward returns from a ...
1
vote
0
answers
42
views
Help implementing numerical pricing model for Summer Day Options (Kanamura & Ōhashi 2009) [closed]
I'm trying to implement the pricing model from the paper:
Kanamura & Ōhashi (2009), "Pricing Summer Day Options by Good-Deal Bounds" (Energy Economics, Vol. 31, pp. 289–297)
The model is ...
0
votes
2
answers
163
views
Collecting/Processing Data Via IBKR, SQL Databases and Python
So, I collect Open/Close data for a lot of tickers, process it in multiple ways, and use it for an ARIMA model. Right now, I do this through Excel, but I'm running into a lot of data capacity problems....
0
votes
0
answers
94
views
OU Mean-Reverting Lognormal Process Simulation
I want to make sure that the following reasoning and simulation technique is reliable (also valid) due I'm trying to model a mean-reverting lognormal process.
The idea is to define a process
$S_t$
...
2
votes
2
answers
219
views
Difference in YTM and calculated risk metrics between QuantLib and Bloomberg for Fixed Coupon Bonds
I'm trying to get the yield for a given bond as well as other metrics to align with the YAS page on Bloomberg, but they are all sufficiently off to be slightly concerning, i.e. somewhere in the 4th ...
1
vote
1
answer
208
views
How can I represent a Brazilian DI1 future in rateslib (python)?
I am currently looking to use rateslib to explore Brazil's rates market, of which the DI1 futures are a big component. I have limited experience with both these futures and with rateslib, so pardon if ...
0
votes
1
answer
135
views
Price and Yield Calculations for Municipal Bonds with QuantLib
I'm currently trying to calculate yield to maturity for a given municipal bond using quantlib for maven, and am comparing the result to the calculated yield listed on EMMA. However, I keep ending up ...
1
vote
1
answer
186
views
QuantLib Python: generating forward rates from Hull White simulated short rates
I am generating interest rate paths through Hull White (1M SOFR for 50 years, monthly) and would also like to generate multiple forward zeros for each point on the path, e.g. 10y1m forward starting ...
1
vote
0
answers
54
views
Estimating Marginal Levy measures in R
I have a question regarding how to estimate the marginal Levy measure in the context of Log returns in R, since I want to estimate a Levy copula of these marginal Levy measures. My code is attached ...
4
votes
1
answer
246
views
The raw SVI parametrization numerical optimization
Recall that a raw SVI parametrization of a total variance for a fixed maturity looks like
$$w(k, \xi) = a + b\cdot(\rho\cdot(k-m)+\sqrt{(k-m)^2+\sigma^2})$$
where $\xi=\{a,b,m,\rho,\sigma\}$ is the ...
0
votes
0
answers
332
views
How can I robustly detect dynamic support and resistance levels programmatically in Python?
I am working on a Python project to programmatically detect dynamic support and resistance levels in historical price data, particularly for forex instruments such as EUR/USD. My primary goal is to ...
1
vote
0
answers
202
views
Why is it called "Mathematical Finance", not "Statistical Finance"?
About the idea of "Quantitative Finance" in general:
Everywhere I look on the Internet, people seem to be saying that Statistics is more relevant to Quant Finance than Mathematics. The ...
1
vote
1
answer
143
views
Simulating a Reverse Convertible Note on DLIB using BLAN
Bonjour,
i recently found out of the existence of DLIB on Bloomberg where one can simulate pricing and various risk analysis for derivatives and structured products. there are several templates ...
0
votes
0
answers
56
views
Earnings calendar with direct link to live earnings feed/report?
I was wondering if there was a service that provides earnings calls calendars with direct access to the URL used to publish the earnings call. Alternatively if there exists a database with the ...
1
vote
0
answers
61
views
Discretization for dynamic hybrid framework
I'm currently trying to implement the following equations (in RStudio).
$\pi$ corresponds to the proportion (of the funds $F$) which is invested in risky assets (parameters : $\delta$, $\sigma$). The ...
0
votes
0
answers
134
views
Generation of two correlated Brownian Motions using two different approaches in numpy Python
Consider two correlated Brownian Motions $W_{1,t}$ and $W_{2,t}$ for which it holds:
$$dW_{1,t}\sim N(0, \sqrt{dt})$$
$$dW_{2,t}\sim N(0, \sqrt{dt})$$
$$Cov(dW_{1,t},dW_{2,t}) = E[dW_{1,t}dW_{2,t}] = \...
1
vote
0
answers
108
views
European option priced with forward Kolmogorov and Finite Difference method
I explored the Kolmogorov equations, which describe the evolution of probability distributions in stochastic processes, and was thinking how they could be used to price European options. However, ...
1
vote
0
answers
74
views
Comparing optimal strategies in Black-Scholes model with python
Consider the 1-dimensional Black-Scholes model
$$dS_t = S_t(\mu dt + \sigma dW_t)$$
$$dB_t = rB_t dt$$
Given a maturity time $T$, by martingale method the optimal discounted portfolio at the maturity ...
1
vote
2
answers
376
views
Monte Carlo Greeks aren't matching Black-Scholes ones
I'm implementing a Monte Carlo simulation of Geometric Brownian Motion for having a hands on model for pricing and hedging exotic barrier and autocallable payoffs. The idea is to test my ...
0
votes
0
answers
84
views
Estimate Convexity bias for Interest Rate Futures in QuantLib Python
I couldn't find find QuantLib Python example function or script to estimate convexity adjustments on Interest Rate Futures. I can see there is HullWhite class with convexityBias but I struggle with ...
0
votes
0
answers
44
views
Quantlib CallableFixedRateBond yield on a call Date [duplicate]
I have a rather simple example of a fixed rate callable bond that I would like to go from price to YTC. Let's just assume it can only be called on the one specified date to make it easier.
I can get ...
0
votes
1
answer
734
views
Worst-of Rainbow Option - Relationship with Correlation and price
I'm trying to build a worst-of and best-of option pricer, however, I am getting unexpected result while also trying to interpret the relationship between correlation and option price for these rainbow ...
0
votes
0
answers
113
views
PineScript: How to create a signal to buy or sell that uses multiple indicators like RSI, Bollinger Band, etc, at once?
So I am trying to create a signal on tradingview but the problem I am encountering is, I have a bunch of indicators, etc. that have to align and on pinescript, for those who are familiar, they have an ...
0
votes
0
answers
111
views
Clarification for volSpreads in Quantlib's swaption vol cube classes
Pulled from https://github.com/lballabio/QuantLib-SWIG/blob/a397e5397f94e30ac74a37ce1e676f050466d1b0/Python/test/test_cms.py#L144
...
0
votes
0
answers
53
views
GARCH parameters generating simulations that have a lot higher standard deviation's than the historical standard deviation
Below is code using the rugarch package for the daily returns of the NDX, XAU and XAGm. The issue is that when I simulate the data 200 steps ahead for 50k sims, calculate the standard deviation of the ...
0
votes
1
answer
163
views
Quantlib : bonds with fixed cashflows
Using QuantLib, I want to model bonds with fixed cashflows. Specifically, at each payment date, the cashflow is a constant amount $ A_0 $. I can model this manually (especially with an annual ...
1
vote
0
answers
127
views
Struggling with Implementation of Longstaff-Schwartz (2001) LSM Method
I'm having difficulties implementing the Least Squares Monte Carlo (LSM) method from Longstaff and Schwartz's 2001 paper for American Vanilla Put option pricing. According to the paper, they used 100,...
1
vote
1
answer
102
views
Question on QuantLib Python DatedOISRateHelper fairRate
I'm wondering if this is intended in DatedOISRateHelper. Referring to executable code below, 1Y OIS maturity date is 22nd Dec 2025 (21st and 22nd Dec fall on weekend). However when I try to price OIS ...
1
vote
1
answer
106
views
Price OIS fairRate and PV01 without creating OvernightIndexedSwap object?
With QuantLib Python, I'm able to build OIS curve and reprice the inputs by using OvernightIndexedSwap with schedule. Would like to know is there a way to price PV01 and fairRate() of OIS/IRS without ...
2
votes
2
answers
475
views
Mean-variance optimisation with and without constraints
I wrote the following code for a portfolio project but I have an issue.
The first function calculates the mean-variance optimisation based on the lambda (risk propensity), the vector of expected ...