All Questions
Tagged with r or programming
1,825 questions
2
votes
0
answers
237
views
Adjoint Automatic Differentiation
I'm currently benchmarking several Monte Carlo computing methods for sensitivities computation purposes.
I've already done some implementation in Python using Numpy and MyGrad libraries and it's ...
0
votes
1
answer
283
views
0
votes
0
answers
212
views
finding the monthly covariance matrix given daily covariance matrix
consider the following problem i am trying to find the monthly covariance matrix given daily data. i have the following codeimport datetime
...
6
votes
2
answers
432
views
Best practice in QuantLib Python to include borrow rate
When pricing a vanilla option, there are at a minimum 3 yield curves to consider:
risk free yield curve = YC
dividend yield curve = DC (or discrete dividends for American options but not the topic ...
1
vote
0
answers
1k
views
Pricing a Digital Barrier Option using QuantLib in Python [closed]
I'm trying to price a EURUSD digital knockout in QuantLib/Python. Ideally would like to get the same output as this stylized Bloomberg OVML model (OVML EURUSD DIKO 1.0000P B0.9500 01/13/23 N1M). I ...
0
votes
1
answer
217
views
How to efficiently shift BlackVarianceSurface to compute the vega, volga and vanna of an option
I am working with a vol surface that was created as a BlackVarianceSurface.
Now I would like to compute the "vol" greeks for a product and as such I need to shift that surface by a small ...
2
votes
1
answer
385
views
How do you handle non integer time intervals in Quantlib for options pricing (ie intraday pricing)
I'm using QuantLib (python version) for options pricing, and am trying to figure out how to handle non integer dates. If you try and price an option at 9:30 AM and at 4 PM, you should get different ...
1
vote
2
answers
704
views
Quantlib issue with BlackVarianceSurface diffusing with the wrong vol when there are either holes or arbitrages in early maturities
I'm new to Quantlib in Python and I'm running into a quite awkward situation.
I have a vol surface from the market on the SPX index. Not all strikes/maturities are populated. In addition, there could ...
1
vote
0
answers
99
views
Measuring latency with tcpdump and storing output
I am writing a code in python that streams real-time data from the Coinbase Exchange.
...
0
votes
1
answer
309
views
2
votes
1
answer
495
views
What program to use for reverse MIDAS?
I know EViews is used for mixed-data sampling (MIDAS). Can someone pls help me identify a program I can use for reverse MIDAS? Thank you.
2
votes
1
answer
909
views
Problem with pricing a call option using the Monte Carlo Vasicek model
I am trying to price a call option on a zero coupon under the Vasicek Model using Monte Carlo method:
$$C_0 = B(0,\theta) \ \mathbb{E}^{\mathbb{Q}_T}[(B(\theta,T)-K)^{+}]$$
The problem is that the ...
0
votes
2
answers
125
views
How do Personal Finance companies get access to their customers investment accounts? [closed]
I want to create an app that centralizes all the customer's investment accounts into one platform where they can view/monitor their trading positions across all brokerage accounts. How do apps like ...
0
votes
1
answer
159
views
how to add redemptions to amortizing floating bond in dates that are not coupon dates
How can I in QuantLib add redemptions to a AmortizingFloatingRateBond that follow in dates outside the Bond Schedule?
...
4
votes
1
answer
2k
views
Efficient way to store orderbook in Python
I am using the Coinbase WebSocket API to extract real-time data about the orderbook for BTC-USD.
I am using the following code to store the snapshots of bids and asks and the changes to the orderbook ...
2
votes
0
answers
44
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-...
1
vote
2
answers
727
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 ...
1
vote
0
answers
298
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 + \...
0
votes
1
answer
624
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 ...
2
votes
1
answer
256
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 ...
3
votes
2
answers
595
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 ...
0
votes
1
answer
1k
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
...
0
votes
1
answer
838
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 ...
5
votes
2
answers
481
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 ...
1
vote
1
answer
607
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 ...
2
votes
0
answers
162
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] ...
0
votes
1
answer
363
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 ...
2
votes
0
answers
164
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 ...
2
votes
0
answers
116
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 ...
0
votes
1
answer
306
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.
...
2
votes
1
answer
2k
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, ......,...
1
vote
1
answer
713
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 ...
3
votes
1
answer
602
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 ...
0
votes
0
answers
121
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)}...
0
votes
1
answer
205
views
Commodity Futures Cascading in Python
I am new to Quantitative Finance so please bear with me. I have the following data set:
...
0
votes
0
answers
38
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
...
1
vote
0
answers
51
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 ...
1
vote
1
answer
1k
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 ...
0
votes
1
answer
1k
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()...
2
votes
1
answer
1k
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 ...
1
vote
1
answer
46
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 ...
0
votes
1
answer
174
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 ...
0
votes
0
answers
357
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 ...
1
vote
0
answers
173
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 ...
1
vote
1
answer
89
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':
...
-1
votes
1
answer
86
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 ...
0
votes
0
answers
454
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 ...
0
votes
0
answers
296
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 ...
2
votes
0
answers
614
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 ...
0
votes
1
answer
318
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 ...