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

Value at Risk and Conditional Value at Risk [closed]

I'm quite new to quantitative finance, and this is my first question here. I'm starting with a toy project to measure the risk of certain sectors(like Banking, Energy etc.) The initial approach I ...
user avatar
0 votes
0 answers
65 views

How to master Monte carlo pricing in general? [closed]

I would like to master Monte Carlo pricing. But I don't have so much experience. All I know is that MC is used for approaching an integral result. Could you please give me some books or courses ...
user avatar
2 votes
0 answers
32 views

Any idea where I can find every transcript of the FOMC over the years in text? [closed]

I am trying to scrape each FOMC meeting during the years however I am having trouble finding a repo of the fed that holds all the data. I finally ended up finding this : https://www.fedsearch.org/fomc-...
user avatar
1 vote
2 answers
165 views

Volatility forecast for 5-minute frequency data

I have high frequency data for financial stocks (5-minute periodicity) and I want to forecast volatility. I'm familiarized with the usual ARCH/GARCH models and their variants for daily data but after ...
user avatar
  • 11
1 vote
0 answers
103 views

CEV model effective simulation

I want to simulate the following CEV process : $$ dM_t = \sigma_t M_t^{\eta} dW_t $$ Using Euler discretization to $M_t$, if at a given time $t$, $M_t$ takes a negative value then $M_{t+1} = M_t + \...
user avatar
  • 11
0 votes
0 answers
58 views

Can't reproduce cumulative returns from first principal components of stock returns

The question I have is with regards to the first factor that is produced by a PCA on stock returns. That is, when I call ...
user avatar
0 votes
0 answers
54 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 ...
user avatar
  • 165
1 vote
1 answer
51 views

Why is my put intrinsic value greater than my actual put value in BSM? Python code

I have been creating a class for determining put/call values based on the Black Scholes Merton model and have run into a weird problem. For some reason my put values end up being less than the ...
user avatar
3 votes
2 answers
128 views

Python: detecting measured moves of candlestick data

Goal: I'm looking to see if it's possible to programatically detect "measured moves" on candlestick data. The price data I am using is successfully retrieved from the TD Ameritrade platform ...
user avatar
  • 131
0 votes
0 answers
40 views

Data structure to describe ownership of business entities: What would make a good one?

I am building a database of news outlets, and I would like to include information about the ownership of the news outlets. In order to do this to my satisfaction, I would like to store information ...
user avatar
0 votes
1 answer
146 views

From Implied volatility to shifted Black volatility

I don't know who to go from normal to shifted black volatility before calibrating SABR with negative interest rates. I see: "As we know that implied volatilities have a one-to-one relationship ...
user avatar
0 votes
1 answer
166 views

crypto HFT architecture

This architecture is designed to minimize latency with the help of busy-spinning and CPU affinity locks(meaning each producer/consumer thread running in only one core), preventing a thread from ...
user avatar
  • 33
5 votes
2 answers
261 views

Cointegration between crypto markets

