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.

438 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
11 votes
0 answers
753 views

Block bootstrap to synthesize asset prices

I have a few basic questions on block bootstrapping on a financial time series ('TS'). Assuming my trade universe consists of 10 stocks, I would like to create a set of synthetic prices for all 10 ...
NoviceProg's user avatar
10 votes
0 answers
833 views

Alternative to Block Bootstrap for Multivariate Time Series

I currently use the following process for bootstrapping a multivariate time series in R: Determine block sizes - run the function b.star in the np package which produces a block size for each series ...
ProbablePattern's user avatar
9 votes
0 answers
287 views

Determining Hurst exponent of a Brownian motion

I am trying to determine the Hurst exponent of a simple Brownian motion, however, I seem to get a result that differs from 0.5. I am following the instructions given on the Wikipedia-page, and here is ...
BillyJean's user avatar
  • 191
8 votes
0 answers
3k views

Replicating Bloomberg Swap Prices with QuantLib

I'm trying to learn more about the QuantLib python package and as an exercise I'm trying to replicate some swaps on Bloomberg. However, when I do so, it seems like my swaps are consistently ...
K. Mao's user avatar
  • 181
6 votes
0 answers
271 views

Creating the local volatility surface from the IV surface

I have been using the dupire equation: $$ \sigma_{LV} (K,T) = \frac{\sigma_{i m p}^2+2 \sigma_{i m p} T\left(\frac{\partial \sigma_{i m p}}{\partial T}+(r-q) K \frac{\partial \sigma_{i m p}}{\partial ...
Xerium's user avatar
  • 45
6 votes
0 answers
900 views

(C++) Monte Carlo pricer for SABR model to test Hagan / Paulot formulas

I'm trying to test the so-called Hagan formula (p.6 of this paper) and the Paulot formula, order 1 only (eq. (43) p.19 of this paper. For this, i'm trying to use both Euler and Milstein scheme ...
loyd.f's user avatar
  • 188
6 votes
0 answers
4k views

Implied volatility from American options using python

I am currently trying to construct volatility surface from american option prices (using Cox-Ross-Rubinstein tree) in Python 2.7. Below you can find the code I came up with. Any corrections would be ...
jakub's user avatar
  • 331
5 votes
0 answers
262 views
+50

PBO algorithm "The Probability of Backtest Overfitting" paper

In this article by Lopez de Prado et al., an algorithm was proposed for assessing the overfit of a trading strategy: The Probability of Backtest Overfitting There is also a package for R: pbo: ...
mr.T's user avatar
  • 125
5 votes
2 answers
2k views

Does Fidelity Have a Python Trading API?

I'd like to do my trading through a corporate account at Fidelity, but there does not seem to be a Python api. What I'm looking for is something like this: https://github.com/jmfernandes/robin_stocks
Frederick Ollinger's user avatar
5 votes
1 answer
521 views

GARCH(1,1)-M MLE optimization with fmincon in R

I've searched thru dozens of papers and did not find in any of them satisfying and enough theoretical answers to my concerns. So I've combined everything what I found below. Please indicate if my ...
SlavicDoomer's user avatar
5 votes
1 answer
2k views

How to calculate average entry price for perpetual swap contracts?

I'm trying to calculate the average entry price for perpetual swap contracts for use in back-testing a trading strategy, as per Bitmex's documentation: A Perpetual Contract is a derivative product ...
Natalie Williams's user avatar
5 votes
0 answers
280 views

Implementing Hanson`s LMSR with Limit Orderbooks

I am trying to integrate Hanson's LMSR (see (see logarithmic market scoring rule)into an order-book with traditional bid/ask-limit orders (in KDB+/Q). The following functions define the basic LMSR ...
Thomas's user avatar
  • 101
5 votes
0 answers
4k views

Fitting GARCH(1,1) in Python for moderately large data sets

I am using the arch package in python to fit a GARCH(1,1) to fit daily S&P 500 returns from 1990 to 2017 (about 6800 data points). The code I am using is as follows: ...
user369210's user avatar
5 votes
0 answers
359 views

Algorithmic Trading Model Calculation and Stale Data

I'd like ask everyone a more concurrency programming but definitely quant-finance related question. How do you deal with staleness of data in market hours as quote ticks are streaming and your model ...
cowmoo's user avatar
  • 131
4 votes
0 answers
166 views

Plotting of trendlines with certain conditions post significant pivot point determination

I'm trying to get a point which is higher in a range of points, i.e., pivot high, then among a range of pivot high I want to find a significant pivot high. For this I am trying to create a range which ...
driver's user avatar
  • 91
4 votes
0 answers
119 views

Implementing Hierarchical PCA for financial time series in R

I would like to implement the method "Hierarchical PCA", as described in the following paper and compare it to a "standard" PCA. I like to do this in R AVELLANEDA, Marco. ...
ds_col's user avatar
  • 61
4 votes
0 answers
761 views

Bootstraping CLP Swap with Quantlib

After reviewing and fixing my last code (Swap Bootstrapping with quantlib), i managed to get the zero rates for the ICP swap curve (CLP). Now the thing is that there is a considerable difference ...
Jose Pedro Melo's user avatar
4 votes
0 answers
132 views

How to find a probability of VIX moving from one price to another

I asked a similar question on here with a bounty. I decided to modify the question to simplify what I am trying to do. Is there a package on MATLAB or some other tool where I can find the probability ...
Wolfy's user avatar
  • 728
4 votes
0 answers
758 views

How to estimate option implied skewness and kurtosis in R

Suppose that i have data that for each day i have more than one option, either put or call. I.E. I have more than 20 put options and 20 call options for each specific day. What is the way to estimate ...
Hercules Apergis's user avatar
4 votes
0 answers
192 views

VAR FPCA analysis paper replication

I've been trying to replicate the following publication: CONSISTENT FUNCTIONAL PCA FOR FINANCIAL TIME-SERIES, Sebastian Jaimungal, Eddie K. H. Ng, 2007 but I havent been able to get the same results ...
Jose Pedro Melo's user avatar
4 votes
0 answers
953 views

Black-Scholes explicit Euler implementation python

I've written some code for the explicit finite difference method to solve the BS equation. For certain sets of parameters (time-steps and asset-steps) I get a stable but wrong solution. For others, ...
user1654183's user avatar
4 votes
0 answers
266 views

How would it be possible to use Dynamic Programming to search a space of investment strategies to find an optimum?

As my question states, the problem I am having is finding a sensible way to search a large space. Any help or insight that could be provided would be hugely appreciated. Currently I am trying to ...
ahair's user avatar
  • 71
4 votes
0 answers
294 views

negative transition probabilities in the heston model

I've been trying to implement a bivariate tree for pricing american options with the heston model in R using the paper of Beliaeva and Nawalkha (http://papers.ssrn.com/sol3/papers.cfm?abstract_id=...
Season's user avatar
  • 41
4 votes
1 answer
794 views

What are some popular free/open-source charting controls?

Recently I've tried SciChart and VisiBlox - beautiful charting tools. Are there any free or open-source tools for visualizing charts in C#? Thank you for answers.
Vladimir's user avatar
  • 159
4 votes
0 answers
3k views

FIGARCH estimation in R

I am trying to estimate a FIGARCH(1,1) model in R for Value-at-Risk purposes. As I understand it, the rugarch package does not support FIGARCH or FIEGARCH. To that end, I used the garchOxFit function (...
LostInTheWoods's user avatar
4 votes
0 answers
594 views

Rate Distortion Minimization in a Python Clustering Algorithm

I'm attempting to solve for $\hat{k}$ clusters, such that the rate distortion is minimized, as described here, however, the answers that I am getting from my algorithm are not following the "Jump" ...
benjaminmgross's user avatar
4 votes
0 answers
295 views

RQuantLib: any difference between FixedRateBond() and FixedRateBondPriceByYield() with flat term structure?

Please, consider the following functions from RQuantLib package: FixedRateBond() ...
Lisa Ann's user avatar
  • 2,131
4 votes
1 answer
2k views

Moving window forecasting in Python

I am looking to create some code that will out-of-sample forecast the HAR-RV model. The model itself is formulated as the following, and the betas are estimated through HAC-OLS or Newey-West. ...
Niklas Lindeke's user avatar
4 votes
1 answer
1k views

How to estimate parameters for 2 correlated Ornstein-Uhlenbeck processes with maximum likelihood?

I would like to use maximum likelihood to estimate the parameters of two correlated Ornstein-Uhlenbeck processes from empirical data. Do you have any good references for this? If you have any hints ...
LenaH's user avatar
  • 123
3 votes
0 answers
436 views

Best practices for building an FX volatility surface with Quantlib in Python

Generally my question is: what are best practices for building FX volatility surfaces with Quantlib? In FX options, I would like to price structures such as risk reversals, strangles and butterflies. ...
Wynn's user avatar
  • 105
3 votes
0 answers
267 views

Which C++ implementations of Levenberg-Marquardt does the "industry" use?

According to your various experience, is there an industry consensus about which C++ implementation of the Levenberg-Marquardt algorithm to use ? I came across two places where it was the C numerical ...
EricFlorentNoube's user avatar
3 votes
0 answers
127 views

How to take into account transaction fee of a backtest from a list of returns?

I have a list of booleans that correspond to buy and sell signals that I would like to backtest. To achieve this, I calculated the return ret of a security and when ...
Florent's user avatar
  • 241
3 votes
0 answers
111 views

CDS Runtime Error: Issue changing evaluation date using UpfrontCdsHelper in Python

If I run the below CDS pricing example (from https://github.com/lballabio/QuantLib-SWIG/blob/master/Python/examples/cds.py) using the UpfrontCdsHelper instead of the SpreadCdsHelper, I get the ...
bkhoor's user avatar
  • 31
3 votes
1 answer
692 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:...
Mircea's user avatar
  • 151
3 votes
0 answers
129 views

Manual Computation of Python QuantLib's NPV for Pricing of a Forward Rate Agreement

Following the question that I have asked on this link and response obtained, I have managed to price a 3x6 FRA using QuantLib Python, using the following codes: ...
ql.user2511's user avatar
3 votes
0 answers
2k views

Simulating correlated Geometric Brownian Motion in Python

I want to simulate two correlated Geometric Brownian Motion processes in Python. I found an implementation from Matlab (https://www.goddardconsulting.ca/matlab-monte-carlo-assetpaths-corr.html) and ...
Willart's user avatar
  • 73
3 votes
0 answers
288 views

Is it possible to match talib's RSI results down to machine precision using just python?

I want to match talib's RSI with just python down to machine precision and I'm struggling. Out of curiosity I also tried a bunch of libraries like tulipy and pandas_ta and the gaps are similar. ...
user165494's user avatar
3 votes
0 answers
795 views

Using Python Quantlib's FittedBondDiscountCurve as Evaluator of Parametric Curve - Errors

I am using Quantlib's FittedBondDiscountCurve in Python 3.7 and setting MaxIterations to 0, and giving a guess_solution, which then turns the routine into an evaluator for the parametric form I choose,...
NBF's user avatar
  • 1,068
3 votes
0 answers
172 views

Identifying the same company behind stocks traded in different exchanges (e.g. CUSIP and WKN in 1990ies)

I would like to merge two data sources with companies headquartered in Germany between 1980-2000, but listed in Germany and the US. One source identifies "German companies" by their CUSIP, the other ...
moezelot's user avatar
3 votes
0 answers
618 views

How to calculate YTW (yield-to-worst) in QuantLib?

After defining a CallableFixedRateBond object in QuantLib, I can calculate YTM (yield-to-maturity) right now. I'm using Python so the function is bondYield(). Is there any way to calculate YTW (yield-...
Zhenduo Cao's user avatar
3 votes
0 answers
305 views

Detecting leading stocks using lag correlation

I am working on a project to find leading stocks in a stock market by using lag correlation. Say I want to compare 2 stocks, X and Y, and I have the time series of stock prices. Assume that the ...
Jessica's user avatar
  • 31
3 votes
0 answers
625 views

Is there a more efficient data structure to implement binomial trees than 2d array?

I'm just curious what is the "industry standard" for implementing a binomial tree (if "standards" exist in this case). For simplicity, let's just talk about the simplest trees with recombining nodes. ...
Vim's user avatar
  • 903
3 votes
0 answers
676 views

Modified duration and convexity of a bond in R

A soft question: Are there any existing packages in R that allows one to compute the modified duration and convexity of bonds in R? If there isn't, how can one go about doing so (with formulas) with ...
Stoner's user avatar
  • 205
3 votes
1 answer
618 views

VAR-aDCC full ARCH and GARCH parameter matrices in R

I am working with the rmgarch package in R and I estimated a VAR-aDCC model. Is there any way to extract the extended version of estimates (allowing for volatility ...
Konstantinos Gk's user avatar
3 votes
0 answers
180 views

Approximate asian geometric option with Heston

I am trying to implement Theorem 1 from this Journal in RStudio. The journal says the it is possible to find a approximate price of a geometric asian option in a Heston setup this way: $$X_{1cGAO}=e^{...
Rasmus's user avatar
  • 31
3 votes
0 answers
264 views

Ledoit-Wolf portfolio weights calculation

I am trying to implement the Ledoit-Wolf minimum variance portfolio strategy on a real-world stock dataset. ...
rty's user avatar
  • 31
3 votes
0 answers
715 views

GARCH modelling and forecasting

I have a few questions regarding GARCH modelling and forecasting and it would be great if someone could help me. I am modelling the log return of oil spot prices using various GARCH models: GARCH, ...
user3384794's user avatar
3 votes
0 answers
811 views

How can I do a dynamic GARCH model using extended Kalman filter in R?

Today I was reading an article quoted here, in this article is proposed an adaptive (dynamic) Garch model. How can I do it in R? The use of extended Kalman filter or particle filter is indifferent. I ...
Mik_79's user avatar
  • 31
3 votes
0 answers
134 views

How do I specify Thirty360::European day counter in RQuantLib

I am taking liberty to ask the following question in quantLib forum though this question is about RQuantLib I am trying to use RQuantLib to calculate clean price of a fixed coupon bond using a Nelson-...
kishore's user avatar
  • 131
3 votes
0 answers
409 views

how to apply a simple copula model

I'm playing around with copulas and wanted to generate some sample based on copula techniques in R. For this purpose I applied the following algorithm: Generate three sample vectors coming from ...
math's user avatar
  • 1,718

1
2 3 4 5
9