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
1 vote
0 answers
10 views

Fitting model between security price and intraday volatility

I'm trying to construct a model which shows how much the closing price of a security ($P_t$) differs from the VWAP of that security on that day ($VWAP_t$). I'm calling this measure the "VWAP ...
user avatar
0 votes
0 answers
11 views

Exponentially Weighted non-moving Calculations

Is there a library which contains just single exponentially-weighted calculations that aren't "moving"? I have a time series of data for which I'm wanting to calculate the exponentially ...
user avatar
0 votes
1 answer
35 views

Calculate Exponentially-Weighted Covariance Matrix over Finite Window

I have an (n,m) array (specifically containing asset returns over n days for m assets). I'm ...
user avatar
-1 votes
0 answers
32 views

Eulero discretization [closed]

Write the Euler discretization of the 1-dimensional stochastic equation $dXt = b (t, X_t) \space dt + \sigma (t, X_t) \space dW_t$ For this part I would say all right because it is a purely ...
user avatar
0 votes
0 answers
13 views

mean return and volatility with transaction cost

What means that 5 bps per half-turn for transaction cost? How can I implement mean return and volatility with this transaction cost in formula or python code?
user avatar
  • 1
0 votes
1 answer
42 views

long short portfolio sharpe ratio

What is the proper way to caluclate sharpe ratio for the long short portfolio? When I calculate daily return with no cost, I use this formula: (return for long k.mean()+ (-1)*(return for short k.mean()...
user avatar
  • 1
0 votes
1 answer
51 views

Bloomberg DLIB BLAN in Python

The title describes the question. Below provides more details. Kindly let me know how industry is working on this. I am a heavy user of Bloomberg excel API, including WAPI and DTK (formula such as ...
user avatar
  • 1
1 vote
1 answer
34 views

Finding optimal option to maximise gains under given price hypothesis

Let's have Stock S at \$100 on January and my hypothesis is S will be trading at \$150 in July. Is there any Python/R package that I can feed with option prices from my broker and it would return the ...
user avatar
0 votes
0 answers
17 views

Second-pass Regression testing coefficients

I am supposed to test the following hypothesis in second-pass regression, I work with R. Second-pass regression is in the form: $\overline{r_{i}-r_{f}} = \gamma_{0}+\gamma_{1}b_{i} + e_{i}$ The first ...
user avatar
0 votes
1 answer
63 views

Curious where Financial Data APIs get data

First time posting on this stack exchange, but I was using Polygon to get some Market Data recently, and I was curious about one thing. Where do they get their data from? Might be a dumb question, but ...
user avatar
  • 101
0 votes
0 answers
58 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 ...
user avatar
1 vote
0 answers
53 views

How to optimize the finding of divergences between 2 signals

I am trying to create an indicator that will find all the divergences between 2 signals. (A divergence being defined as t1, t2 such that one signal increases between t1 and t2 while the other ...
user avatar
  • 121
1 vote
1 answer
62 views

Coefficients of univariate regressions equal to those in the multivariate regression

I am currently running fixed effect regressions with multiple dummy variables. These dummy variables are created by a grid of '1' '0': ...
user avatar
  • 154
0 votes
0 answers
37 views

calculate trading returns when trade nominal goes up in 100 dollar increments

I am trying to calculate total and annualised returns on trading. The problem is that the trades placed have a minimum size of 100 dollars, so we cant assume continuous compounding (100% reinvestment)....
user avatar
-1 votes
1 answer
65 views

Can NumPy calculate the % change the way it is shown in multiple instrument charts?

I have closing prices for multiple equities in NumPy arrays (or a pandas timeseries DataFrame). I like to calculate the % change numbers for the closing prices in the DataFrame the way it is shown in ...
user avatar
  • 111
0 votes
0 answers
77 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 ...
user avatar
0 votes
0 answers
22 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 ...
user avatar
  • 494
3 votes
0 answers
105 views

Interesting finding... "Adjusted Kirk's" and "Bjerksund-Stensland" are exactly the same ??? Spread option calculation

This is more of an academic question. The results are SO close, I think they are ACTUALLY THE SAME FORMULAS. So someone published a paper with a "new" method to adjust Kirk's formula to ...
user avatar
  • 145
0 votes
0 answers
71 views

Quantlib in Python

I have been playing around with QuantLib in Python and have been struggling with couple of simple tasks I would like to share and hopefully get help from the community debugging: The fact that it's c++...
user avatar
0 votes
0 answers
66 views

Put call parity with american options

I am trying to back out the put call parity price of an American call option for a 10 min period with tick data (using CME ES Futures Options in this example, see plot below), using the standard PCP ...
user avatar
  • 53
1 vote
1 answer
65 views

BKM risk neutral moments in python

I am trying to compute the BKM implied moments (Bakshi, Kapadia and Madan 2003) in python by following this paper: Neumann, Skiadopoulos: Predictable Dynamics in Higher Order Risk-Neutral Moments: ...
user avatar
  • 53
0 votes
1 answer
78 views

compute Expected Shortfall / Conditional VaR from distribution

I want to compute the Expected Shortfall from a distribution of returns. I have no closed solution for my distribution of returns, so I wonder if I can simply compute ES by taking the mean of all the ...
user avatar
  • 115
0 votes
0 answers
55 views

Extend basket analytic solution (equal weighted) to a various weight basket, also put formula

So I coded up the solution from here: Do basket options have a closed form valuation formula? Which provides a good solution for equally-weighted underlyings under a Black model. The simplified ...
user avatar
  • 145
0 votes
0 answers
45 views

Lazypredict using Multiple Tickers

I am trying to use multiple tickers close prices , create some technical indicators and run lazy predict to get multiple results of Machine Learning performance models. I have cleaned the data somehow....
user avatar
  • 1
0 votes
0 answers
34 views

How to set estimation period in R package eventstudies?

I have a question regarding the R package eventstudies. I want to use the Market model to compute abnormal returns. But am not sure how I can set the estimation ...
user avatar
0 votes
0 answers
36 views

UnivariateSpline Spline Interpolation behaving erratically

I am using univariate spline to interpolate betweeen a number of dots I have (in blue - it is a yield curve). The code is the following: ...
user avatar
  • 23
2 votes
1 answer
207 views

Quantlib: day-by-day evaluation of option value

I'm using Quantlib in Python to price an FX option. I'm comparing the result to Bloomberg, to make sure the code is working correct. I want to calculate the P&L of a certain option trading ...
user avatar
  • 51
0 votes
0 answers
49 views

Python/Matlab code to price options under Heston-Hull-White (or Heston-CIR) using sparse grid/finite difference methods

I am looking for Python (or Matlab) code to price options under the Heston-Hull-White (or the Heston-CIR) using sparse grid/finite difference approach. I can find code just for Heston, or just for ...
user avatar
  • 43
0 votes
0 answers
32 views

How to reduce validation error for LSTM while working on time series data?

I am currently building a multivariate LSTM for predicting the close price of the next 3 days. I have tried changing parameters such as learning rate, number of layers (and neurons), activation ...
user avatar
  • 1
1 vote
2 answers
220 views

2-day ahead prediction of value at risk with GARCH(1,1) in R

Let's say I have a 10 year dataset of Tesla (example) and I am taking the percentage change of lag 2: ...
user avatar
0 votes
0 answers
48 views

What does the locality linear coding function do?

I got this code for spectral clustering from this link. This is a landmark-based spectral clustering code. What is the purpose of the "locality linear coding" function in this code? how it ...
user avatar
0 votes
0 answers
236 views

realized volatility calculation in python

I am trying to do a standard realized volatility calculation in python using daily log returns, like so: ...
user avatar
  • 53
0 votes
2 answers
81 views

Running scripts outside of desktop

In the company I work for, I use several Python scripts that automate many tasks. However, this happens via the task scheduler. I would like to ask you what solutions are you using that make this ...
user avatar
1 vote
0 answers
86 views

Backtesting Strategy in R for simple empirical value at risk

I am new in backtesting methodology and I want for start to keep things simple.Say that I have the following data: ...
user avatar
1 vote
0 answers
54 views

Calibrating HW 1f model params to a term structure market data

I am using Quantlib to calibrate the HW model params to the market swaption price. The attached chart shows the performance of the calibration. Am I correct in saying, this is expected for the 1f HW ...
user avatar
  • 121
1 vote
0 answers
62 views

QuantLib: Modeling GBP-6M-Libor Fixed-Float swaps as valuation date after 2021-12-31 using QuantLib

Starting from January 2022, LIBOR fixings/rates for most currencies (GBP, EUR, CHF, JPY) will be discontinued. After the switching date 2021-12-31 , such floating-rate bonds will effectively have two ...
user avatar
  • 59
0 votes
0 answers
54 views

Best Strategy for storing Stock Data

I have a question that is about how to architecture an API heavy application to avoid long waiting times and long processing. The application is a stock screener which contains all sorts of data for ...
user avatar
  • 101
1 vote
0 answers
55 views

EWMA initial margin model risk

Let's say that someone wants to estimate the initial margin model (very simple one) with the exponential weighted moving average approach.For margin period of risk 2 days. ...
user avatar
0 votes
0 answers
90 views

Simulating sum of squared brownian motions process

I'm trying to simulate the following stochastic process: \begin{equation} R_t = \sum_{i=1}^nB_{i,t}^2 \end{equation} which has the following dynamics: \begin{equation} \begin{aligned} dR_t = \sum_{...
user avatar
0 votes
0 answers
54 views

Optimal Entry, Exit, And Stop Loss From Historical Stock Data

I'm trying to build a system that recommends stock trades. My goal is calculate optimal values for the following: Entry Parameter: expressed as a percentage change downwards from the opening price. ...
user avatar
0 votes
2 answers
132 views

QuantlIb: How to use maturities in place of Tenors in OIS rate helpers Quantlib?

I would like to know if I can use maturity dates from my rates dataframe to generate OISratehelpers. In the following code the OIS rate helper use 'tenors' and I want to replace those tenors with ...
user avatar
  • 59
0 votes
1 answer
144 views

Applying Differential Evolution to the Nelson Siegel Model in Python

I am trying to create a zero curve from a series of government bonds by minimizing the differences in the dirty prices. The problem is that there is something wrong with my differential evolution ...
user avatar
  • 21
0 votes
0 answers
139 views

Bloomberg OVML| FX option pricing | Python

Wanted to check if any API for python is available to replicate Bloomberg's OVML. The objective is to perform FX options pricing for multiple positions, and we are getting stuck in calculating ...
user avatar
0 votes
0 answers
106 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:...
user avatar
  • 121
0 votes
1 answer
77 views

Verify numerically relation between mean deviation and standard deviation

I was reading "We Don’t Quite Know What We Are Talking About When We Talk About Volatility" by Goldstein and Taleb, and I was trying to quickly verify numerically the relation between mean ...
user avatar
0 votes
0 answers
67 views

QuantLib: null pricing engine

I have the following class: ...
user avatar
0 votes
1 answer
49 views

Error in class when pricing vanilla European options using QuantLib

I'm brand new to QuantLib and have the following class that I'm using to price European options: ...
user avatar
-1 votes
2 answers
87 views

Easier way than using QuantLib to compute the price and Greeks of a vanilla European option?

I'm using the following to compute the price and Greeks a vanilla European option: ...
user avatar
0 votes
1 answer
170 views

Estimating Amihud's illiquidity in Python

I have found the following code in the book Python for Finance by Yuxing Yan, in page 267 for estimating Amihud's illiquidity ...
user avatar
1 vote
0 answers
85 views

SciPy Calibrating Heston call option

I have been attempting to calibrate my Heston model, but I am running into issues with scipy.optimize module. I have tried various scipy optimizers, but they all return the error "TypeError: can ...
user avatar

1
2 3 4 5
33