I'm having an hard time understanding how cointegration works. Basically i'm trying to find cointegrated pairs in the crypto market, so i do the following: Get OHLC data for the two markets (i'm ...
user avatar
  • 51
1 vote
1 answer
114 views

Suggestions for backtesting machine learning 'model'/strategy in Python

I have coded a machine learning algo (sklearn) in Python, that uses different 'look back periods' for training a model, which is then used to predict future prices of a stock. It has a 52% accuracy in ...
user avatar
0 votes
0 answers
22 views

Defining leverage function in QuantLib

I have numpy arrays for X,Y and Z that define a leverage function for the Heston SLV in Quantlib (Python). This would then be used to define a pricing engine like so ...
user avatar
  • 101
2 votes
0 answers
39 views

QuantLib option.NPV() returns interpolation error

I've been trying to price some barrier options with a Heston model on Quantlib and it works quite well most of the times, but sometimes I get the error: "interpolation range is [3.4314, 4.28384] ...
user avatar
  • 21
0 votes
1 answer
97 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 ...
user avatar
2 votes
0 answers
69 views

option pricing using empirical distribution

I am looking for ways to express a directional bet on a commodity through futures options. Assume that there's 50% probability that oil will spike up 100% in the span of 30% during the next 9 months ...
user avatar
  • 21
2 votes
0 answers
50 views

CRSP Permco Aggregation

I saw that for one CRSP Permco, there could be multiple CRSP Permnos. Could anybody provide guidance on how to aggregate the market capitalization, returns, etc... by permco and date? I am currently ...
user avatar
0 votes
0 answers
56 views

How do I price options with an American barrier on Quantlib?

I've been looking for a way to price options with an American barrier (continuous), but I can't seem to find any documentation on this... In the "QuantLib-Python Module Reference" by David ...
user avatar
  • 21
0 votes
1 answer
54 views

Quantlib: VanillaSwap not using underlying Index fixings correctly

I am trying to reperform a vanilla swap. The problem is that the vanilla swap object does not seem to be using the exact fixings of the underlying index. ...
user avatar
0 votes
0 answers
115 views

Quantlib python convertible bond pricing

I'm trying to price a convertible bond using quantLib library in Python but I can't seem to build the convertible bond object with ql.ConvertibleFixedCouponBond function. I get this error message, ...
user avatar
  • 1
0 votes
0 answers
36 views

API for making investments into index funds?

I'm looking for an API that would allow me to automate a monthly investment into an index fund ideally in UK or US. I've looked at upvest but waiting to hear back from them. Are there any other APIs I ...
user avatar
  • 1
2 votes
1 answer
206 views

Heston Model python MC simulation

I have this exercise. $\\\\$ Look for realistic values ​​of the parameters and calculate the price of a European Call with maturity $T = 0.5$ and $S_0 = 1$ for the strike values $​​K = 0.5,0.6, ......,...
user avatar
1 vote
1 answer
175 views

Euler Discretization python code

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
3 votes
1 answer
108 views

API for Commodities Stock markets

I would like to have a clear picture about lithium investments all over the World. I like this website where I can see all companies related to lithium on the Australian Market. The website also ...
user avatar
0 votes
0 answers
79 views

Inconsistency between simulation and the probability of a "stock" hitting take profit before stop loss

Let's assume a stock at time $t$ is worth $X(t)$. If the returns of $X(t)$ are i.i.d. and normally distributed,the probability of $X(t)$ hitting a value $H>X(t)$ before $L<X(t)$ is $\frac{H-X(t)}...
user avatar
0 votes
1 answer
87 views

Commodity Futures Cascading in Python

I am new to Quantitative Finance so please bear with me. I have the following data set: ...
user avatar
0 votes
0 answers
30 views

How to predict what stage of business cycle we are currently in based off of unemployment indicators

I am trying to predict what part of the business cycle (Early, Mid, Late 1, Late 2) we are currently in by looking at unemployment indicators. Qualitatively, I've reasoned that: . Early Mid Late 1 ...
user avatar
1 vote
0 answers
32 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
19 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
77 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
0 votes
0 answers
26 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
115 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
144 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
39 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
1 answer
74 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
91 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
68 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
66 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
38 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
74 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
88 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
35 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
  • 534
3 votes
0 answers
153 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
  • 165
0 votes
1 answer
129 views

Quantlib: How to bootstrap FedFunds Index having other tenors 3M, 1Wk, etc?

I am valuing few Basis Swaps having combination of USD-FedFunds-H.15-OIS-COMPOUND3M vs USD3MLibor. However, I can understand to value 'USD-FedFunds-H.15-OIS-COMPOUND1D' by using ql.FedFunds(). But ...
user avatar
  • 59
0 votes
0 answers
171 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
120 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
  • 93
1 vote
1 answer
85 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
  • 93
0 votes
1 answer
91 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

1
2 3 4 5
21