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
2 votes
0 answers
17 views

Using Yield Term Structure for Bond Pricing in QuantLib: Is a Zero-Coupon Curve Necessary?

I've been using QuantLib for constructing a yield curve and pricing a bond. I am wondering if I'm using the correct method to create my yield term structure (yts) ...
-3 votes
0 answers
40 views

python code for DV01 [closed]

python code to Draw a curve for DV01 risk of a puttable bond, which is due to mature at 30 years and have a feature of put at 15 years. Where will the maximum exposure be? Shall this bond be sold at ...
10 votes
2 answers
9k views

How to use statsmodels' Granger causality test to measure the lag between two time series?

I am using the Granger causality test to measure the lag between pairs of time series where it is already apparent that one is following the other. So I am not expecting this test to tell me whether ...
0 votes
1 answer
72 views

Discrepancy between Bootstraped Zero Rates: Gaps between Bloomberg and My Calculated Zero Rates

I have been attempting to bootstrap zero rates using quantlib, but I am perplexed by the significant discrepancies between my calculated zero rates and those ...
0 votes
1 answer
318 views

Using QuantLib to get all holidays currently published by an exchange in multiyears without specifying a range

Is there a way to get a list of all the holidays published in an exchange calendar without specifying a date range? For example, NYSE has published their holiday calendar up to 2024 and I want to see ...
4 votes
1 answer
180 views

Yield curve bootstrapping not producing expected cash flow start date

I'm currently working on building a yield curve using OIS swaps. However, I'm encountering an issue with the cash flow start date that I'm struggling to understand. Here's a simplified version of my ...
-2 votes
0 answers
19 views

Mutli-period performance contribution with python code [closed]

I have a portfolio with weights and performance in 2 dataframes. I would like from these calculate the contribution of performance of each asset. I mean that if I have the returns of 3 assets: ...
1 vote
2 answers
72 views

CrossCurrencyBasisSwapRateHelper feature deprecated

I have been using the CrossCurrencyBasisSwapRateHelper feature to generate a colateralised discounting curve where the collateral is in a currency different to that of the asset. However, I noticed ...
14 votes
6 answers
8k views

Library of basic indicators

I am looking to start developing a trend following strategy and have been looking to do something in either C# or Java and wondered if there was a library or framework out there that would make ...
0 votes
1 answer
53 views

QuantLib: null term structure set to this instance of index

I'm playing around with QuantLib and trying to price an interest rate cap using HW 1F model. ...
0 votes
1 answer
189 views

Looking for non-GAUSS Code for Thiery Roncalli's book on Risk Parity and Budgeting

I am going through the book 'Introduction to Risk Parity and Budgeting' by Thierry Roncalli (2013). The author provides software for the various concepts illustrated in the book, but it is all done in ...
2 votes
1 answer
661 views

Question regarding fitting Euribor curve using different basis quotes using Quantlib Python

I am trying to fit a EUR curve based on the following instruments:- EONIA quotes 1m vs 6m basis quotes 3m (outright) quotes 6m (outright) quotes 6m vs 12m quotes (1) , (3) & (4) are simply ...
3 votes
2 answers
122 views

Average drawdown and average drawdown length in Python

I'm trying to use Python to give me more information about drawdowns than just the max drawdown and the duration of the max drawdown. I would like to determine the number of drawdowns that have ...
4 votes
1 answer
78 views

Quantlib Slow valuation of ois_swap on multiple eval days

I have bootstrapped a curve using several depo and swap rates and am trying to use that curve to get the NPV of a swap over a period of time. The generation of prices iteratively through time is ...
2 votes
3 answers
371 views

Q regarding amortization of 500,000 loans

I am brand new to this forum. I asked this question on the main StackOverflow site and it was suggested that I ask here. My task is to find a method to quickly calculate the monthly cash flow on ...
1 vote
1 answer
83 views

QuantLib: How to iterate over Cashflows in a Leg

I am looking for a way to obtain dates and amounts of each cashflow in a leg, without having to pop the cashflows out of the leg, like this ...
5 votes
6 answers
21k views

Which library shall I use for time series analysis in Java?

I'm looking for a library to do some time series analysis in Java but I can't find anything suitable. I've found plenty of libraries such as Math3 of JSAT but there's much I can you for my problem. ...
4 votes
1 answer
420 views

GARCH(1,1)-M MLE optimization with fmincon in R

I've searched thru dozens of papers and did not find in any of them satisfying and enough theoretical answers to my concerns. So I've combined everything what I found below. Please indicate if my ...
1 vote
1 answer
170 views

Python yield curve bootstrapping equivalent to Matlab IRDataCurve.bootstrap

I want to bootstrap the yield curve of multiple currencies using 3M futures. I have it implemented in Matlab, but need to transfer to Python. I have a vector of dates and a vector of future prices. ...
3 votes
1 answer
36 views

Quantlib: how to construct CDOR volatility cube? Getting error when using SwapRateHelper

...
4 votes
1 answer
334 views

