Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

10
votes
0answers
451 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
0answers
755 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
166 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
102 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}\...
5
votes
0answers
328 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
145 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 ...
4
votes
0answers
113 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
389 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 ...
4
votes
0answers
383 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
150 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
0answers
240 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
249 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
2k 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
258 views

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

Please, consider the following functions from RQuantLib package: FixedRateBond() ...
3
votes
0answers
90 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
72 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
149 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
0answers
4k 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
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
159 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
657 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
89 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
295 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
343 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
181 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
407 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
224 views

What does negative gamma mean in APGARCH model?

I got a gamma of -0.1321677. ...
3
votes
0answers
2k views

Backtest pair trade strategy in R

I am looking for some tips on how to run a simple backtest on a pairtrading strategy intraday using eg. 30minute bars. I have calculated the spread, ...
3
votes
0answers
382 views

How to balance two Forex crosses correctly to do a linear regression?

I have two cross and an account in EUR: EUR/USD GBP/USD I would like to do a balanced linear regression using R. With "balanced" I mean that I would like to normalize it by calculating the ...
2
votes
0answers
17 views

Backtesting EGARCH-NIG CVaR in R

I fitted an EGARCH model with a NIG distribution to a series of returns. Using the following link I tried got how I should calculate the CVaR of the model http://r.789695.n4.nabble.com/CVaR-with-NIG-...
2
votes
0answers
31 views

Mixed-Frequency VAR -packages

My intention is to retrieve forecast error variance decomposition from a MF-VAR with no latent processes following Ghysels (2012) https://www.hec.ca/finance/seminaires/Ghysels.pdf I found the ...
2
votes
0answers
59 views

Backtesting :: Migration to Simulated / Real-Time Trading

I am relatively new to backtesting and I want to migrate my system to simulated trading via Amibrokers Interactive Broker's API. What I have been doing is setting trade delays such that when a Buy or ...
2
votes
0answers
41 views

IBrokers: How to assign trail amount for order type 'TRAIL'?

I'm using R package IBrokers with IB TWS. I'm trying to create a twsOrder object using twsOrder function: twsOrder(...., orderType = 'TRAIL', ...) How can I ...
2
votes
0answers
63 views

Generating Correlated Quasi Random Numbers

Hi I am trying to generate correlated quasi random numbers using a sobol sequence in matlab. My Problem is the Following: Using "standard" random numbers it is easy to generate the 6 correlated random ...
2
votes
0answers
48 views

Dividing H in the Hurst power law function to get the Hurst exponent?

For my own learning I have been following the guide here. It is highly instructive. Implementing this in R I was able to reproduce the authors results on the data sets provided within some ...
2
votes
0answers
174 views

Quasi Monte Carlo method and Heston model

I want to run a quasi monte carlo simulation for Heston model in matlab. Obviously there exists a lot of literature regarding the theoretical aspects of the topic, for example by Baldeaux and Roberts, ...
2
votes
0answers
282 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 ...
2
votes
0answers
231 views

VARMA GARCH modelling in R

I want to simulate a VARMA-GARCH process in R. Unfortunately, I found no package to help me with that. I tried modelling the MGARCH part on itw own and combine it with the VARMA simulation using MTS ...
2
votes
0answers
57 views

Spurious regression between two futures with the same underlying highly correlated (cor=0.9)

analyzing the correlation between soybean and soybean meal futures in ECBOT, and making a linear regression in R between them I check with an ADF Test that the residuals are not stationary, so ...
2
votes
0answers
702 views

Problem with R code, with option pricing

I have a problem with my R code not producing accurate results. I am trying to implement the Carr-Madan approach to option pricing, using the Black-Scholes model. The formula can be found in equation (...
2
votes
0answers
497 views

Optimal weights for portfolio optimisation (r)

The question is what R optimization could be applicable to find a vector of weights that when, multiplied by S matrix creates equal rows sums, and when set in the objective function returns the ...
2
votes
0answers
138 views

How to reset indicators in quantstrat / quantmod?

I am currently trying to back test a strategy on a file which contains minutely data for the whole month. I would like to reset my indicators at 3:30 PM . Is there a way I can reset the indicators ...
2
votes
0answers
150 views

How to (efficiently) calculate the maximum possible return of a perfect “crystal ball” investment strategy?

I am new to the world of investing, so please excuse the clumsy wording of the question... there is probably a better term for what I am looking for or maybe this is even a known/classic problem. If ...
2
votes
0answers
270 views

Problems in computing VaR with GARCH-GPD-copula approach

I use a time-varying Gaussian copula (with GARCH-filtered standardized residuals modeled semiparametrically with Gaussian kernel interior and GPD tails, i.e. generalized pareto distributed) to ...
2
votes
0answers
63 views

False warning messages in R, is it possible?

I'm modeling GARCH-filtered standardized residuals via semiparametric distribution with Gaussian kernel and GPD (generalized pareto distribution) tails with thresholds at 5% and 95%. For some series I'...
2
votes
0answers
86 views

Monte Carlo approach to RAN bonds in Quantlib or suggestions

This is a problem from Schlogl's book in the chapter on the HJM model: Price option of the RAN instrument with 3 month coupons and maturity 3 years using Monte Carlo(Exercise 4 Range Accrual Note). ...
2
votes
0answers
73 views

Using Market Prices of Bonds to Model the Discount Curve with a Polynomial (Math + R)

I have a small program I'm building to interpolate the discount curve from a portfolio of benchmark bonds. If anyone has any guesses as to whether it's my process, or my code that's messed up I would ...
2
votes
0answers
460 views

Johansen cointegration test interpretation in R

I want to test my time series for cointegration using the Johansen test in R. I got the following result and so I know now that at least 5 out of 9 of my time series are cointegrated. My question is, ...
2
votes
0answers
131 views

Interpreting different factor models w.r.t. correlation matrix and min variance portfolio weights

Background In Eric Zivot's analysis of factor models he uses three models The sample (.sample) Single index model (.si) Barra factor industry model (.ind) PCA model (.pca) You can download his ...