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.

15
votes
4answers
9k views

R code for Ornstein-Uhlenbeck process

Can any one help me with some R code to run Ornstein-Uhlenbeck process?
4
votes
0answers
400 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 ...
1
vote
1answer
103 views

Are CUSIP case sensitive

Are CUSIP identifiers case sensitive like RIC number are?
0
votes
1answer
133 views

Are ISIN case sensitive?

Are ISIN codes case sensitive like RIC Codes are? We need to know this in order to sanitize input. This completely describes my problem!
2
votes
1answer
142 views

Simple Compounding vs Continuous Compounding in return series

I'm creating a log price series in MATLAB. This is fairly easy to do using standard functions. Given a price series prices: ...
1
vote
2answers
609 views

When people say that C++ is overly complicated, does that also hold for its application in Quant finance? [closed]

Programmers often criticize C++, calling it an overly complicated and dying language. I don't care if this is true or not. My question is, considering the argument that supports this claim, does that ...
1
vote
1answer
374 views

How to add controls (regressors) to GARCH model in R?

How can I estimate a GARCH(1,1) model with control variables like this: $$Y_t=a_0+a_1X_t+e_t$$ where$$ e_t\sim N(0,h_t)$$ $$h_t=b_0+b_1e_{t-1}^2+b_3h_{t-1}+b_3Z_t$$ I've checked some packages but can'...
1
vote
1answer
123 views

Interact with FX Connect

I have little to no programming background so please bear with me. I work for a firm that executes our FX trades via FX Connect. I would like to program some logic into FX Connect so that trades that ...
4
votes
1answer
206 views

R Calculate future price range and plot the result

First I want to say that I've read this post (How to calculate future distribution of price using volatility?) but it doesn't help much. Here is what I'm trying to do (values are not real) Let's ...
2
votes
0answers
287 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
1answer
328 views

Sharpe Ratio of ETFs in R

Suppose I want to calculate the Sharpe ratio given a risk free rate of 0.05 for a portfolio consisting of assets from 500 ETFs. How can I do so in R given the data I've collected thus far in my R code?...
0
votes
1answer
431 views

How to construct stock portfolios in R

I need some help, since I can't find any good sources. I need the portfolios for my thesis. I have 20 years of monthly stock returns for ~200 stocks. I want to create each month 5 equally weighted ...
2
votes
1answer
269 views

R Mean Reversion Estimate on Funds

I am new to mean reversion, and I'd like to run an analysis on a fund (ts with monthly returns only) to see if mean reversion applies and if so, when it will happen. Most of the examples I found ...
1
vote
1answer
367 views

Getting monthly return using quantmod, if input ticker is a variable

I am new to package quantmod and quandl. I encountered a problem while I was trying to fetch period return data. Below is my ...
0
votes
1answer
75 views

Histogram on R Studio [closed]

I am new to R and I am trying to plot a histogram from one of the columns in my csv file. The table is already being read perfectly as I can check on R Studios date view. I also can plot histograms of ...
2
votes
1answer
385 views

Types of programming languages used for optimization in finance

