We’re rewarding the question askers & reputations are being recalculated! Read more.

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.

283 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
0answers
7k views

How to use statsmodels' Granger causality test to measure the lag between two time series?

I am using the Granger causality test to measure the lag between pairs of time series where it is already apparent that one is following the other. So I am not expecting this test to tell me whether ...
10
votes
0answers
491 views

Computing Value at Risk for portfolio in R

I know how to compute VaR with long positions using PerformanceAnalytics. What about a portfolio consisting in two equities A and B, 100 USD long positions in each, and 2 stock options for the same ...
9
votes
1answer
405 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 ...
9
votes
0answers
769 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 ...
8
votes
0answers
179 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 ...
7
votes
0answers
139 views

Does your Parkinson volatility ratio work as Taleb explained?

According to Dynamic Hedging: Managing Vanilla and Exotic Options (Taleb, 1997), the Parkison volatility estimator has several meaningful properties. It is defined $$P=\sqrt{\frac{1}{n}\sum_{i=1}^{n}\...
7
votes
0answers
769 views

Python Backtesting Framework Similar to Quantstrat

I use Quantstrat heavily for strategy research and optimisation. I have two Python developers about to join my team and would like to use it as an opportunity to diversify our research tools so we are ...
5
votes
0answers
187 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 ...
5
votes
0answers
471 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 ...
5
votes
0answers
332 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 ...
4
votes
0answers
55 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 ...
4
votes
1answer
491 views

Optimal Portfolio from Efficient Frontier

I found this code on plotly site, using CVXOPT to find the efficient frontier, and then, the optimal Portfolio. The optimal function is ...
4
votes
0answers
488 views

Understanding and simulating the jumps in Merton's Jump-Diffusion SDE?

I found this great post deriving the solution to the Merton Jump-Diffusion SDE $$S_t = S_0\exp\left(\left(\mu - \frac{\sigma^2}{2}\right)t + \sigma W_t\right)\prod_{j=0}^{N_t}V_j$$ The first part of ...
4
votes
0answers
119 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 ...
4
votes
0answers
464 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 ...
4
votes
0answers
2k 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: ...
4
votes
0answers
154 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 ...
4
votes
1answer
923 views

How to backtest strategy in portfolio of stocks using SIT R?

I am creating and testing strategies in R code and using systemic investor toolbox(SIT) package as the backtesting tool. I copied a SIT backtesting code from a website and made small changes to make ...
4
votes
0answers
246 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 ...
4
votes
0answers
2k 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 ...
4
votes
0answers
251 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=...
4
votes
0answers
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 (...
4
votes
0answers
419 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" ...
4
votes
0answers
261 views

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

Please, consider the following functions from RQuantLib package: FixedRateBond() ...
4
votes
1answer
1k 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. ...
4
votes
1answer
774 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 ...
3
votes
0answers
54 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 ...
3
votes
0answers
167 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-...
3
votes
0answers
96 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 ...
3
votes
0answers
127 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. ...
3
votes
0answers
185 views

Simulation of a DCC-GARCH

I want to simulate some exchange rates with a DCC GARCH. I know the package rmgarch but I want to code the simulation my self. The following are the main equations ...
3
votes
2answers
173 views

How to interpret and define statistics of GBM output

I am trying to model the future prices of a number of commodities. For this, I am applying geometric Brownian motion, writing a Monte Carlo code in Python. Given that I want to estimate tommorows ...
3
votes
1answer
284 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 ...
3
votes
1answer
582 views

Trader Workstation on Ubuntu cannot be connected to via the API

I am using ibPy to connect to TWS on a fairly fresh ubuntu machine. I have been successful in logging into the paper trading account and submitting buy and sell orders programatically via the ibPy ...
3
votes
0answers
5k views

Historical volatility on bloomberg API

Is there a way to obtain the historical volatility of a stock from the bloomberg API? I would be looking for the data in the HVT table. Actually 3-months historical volatility from now would be enough....
3
votes
0answers
602 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, ...
3
votes
0answers
128 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^{...
3
votes
0answers
164 views

Ledoit-Wolf portfolio weights calculation

I am trying to implement the Ledoit-Wolf minimum variance portfolio strategy on a real-world stock dataset. ...
3
votes
0answers
684 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, ...
3
votes
0answers
583 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 ...
3
votes
0answers
92 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-...
3
votes
0answers
314 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 ...
3
votes
0answers
355 views

Which are the popular free/open-source charting controls?

Recently i've tried SciChart and VisiBlox - beautiful charting tools. Is there any free or open-source tools for visualizing charts on C#? Thank you for answers.
3
votes
0answers
194 views

rugarch and rolling estimation

I use Rugarch for a long time in order to calibrate GARCH models on FX rates time series and perform simulations. I am trying to understand the ugarchroll method. However even if I can find plenty of ...
3
votes
0answers
3k views

Black Scholes diffusion well coded in Python

I have some trouble with the following code. Some jump and a decentered path are present but it's not the case, normally for Black Scholes diffusion! Is anyone see a problem in my code ? ...
3
votes
0answers
416 views

What R-packages for SOCP problems are there?

Currently, I am looking deeper into the topic of second-order cone programming. Could you suggest packages that solve SOCP-problems in R? With your answer, please provide a short description of ...
3
votes
0answers
1k views

Philips-Ouliaris test for cointegration

I'm trying to implement cointegration tests using the R urca package. I've figured out the Johansen test (ca.jo), but I'm having trouble with the Philips-Ouliaris test (ca.po). I have two questions: ...
3
votes
0answers
228 views

What does negative gamma mean in APGARCH model?

I got a gamma of -0.1321677. ...