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.

1,184 questions
Filter by
Sorted by
Tagged with
13 views

EUROPEAN PUT OPTION: STOP-LOSS HEDGING (Matlab) [closed]

The goal is to discretize the following Matlab Code ...
18 views

Are there any programs that show the highest limits order on the market?

Super noob here, and I'm sure this is already a thing but I can't find it... Often times on various stocks there are huge limit orders that have a have a high likelihood of bouncing the price. I was ...
24 views

How to derive renko volume from candle OHLCV data

i have been recently trying to generate Renko bricks from my OHLCV data, I'm currently using stocktrends module and have successfully generated the bricks, but I'm having trouble with generating the ...
1 vote
39 views

How to retrieve Yahoo Finance tickers for stocks, given the companies' name

I'm a student attempting to download time-series data for 27,000 stocks. I initially tried using Factset's API but lack access (as a student, I am able to manually download data, without access to ...
• 21
216 views

Calculating swap rolldown using the RatesLib Python Library

The code I am using is below, pulling in swap curves from BBG and then using RatesLib to price the swaps. ...
• 103
100 views

Python QuantLib datecount ActualActual basis vs Matlab daycount basis

I am translating a code from MATLAB to Python and I need to find equivalent setting to MATLAB’s day-count basis of 0 = actual / actual. My MATLAB code uses date2time function to determine the length ...
60 views

Issue with Volatility Parameter for Geometric Brownian Motion [closed]

I am trying to create a Geometric Brownian Motion based model on python. According to theory, A stock price follows : S(t) = S(0) exp{σW(t) + µ − σ^2/2 dt}  The volatility parameter ...
42 views

Conducting PCA on features of dataset

To preface, I am very new to quantitative finance and nowhere near the point of actually trading so forgive me if this question is trivial to most of you. I am making a basic k-means clustering ...
31 views

...
1 vote
65 views

Is my spread calculation correct?

I have automated Pair trading strategies running on both CME Futures and cryptocurrency perpetual pairs. I can chose between different spread calculation type and I noticed that the one I thought was ...
• 11
16 views

How To Get Morningstar Unique Stock IDs

I have been trying to extract every piece of information I can from Morningstar's Investor platform and save it offline for free to integrate for a different use case; I have figured out how to ...
• 1
57 views

How to compute moving average convergence divergence without using pandas ewm function?

I'm trying to compute the moving average divergence convergence (MACD) which is a technical indicator in trading. To compute MACD we have to find out exponential moving average over a certain period ...
100 views

Rateslib - Pricing 1y EUR vs 6M (EUSA01)

I am using the rateslib python library to try to price some European swaps. It seems to be working for most tenors aside from the 1y for some reason. The code I am using is below: ...
• 103
1 vote
81 views

Reverse Optimization: finding the returns that satisfy specific weights given one known return

Here is the premise: I have a three asset portfolio, I know the assets covariance, the client's risk aversion and the expected return of one of the assets. I also have a desired set of weights. So, 1) ...
• 21
31 views

How to Bootstrap a daily compounding future in QuantLib

Hi I am currently tying to bootstrap the F-TIIE curve for mexican swaps In the short term it uses the F-TIIE Futures. These F-TIIE futures are 1 month futures that start on the first day of the month ...
55 views

ql.OvernightIndexFutureRateHelper asking for a fixing, but not able to add it

I´m trying to make a Overnight Index FutureRateHelper but when bootstrapping, the following Error arises: RuntimeError: 1st iteration: failed at 1st alive instrument, pillar May 31st, 2024, maturity ...
95 views

Volatility Surface Modelling in Python

For my master thesis, I try to create a Volatility Surface for S&P500 Index options. Every time I run my code, the surface I get is full of spikes. I'm just not sure if these are outliers which ...
16 views

Is there any way to implement GARCH-MIDAS model in R for multivariate estimation?

I'm writing a research paper in economics, and would like to research the impact of both financial and macroeconomic variables on the NIFTY50 index. My plan was to use a GARCH model. I've stumbled ...
114 views

Get bonds data in python [duplicate]

Anyone knows a way of getting trustworthy bonds data in python? I know that for stock there is yfinance package but it doesnt include bonds. Thx
240 views

Recommended Setup for QuantLib-Python AmortizingFloatingRateBond

I am trying to model a term loan in QuantLib-Python that makes quarterly interest payments at CME Term SOFR 3M + 10bps + 525bps paid in arrears with a 2 business ...
• 64
22 views

eGARCH(1,1) model evaluation (R). How to assess model integrity?

I am using GARCH modelling for my bachelor thesis in Economics. I am entirely new to the concept, and have only been looking into these kind of models for about a week now. I am trying to do a ...
• 1
81 views

Get upfront bps from a CDS with QuantLib

I have an example the pricing of a CDS in Excel and I am trying to match it with QuantLib, in order to get the upfront bps. Below there is a print of the excel screen where I know all the values are ...
92 views

Brent algorithm supporting automatic differentiation

I painfully implemented automatic differentiation (AD) and a Gauss-Kronrod numerical integration routine working with it with AD. (Fully tested etc, perfectly working.) Needing a root finding ...
• 113
61 views

Maximze Sharpe ratio from matlab to python [closed]

I know there matlab library funtion for Optimzing Sharpe ratio estimateMaxSharpeRatio, it mentioned it use direct method How can i do the same thing in python Is there any python libraries Or need ...
• 1
59 views

Visualizing Drawdown

I want to replicate the image below: Does anyone have an idea how to do this in Python. To be specific; I am only having problems plotting the blue shade and the blue lines.
• 1
20 views

How to get a complete and up-to-date list of ticker symbols for any Yahoo Finance index? [duplicate]

Good afternoon everyone, I am currently in a dilemma to which I have tried to find a solution for a whole week but unfortunately I have come to nothing. I have tried to locate a library or create a ...
1 vote
165 views

Reverse optimization: How to generate the expected portfolio returns given the weights and a series of constraints on those weights?

I have the below function in Python. My objective is to back out the expected returns associated with certain portfolio weights given a series of assumptions. From this I want to generate the expected ...
• 21
1 vote
75 views

Setting up QuantLib to get correct yield for bond with long first payment period

I am dealing with fixed rate bonds. There is one particular bond, 34659UAC0, that caught my eye. This bond has a first coupon period of a whopping 5 years, followed by regular periods of 6 months. My ...
• 11
139 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 ...
• 64
35 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 ...
• 135
140 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 ...
29 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!
50 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 ...
1 vote
244 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-...
25 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 ...
• 73
48 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
188 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 ...
• 125
36 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 ...
1 vote
72 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 ...
• 55
219 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 ...
142 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 ...
• 31
64 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
132 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, ...
• 31
20 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 ...
• 1
253 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/...
• 31
190 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 ...
• 71
70 views

Deal details ...
134 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 ...
• 127
293 views

IDE to use for Python for Quant Trading [closed]

Dear Quantitative Finance Stack Community, Since many Quantitative propietary trading firms seem to be using Python over alternatives such as STATA. I have now decided to get myself familiar with ...
• 165