All Questions
Tagged with r or programming
1,824 questions
2
votes
0
answers
57
views
Help with Implementing Basket Option Pricing Code from Borovkova, Permana, and van der Weide (2007)
I'm working on pricing basket options for my research and am referencing the paper "A Closed Form Approach to the Valuation and Hedging of Basket and Spread Options" by Svetlana Borovkova, ...
1
vote
1
answer
90
views
Simulating Kou's Asymmetric Double Exponential Random Variable
In Python, I import NumPy module to generate Kou's a vector of Asymmetric Double Exponential Random Variables (ADERV). I attempt to apply Glasserman's method for simulating the aforementioned from his ...
0
votes
1
answer
112
views
Geometric Brownian Motion vs Lognormal (Monte Carlo)
I am a bit confused. I thought that simulating stock prices via the GBM model is equivalent to drawing returns from a lognormal distribution.
In particular, consider the following Python code, which ...
0
votes
0
answers
47
views
Quantlib: flat forward curve construction with spreads + jumps
I am trying to build a flat forward curve with some specificities. The input data for this curve is a mix of forward rates, zero spreads and jump specifications. See an example dataset below:
FORWARD ...
0
votes
1
answer
64
views
Lead/Lag statistical test in Python
I have two series of data, one showing positioning data and one showing price data. Generically the format is similar to the below:
Price:
Date
EUR
JPY
NOK
SEK
Date
price
price
price
price
Date
...
0
votes
0
answers
36
views
Stock screener for US stocks - yahoo API
I am trying to create simple stock screener in python for all US stocks (yahoo API). Due to the large amount of data even ThreadPoolExecutor does not work. What do you propose I could use?
0
votes
0
answers
75
views
Where can I find good and cheap historical options data API?
I'm looking for an API that can provide historical option contract prices (OCHLV) for USA stocks and preferably a list of option symbols so I don't have to generate them manually.
I tried working with ...
0
votes
0
answers
29
views
Which fields are companies required to report for 10-k filings?
For 10-k filings, which fields are companies required to report? For example:
Liabilities
Operating Expenses
Operating Income
Cash and Cash Equivalents
Property, Plant, and Equipment
Cash Flows from ...
0
votes
0
answers
38
views
Computing Daily MTM from a Trade log of a Positional Strategy
I've generated the trade log shown below based on a positional strategy. There may be multiple or no trades on any given day.
The log includes entry/exit times and prices, and I also have access to ...
1
vote
0
answers
38
views
Python Regime Labeling Using Explicit Threshold for Increase/Decrease from peak to trough
I am trying to find the longest stretches of time in a time series where the value from start to end increases by at least a certain threshold without any declines in the interim by at least that ...
1
vote
0
answers
52
views
How to represent dividend schedule to ML Model for barrier Options
I am looking at creating an ML model to price an exotic equity option which has a barrier where the buyer is paid out if the barrier is crossed, and multiple observation dates where the price is ...
1
vote
1
answer
76
views
Calculate Sharpe Ratio, Annualized Return, and Volatility for Uneven Cashflows and Mixed Asset Classes?
I am working on a portfolio problem and encountered some challenges related to calculating key performance metrics. I would greatly appreciate any guidance on the following:
Say, I started with an ...
4
votes
4
answers
257
views
Backtesting in python continue build or buy available software
I started building a backtesting application in Python to backtest and optimize trading strategies, but I've paused to assess whether to continue development or purchase software to speed up further ...
0
votes
1
answer
62
views
How to compute standardized residuals in GARCH-MIDAS model?
I'm trying to compute the standardized residuals in GARCH-MIDAS model but I think that the calculation is not similar to GARCH standard models in R. As reference I have only Engle's (2012) paper in ...
1
vote
1
answer
168
views
Bond portfolio optimization with Python reaching iteration limit
I am using scipy to optimize a hypothetical bond portfolio for maximum yield by choosing from a list of bonds in the portfolio's investable universe while adhering to portfolio constraints such as ...
0
votes
0
answers
53
views
Finite Difference Grid for Asian option + python
I am trying to write python code to price an Asian option (call payoff at maturity = avg(S(T)) - E, i.e. average of the asset price - strike) with FDM and grid. I have the following code, but the ...
0
votes
0
answers
31
views
How to add inflows and outflows to Monte Carlo Model in Python
I am trying to simulate my portfolio's total value over time. Here is my current code:
'''
...
-1
votes
1
answer
121
views
How to calculate daily returns and volatility from intraday price? [closed]
Imagine I have 30-minute price data like this:
...
0
votes
1
answer
153
views
QuantLib DividendVanillaOption deprecation replacement/alternative
Prior to QuantLib 1.35 you could create the option obj via:
...
0
votes
0
answers
34
views
Empirical factors vs PCA factors representation
I have performed a Principal Component Analysis on Matlab on a time series of US Treasury yields from 1990 to the present, which determines a $n \times m$ matrix $Y$, where $n = 8577$ are the ...
0
votes
0
answers
46
views
PCA on yield curve - Matlab
Consider that I have a dataset of 8964 daily observation of US yields from 1990 to May 2024. These yields are related to each maturity from 3 months, every 3 months, to 30 years, for a total of 120 ...
0
votes
0
answers
54
views
How to estimate the time-varying tail-dependence functions of Liu, Ji, and Fan's 2016 Paper?
Paper Title: A new time-varying optimal copula model identifying the dependence across markets
Paper's Authors: BING-YUE LIU, QIANG JI, and YING FAN
Primary Concern: Tail-dependence Functions were ...
0
votes
1
answer
117
views
In rateslib curve construction, how to control the jump size in step daily forward (log_linear), when i have 2 nodes on 1 instrument?
I have recently been trying to build a SOFR curve using SOFR 3 month futures. The issue I am facing is that when constructing a SOFR curve in the short-end, market convention is to use step forward in ...
0
votes
0
answers
67
views
Geometric Brownian motion simulations computed in different ways
I have come across three different equations that, as far as I know, will yield the same Geometric Brownian Motion process given that we use the same random variables in each case; however, when I try ...
1
vote
0
answers
92
views
python package for SABR calibration and greeks
pysabr seems to only fit and does not provide greeks.
Curious if anyone used a decent python package that fits SABR model and produces greeks (delta/gamma/vega/theta/volga/vanna). Thanks.
0
votes
2
answers
142
views
0
votes
0
answers
35
views
Plotting theoretical efficient frontier over sample of risk/return data
I have a data set of a few thousand mutual funds that I wish to plot the annualized risk and three-year returns of and color code each dot by its sharpe ratio. Some degree of inefficiency is expected, ...
0
votes
1
answer
78
views
Algorithm for Identifying NDF FX Trades as Buy or Sell
Do you know if there is an algorithm for identifying NDF FX trades as buy or sell? I am working on a project with data from the DTCC dashboard.
1
vote
1
answer
102
views
Coupon schedule issue with initial coupon date
I am trying to match the accrued interest, clean price, dirty price, and duration from the iBoxx underlying data. I've come close to perfectly matching their measurements but have run into an edge ...
0
votes
0
answers
44
views
Quantlib Heston MC Discrepancy between methods
I am a newbie at Quantlib (not finance) and am trying to price with the Heston model. I have implemented two different ways to verify the correctness of the Heston path generation to use in a custom ...
2
votes
1
answer
206
views
0
votes
0
answers
71
views
Calculate Hurst exponent for log stock time series
I try to calculate the Hurst exponent for the main stock time series. When I applied classical R/S analysis (Matlab code developed by Weron) I received the same value of Theoretical Hurst exponent for ...
0
votes
0
answers
114
views
Quantlib Python Yield Curve Construction Inconsistent
Why is it that my first method of looping through dates and creating curves on each date, fails on a specific day, but when creating a curve using only that dates data it does not?
I created a repo ...
0
votes
1
answer
98
views
Continuation of GARCH(1,1) without data
Please be easy on me since quant finance is not my strength.
I have the following Python code that models volatility under GARCH(1,1) for the S&P500:
...
0
votes
0
answers
55
views
Seeking Best Methods to Identify and Analyze Sharp Trends in Stocks and Currencies Using Python
I have basic proficiency in Python development and I'm interested in analyzing the relationship between certain parameters and sharp changes in stock and currency trends. What are the best methods for ...
0
votes
1
answer
79
views
Allocation of time to maturity day difference into standard tenor buckets in python
I was wondering if there is a quick way, e.g. via quantlib or any other python package/module, to allocate or to correspond time to maturity day differences to standard tenor buckets. In other words, ...
0
votes
0
answers
43
views
Algorithm to open a delta neutral position
I'm not sure how to articulate this problem exactly but what I am looking for as an answer is what approaches could be used to open a delta neutral position for the similar assets across exchanges ...
3
votes
0
answers
71
views
How do i change face value of a Zero Coupon Bond in Python rateslib?
I'm currently trying to calculate the effective annual YTM of a Zero Coupon Bond with the following data:
Issue date: 2024/07/01
Maturity date: 2024/09/30
Settlement date (also date of valuation): ...
1
vote
0
answers
72
views
How can calculate the American put option's vega,rho? [closed]
The QuantLib's version in my os:
import QuantLib as ql
ql.__version__
'1.34'
All the arguments related to the put option:
...
16
votes
5
answers
4k
views
What makes Python better suited to quant finance than Matlab / Octave, Julia, R and others?
Some background, I am not a developer at all and until now all my scripts are in Octave (open source version of Matlab). However it seems that Python is the way to go.
As I am not a developer, and I ...
2
votes
0
answers
81
views
Calculating value of vanilla swap after effective date
I'm trying to find the value of a fixed to float interest rate swap using Rateslib library but I'm running into a few issues.
I've followed the code exactly as the link here but now I'm trying to ...
1
vote
0
answers
35
views
Issues running Fama French regression for annual portfolios
As part of my master thesis I am planning to do some analysis based on the 3-Factor Fama french model. I am not a quantitative finance person at all, so my question might be extremely basic and I ...
0
votes
0
answers
37
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 ...
0
votes
0
answers
36
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
0
answers
122
views
How to retrieve Yahoo Finance tickers for stocks, given the companies' name [closed]
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 ...
4
votes
1
answer
394
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.
...
0
votes
4
answers
288
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 ...
0
votes
0
answers
49
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 ...
0
votes
0
answers
48
views
1
vote
0
answers
82
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 ...