I'm currently taking graduate finance courses, and wish to pursue a career in finance - in particular $\textbf{optimization in finance}$. To date, I've only been taught the GAMS programming language (...
1
vote
2answers
1k views

R RSI Calculation (TTR package)

I'm using the default RSI calculation in the TTR package as follows: result = RSI(data,14). The function also allows the user to specify the averaging method: result = RSI(data,14,"SMA"), result =...
5
votes
2answers
12k views

how do I loop through all the stocks with quantmod and ttr?

I just started with quantmod package. If I want to select stocks based on their recent performance, then I need to loop through all the stocks in, say, NYSE. So I need: get all the stock symbols ...
3
votes
4answers
5k views

Does Yahoo/Google no longer support web-scraping of FOREX data?

I use Python 3.6 to develop quantitative FOREX trading strategies. I used to use Yahoo or Google in conjunction with pandas.datareader in order to collect forex ...
8
votes
2answers
274 views

Refer some most recent books of derivatives pricing by C++

Could you refer some most recent books of derivatives pricing by C++ including Tree method, Finite difference method, Monte Carlo etc. Once I read a series of <...
1
vote
0answers
88 views

Should I interpolate before or after to find option price using Vanna-Volga method?

I am trying to calculate the implied option premium $C(K)$ and $\Delta$ using the procedure outlined by Castagna and Mercurio in this paper - http://www.fabiomercurio.it/consistentfxsmile.pdf My ...
1
vote
0answers
121 views

ARMA-GARCH Forecasting [closed]

I want to forecast a differenced time series of an Index using the combined ARMA-GARCH model (because I want to forecast the mean and not the variance). My model is a ARMA(2,2)-GARCH(1,1) model. So ...
4
votes
3answers
923 views

Loading HF stock data into excel

Are there any free, open source VBA addins or R packages that can be linked using the yahoo finance/Google finance/other data sources api to continuously download intraday data into excel or R? https:...
6
votes
1answer
3k views

What is the best solution to use QuantLib within Excel?

Excel is likely the most widespread instrument across all not-only-quants desks; in addition, we have to keep in mind that Bloomberg and Reuters allow to easily import real time data in Excel, and ...
0
votes
1answer
208 views

Calculate Annualized Return / Annualized Sharpe From Portfolio

If I have a portfolio of stocks that I invest in and out of at different holding periods and different times of the year. How would one calculate the annualized returns and annualized sharpe ratio of ...
4
votes
2answers
5k views

What is the best alternative of Quantlib library

We need to build a Fixed Income Portfolio Risk Analytics solution. Somehow due to administrative reason we can't use Quantlib which is written in C++, even call it through SWIG via JNI. We have tried ...
0
votes
1answer
108 views

Probability integral transforms of risk-neutral densities

I've backed out a time series of risk-neutral densities of GBP/USD options using a non-parametric approach in Matlab and would like to assess their forecast ability by applying the unconditional test ...
1
vote
1answer
614 views

VaR : Student-t GARCH

I have a question on the VaR estimation via the student t GARCH model. Under this framework, the one day ahead VaR estimate is calculated by the following formula: $$VaR_{p}=\mu_{t+1}+\sigma_{t+1}\...
1
vote
0answers
72 views

Long Term investment in leveraged ETFs not necessarily bad?

I have conducted very much research about leveraged ETFs lately. Most sources specifically say that these instruments are not meant for long-term investments and that they are very risky due to the ...
2
votes
1answer
174 views

Projecting a Thiele differential equation with Black Scholes returns

I am trying to solve the equation $\frac{d}{dt}V(t)=r(t)V(t)+\pi-\mu(x+t)(b_d-V(t))$ numerically using the R function 'ode'. This is a Thiele differential equation for a life insurance reserve with ...
-1
votes
1answer
433 views

quantstrat for backtesting vs. writing one's own code in R

I have invested a few years in learning R and have developed a number of Monte Carlo backtesting scripts. My question is this: In general, for a person with some experience writing R code who is ...
3
votes
2answers
7k views

Downloading S&P historical data from Google

Since Yahoo has decided to yank their API for the foreseeable future, I'm attempting to switch to Google finance. I'm having trouble downloading a .csv file for GSPC (S&P 500), despite there ...
0
votes
1answer
85 views

Making an IB contract: Directory for IBpY exchanges and commodity codes?

All the tutorials for making a contract seem to use either Apple or Google as examples: goog_contract = create_contract('GOOG', 'STK', 'SMART', 'SMART', 'USD') If I want to trade CME Feeder Cattle ...
8
votes
2answers
18k views

GARCH(1,1) good fit found, how to predict one day volatility ahead?

I used SPY data to fit GARCH(1,1) in my model. My data starts from Jan, 2000 until Dec, 2013. I compared the volatility using runSD on the 21 rolling window and GARCH(1,1). It looks a pretty good fit ...
1
vote
1answer
432 views

Starting values for constrOptim() in R

I want to perform a constraint optimization for Maximum Likelihood Estimation in R to forecast volatility of returns. The probleme is that my initial values aren't in the permitted region. Is there ...
5
votes
2answers
4k views

GJR-GARCH Model In R

Any idea how to estimate GJR-GARCH models in R? Is there any particular library like fGarch that supports such models?
3
votes
4answers
318 views

Mark Joshi Quantitative finance numerical techiniques, writting an algorithm that produces a random variable

Background: I am preparing for interviews and I was told to try and answer as many problems in the Mark Joshi book as possible. Question: Suppose an asset takes values from a discrete set $v_j$ ...
1
vote
0answers
363 views

Estimating parameters of the Cox-Ingersoll-Ross model using CLS in R

I'm working on a project where I need to estimate the parameters of the CIR model. In the particular case, the CIR model is used to model cumulated capital calls for a private equity fund. The data ...
3
votes
6answers
14k views

Which library shall I use for time series analysis in Java?

I'm looking for a library to do some time series analysis in Java but I can't find anything suitable. I've found plenty of libraries such as Math3 of JSAT but there's much I can you for my problem. ...
1
vote
0answers
302 views

How to calculate mean reversion values for Hull White tree calibration on MATLAB?

As part of a time series analysis, I'm writing a MATLAB program to create a Hull White tree, for the purpose of pricing a coupon-bearing bond. While using the function hwvolspec (volatility ...
1
vote
1answer
32 views

Calculating the ideal initial capital value to optimize a growth model

I'm trying to work out a method for finding the initial capital value that allows someone to run out of money at the exact time they reach mortality. Currently, I'm graphing the annual total capital ...
3
votes
4answers
256 views

Obtaining intra-day values of the EUR-USD exchange

I need for my project the values of the EUR-USD exchange (both intra-day and ticker). I've been playing around with the Yahoo's YQL API and at this moment I can obtain the current value of the ...
24
votes
3answers
3k views

Tools in R for estimating time-varying copulas?

Are there libraries in R for estimating time-varying joint distributions via copulas? Hedibert Lopes has an excellent paper on the topic here. I know there is an existing packaged called copula but ...
1
vote
2answers
484 views

Choosing broker to run with Zipline

Which brokers offer Python integration/API? Which brokers offer R integration? I'm starting on trading, and I want to learn about algorithm trading. So I would like to know what brokers offers these ...
0
votes
2answers
220 views

Portfolio optimisation - Non brute force solutions to optimisation problems

Recently I wrote a program in Python which extracts stock data for a designated period and frequency of the predetermined stocks and then optimises the portfolio using the Sharpe ratio. In order to ...
1
vote
1answer
99 views

How to find coefficient that will minimize the distance between few times series

I have 3 time series X1, X2, X3. I want to find the coefficient (c1, c2) that will minimize the distance between them as follow: $$MIN\sum\sqrt{(X1-(c1*X2+c2*X3))^2}$$ The constrains are: $$-1< ...
1
vote
1answer
216 views

Generating random yields

I would like to test different methods for fitting a yield curve, like the Nelson-Siegel, cubic splines etc. I would like to generate random yield to maturity data, that somehow reflects the common ...
3
votes
1answer
192 views

Why is this utility function not picking up its penalty?

I was reading this seminal paper by Infanger. On page 40, Figure 11. was quite interesting. In particular I was interested in the top one, 19 Years and I wanted to reproduce this plot. To give some ...