PortfolioAnalytics and regime switching issue

I've been playing around with the R package PortfolioAnalytics and I have spent more time than I'm willing to admit to try and resolve this issue: When I follow the regime switching example with the ...
0 votes
0 answers
63 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 ...
1 vote
1 answer
41 views

API for stock price data for commercial re-distribution? [duplicate]

(I know there are existing questions on this topic, but none seem to be for commercial re-distribution use, so please keep this question active.) It seems there are many websites offering API for ...
0 votes
0 answers
41 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
32 views

Define the supports and resistances [duplicate]

When I day trade, I easily notice support and resistance areas. Visually it seems very intuitive to spot them, but I can't define them so that I can spot them using python. Can you give me a clear ...
0 votes
1 answer
385 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
221 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 ...
0 votes
0 answers
35 views

Estimating Returns with the Non-Central t-distribution

The Boost C++ Libraries provide a set of statistical distributions in their Math Toolkit library. The best candidate I can find among those available that will capture skew and kurtosis typically ...
1 vote
1 answer
487 views

How to calculate basic components like trend, momentum, correlation and volatility in Pandas(Python)

I am new to quant. finance and trying to calculate trend, momentum, correlation and ...
4 votes
1 answer
268 views

Bartlett's delta gives wrong signs for calls and puts

There is a paper by Bruce Bartlett introducing a modified delta for SABR model which accounts for the correlation between forward and volatility processes. The main result of the paper is that if $dF$ ...
0 votes
1 answer
350 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 ...
0 votes
0 answers
39 views

Hurst Exponent and Smoothed Hurst Exponent values are the same and incorrect plotting

I'm working on a script to calculate and plot the Hurst Exponent and Smoothed Hurst Exponent for a stock's historical price data using Python. When I run the script, I face two major issues: The ...
5 votes
1 answer
576 views

How to (efficiently) calculate the maximum possible return of a perfect "crystal ball" investment strategy?

I am new to the world of investing, so please excuse the clumsy wording of the question... there is probably a better term for what I am looking for or maybe this is even a known/classic problem. If ...
5 votes
1 answer
1k 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 ...
1 vote
0 answers
697 views

Schedule, Yield-to-Maturity, and NPV of Fixed Rate Bond from QuantLib Python

I would like to price a fixed rate bond using QuantLib Python. The pricing is fine, however I would like to understand how to extract the Yield-to-Maturity (YTM) of the fixed rate bond, that is, the ...
4 votes
1 answer
852 views

Trader Workstation on Ubuntu cannot be connected to via the API

I am using ibPy to connect to TWS on a fairly fresh ubuntu machine. I have been successful in logging into the paper trading account and submitting buy and sell orders programatically via the ibPy ...
1 vote
1 answer
793 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
98 views

How to calculate the discount factors for two deposits in an interest rate curve [closed]

I am trying to calculate the zero rate for a piecewise linear zero curve. I have the following deposit on the short end STIBOR 1D, is identified as a tomorrow next deposit: 0.02416 STIBOR 3 Month: 0....
2 votes
1 answer
303 views

Gamma for a basket option in Python - Finite Differences vs. AAD Autograd library using Heaviside Approximation

I have been trying to use the Heaviside Approximation for a simple basket option so that I can solve for Gammas with AAD (Adjoint Automatic Differentiation). This routine smooths the payoff function ...
3 votes
1 answer
526 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 ...
2 votes
1 answer
552 views

Kou model implementation Python

Hey I try to implement Kou model in Python. This is my code: ...
0 votes
0 answers
20 views

Free historical data for options [duplicate]

is there a way to get options historical data for free or for a cheap price, let's say 2 years at least for both EOD data and hourly ones for just one underlying instrument such as sp500? Or ...
0 votes
1 answer
64 views

Pricing a fixed rate bond with ex-dividend date in QuantLib Python [duplicate]

I'm trying to price a fixed rate bond with ex-dividend date using Python QuantLib. This is a feature of UK Gilts. On regular days, I'm able to get the correct accrued interest, but on days in the ex-...
1 vote
1 answer
205 views

Getting incorrect options data with IB API. Missing real time market data subscription?

I'm having a problem getting options data with IB's API. The data seems not to be correct. In my code I'm getting some 0DTE call options for the Mini SP500 March Futures contract and printing their ...
1 vote
1 answer
164 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 ...
4 votes
1 answer
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
987 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 ...
2 votes
3 answers
11k views

Calculating log-returns across multiple securities and time

I've been getting very confused on the topic of calculating returns. To get cumulative returns in time, log-returns are used, but apparently log-returns aren't used across different securities at a ...
0 votes
1 answer
306 views

Option pricing Greeks in Python - incorrect Gamma with MC option pricing (Black) using AAD autograd / JAX libraries - but works with closed form?

I am attempting to use AAD (Adjoint Algorithmic Differentiation) with a simple Black MC pricer, and found that the Gamma is incorrect. The output was compared to Black analytical Greeks, as well as ...

1
2 3 4 5
34