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.

Filter by
Sorted by
Tagged with
1
vote
1answer
235 views

Modelling interest rate

Hi I want to model two stochastic integrals in Matlab, which is given by $ x(t) = x(s) e^{-a(t-s)} + \sigma \int_s^t e^{-a(t-u)} dW_1(u)$ $y(t) = y(s) e^{-b(t-s)} + \eta \int_s^t e^{-b(t-u)} dW_2(...
1
vote
0answers
31 views

Finding the distribution and moments of returns with GARCH models (in R if possible)

I understand the GARCH type models and I know how to fit a model to a time series. But, there is a paper which calculates the moments of the distribution of returns (Variance, Skewness, and Kurtosis) ...
2
votes
1answer
6k views

Did Google Finance API Go Away or Just Change Signature? [closed]

I have been using Google finance for many months to pull intraday and daily data. Today I tried to use it and got redirected. For example, the following URIs returned text data that could be parsed: ...
15
votes
4answers
11k views

Trading C++ Libraries

Are there any free c++ libraries that would have some of the functions that would be used in developing a trading strategy. For instance, calculating drawdown, Volatility Forecasting, MAE, MFE....etc. ...
8
votes
3answers
1k views

Using QuickFIX in a C project

QuickFIX is a well-known open-source implementation of the FIX protocol. This library has been ported to numerous languages, though for the moment I am concentrating the on C/C++ implementation. ...
5
votes
1answer
235 views

OpenGamma's Strata - Computational Overhead

I've been looking at the open-source library Strata (maintained by OpenGamma), which is written in Java. Now, upon inspection of the FX Forward Pricer and Payment Pricer I noticed two things: All ...
1
vote
1answer
219 views

Interpretation of PCA for commodity futures

I've done some PCA analysis of a portfolio consisting of futures on certain commodities. However, I am unsure of how to interpret the output as most of the information found online deals with fixed ...
2
votes
3answers
2k views

Portfolio Optimization - Zero beta portfolio

I am trying to solve a optimization portfolio in R in which I do the following constraints: Set weight sum to within a boundary Set return to a certain value Set portfolio beta to 0 The purpose is ...
2
votes
1answer
35 views

Deriving the long-horizon predictive regression and hypothesis testing

I am working on the long-horizon regression, $$y_{t,K}=\mu+\beta_1x_{1,t-1}+...+\beta_nx_{n,t-1}+e_{t} $$, where $$y_{t,K}=y_{t}+y_{t+1}+...+y_{t+K-1}$$ and there can be multiple x's. So I am ...
0
votes
3answers
8k views

Symbols for DAX from Alpha Vantage

I found the website https://www.alphavantage.co as an alternative for yahoo finance stock API. I am interested in the top 30 DAX symbols, but I seem to cannot find them on Alpha Vantage. Is there a ...
4
votes
0answers
167 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 ...
3
votes
0answers
169 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 ...
2
votes
1answer
133 views

How to use Kelly Criterion to place an order in financial market

I tried to write a real-time trading system, however do not know how to fit a Kelly model into the system. The system will automatically calculate everyday 12AM while I want to add another function ...
1
vote
1answer
714 views

Automatically get iShares ETF holdings

I heard that ETF's must publicly report their holdings all the time. I have seen that for example on the iShares website I can download the list of holdings as a csv file: https://www.ishares.com/us/...
1
vote
2answers
309 views

R: optimize timeseries to minimize “integral”

What I am looking to do is: for a given time-series $P_t$ (which will be constructed from different timeseries itself): $P_t$ = $\beta_1$$I_t^1$+$\beta_2$$I_t^2$+$\beta_3$$I_t^3$ $\qquad$ ($I_t^i$ ...
3
votes
1answer
772 views

Please advice free Java library for classical time series forecasting

I've got an ARIMA model (with a GARCH model for variance estimation) and parameters estimated in Matlab for my set of data. Now I need to use this model in my Java based application for making ...
2
votes
1answer
200 views

SABR PDE spot/forward upper boundary condition implementation

When running my Finite Difference code, I observe something odd. Although implementing a classical (non-reverting) SABR model, I initialized the variables such that it should be equal to Black-...
4
votes
1answer
243 views

Finite Difference method in Matlab for SABR volatility model fails to provide correct option values

Currently, I'm trying to implement a Finite Difference (FD) method in Matlab for my thesis (Quantitative Finance). I implemented the FD method for Black-Scholes already and got correct results. ...
1
vote
0answers
35 views

List of long-Term Support & Resistance in forex or stocks [duplicate]

I'm looking for a study of historic long-Term Support & Resistance in forex or stocks. If possible with their level of strength (strong, medium...). Example ...
1
vote
1answer
112 views

GBM in R giving negative numbers?

I was under the impression that simulations involving geometric brownian motion are not supposed to yield negative numbers. However, I was trying the following Monte Carlo simulation in R for a GBM, ...
1
vote
1answer
207 views

Collect all stock returns in one single matrix using quantmod in R

My problem is similar to the one in this question: how do I loop through all the stocks with quantmod and ttr? To estimate the covariance matrix of stock returns, I need a $NxT$ matrix $X$ of returns ...
2
votes
0answers
188 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
1answer
133 views

Unable to obtain correct Finite Difference Results

A rather general question regarding a specific problem I am facing with my Matlab implementation of the implicit FD method for this PDE: \begin{equation} \frac{\sigma_s^2}{2}\frac{\partial^2 V}{\...
1
vote
0answers
25 views

Trading Platform APIs which support editing holdings

I am developing a tool to assist human traders using a trading platform. For testing, I was wondering if anyone was aware of any trading platforms which support editing the holdings of a paper account....
3
votes
2answers
596 views

Test .mql4 (meta trader 4 editor) when the fx market offline

I am coding some simple .mql4 program, you know, the fx market is offline on weekend, and the market will be not shown in Meta trader 4 platform. I wanna test my program in meta trader 4 on weekend. ...
1
vote
0answers
36 views

Custom Frequency termstrc Package

Termstrc package in R by default uses yearly coupon frequencies. Dataset i am working with is semi-yearly coupon bonds. Here are the variables it takes into the model ...
11
votes
2answers
747 views

Imposing Restrictions on Cointegrating Vectors, R example

The code given below estimates a VEC model with 4 cointegrating vectors. It is a reproducible code, so just copy and paste into your R console (or script editor). ...
0
votes
1answer
627 views

EGARCH fitting in R

I am using the fGarch package in R to analyze stock volatility. To do this I am using the garchFit formula on my time series. ...
2
votes
1answer
215 views

Portfolio Optmization With Risk Aversion Parameter R

I have this problem in R. $$\max w^Tu- y w^T A w$$ where A is covariance variance matrix, y risk aversion parameter. Is it rigth if I use the function solve.QP multiplying the covariance matrix for ...
2
votes
1answer
214 views

Why there is a Deviation on my RSI indicator in comparison from one of the other Trading Markets

Hello all, and sorry for this stupid question. I am using my custom RSI indicator to which I created programmatically. I follow the equation type from here. My problem is when I compare it with the ...
1
vote
0answers
49 views

Trouble calculating the Dow Jones Industrial Average

I can successfully calculate the Dow Jones closing price by taking the sum of closing prices of the 30 component companies. However, using this same method, I'm unable to calculate the correct opening ...
2
votes
1answer
296 views

Backtest with rolling volatility in R

So I'm very new in R. I want to backtest a strategy for 3 stocks SPY, EEM, AGG. With library(RiskPortfolios), I can calculate ...
0
votes
1answer
273 views

PortfolioAnalytics: What is the training_period and rolling_window “type” in optimize.portfolio.rebalancing?

In R-package PortfolioAnalytics, what is the unit of the training_period and rolling_window ? is it the just data points ? or is ...
3
votes
2answers
1k views

SVCJ (SVJJ) Duffie et. al Model implementation in Matlab

I'm attempting to implement aforementioned SVCJ model by Duffie et al in MATLAB. so far without success. It's supposed to price vanilla (european) calls . parameters provided, the expected price is: ~...
1
vote
0answers
81 views

How to debug Example_1 of the Open Risk Engine (ORE) library?

Following the manual, I have built an Open Risk Engine library and I would like to learn the library by modifying examples that come together with the library. Question: How to run, for instance, <...
2
votes
3answers
3k views

How to get list of all symbols in fred database?

I am trying to query every single series in the fred database using r. I have checked out both the quantmod and fImport packages, and they work fine, though it seems that quantmod fits my use a bit ...
2
votes
1answer
535 views

Volatility Forecasting of VIX

Background: As we know, volatility in the long run is mean reverting. Given that volatility is mean reverting, when volatility is low, it tends to go up. When it is high and going down, it tends to ...
0
votes
1answer
406 views

talib.ATR or other ATR calculation

I have my data stored in df1 with the columns: Date Time Open High Low Close Vol OI I want to calculate the 20 period ATR from ...
2
votes
0answers
289 views

Initial values for Heston Model calibration

I'm doing a Heston model in Matlab using simple Monte Carlo simulations (5.000 paths and 2 steps per day, simulating 360 days). When I try to calibrate the Heston parameters using fminsearch it takes ...
0
votes
1answer
57 views

How to simulate a path through its solution and conditional expectation / variance

Hi I want to simulate in Matlab the following stochastic integral: $ x(t) = x(s) e^{-a(t-s)} + \sigma \int_s^t e^{-a(t-u)} dW_1(u)$ with $E[x(t) \vert F_s] = x(s) e^{-a(t-s)}$ $Var[x(t) \vert ...
0
votes
1answer
91 views

R script for Leasts Square Monte Carlo. How to explain vol and mean?

I am trying to do a Least Squares Monte Carlo in R. I don't know if it is the right place to post this, but I am out of options. I don't understand the following ...
0
votes
1answer
546 views

Javascript calculating IRR using Newton method

I leveraged the github code (https://gist.github.com/ghalimi/4591338) to compute IRR using Newton method. When I replicated the codes step by step in excel, I'm able to find the optimized resultRate ...
15
votes
4answers
56k views

Calculating log returns using R

I am trying to calculate the log returns of a dataset in R using the usual log differencing method. However, the calculated data is simply a vector of zeroes. I can't see what I'm doing wrong. Here ...
0
votes
1answer
402 views

PortfolioAnalytics R package - Error with the function “create.EfficientFrontier”

Issue The function create.EfficientFrontier from the PortfolioAnalytics package is outputting an error message that reads: <...
1
vote
0answers
179 views

Open Source library for calculating exposures?

I would like to know an open source quantitative library/ies that can calculate exposures out of the box (I have investigated a bit on OpenGamma/Strata libraries with no luck and the website of ...
1
vote
2answers
110 views

Cause of difference in theoretical vs observed value of a (call) option under the Black-Scholes model?

I am currently considering the price $C_0$ of a call option on a stock $S$ with $$ S_0 = 1 \\ K = 1.1 \\ r = 1\% \\ T = 1 $$ Based on the Black-Scholes formula, I have deduced that $C_0 = 0.356$. ...
7
votes
1answer
3k views

Rest API to retrieve ISIN

What is best API to lookup ISINs by number or name? In other words, ideally I would like to have an rest-api like this: ...
1
vote
1answer
96 views

Estimate intraday trading and $ volume

UPDATE With Questrade, I can get the usual data from their API, i.e. symbol, bidPrice, bidSize, askPrice, askSize, lastTradeTrHrs, lastTradePrice, lastTradeSize, lastTradeTick, volume, openPrice, ...
5
votes
1answer
821 views

Portfolio Optimization using Parametric Portfolio Policy Method in MATLAB

I want to contruct an optimized stock portfolio with the restriction of a zero-investment strategy. The portfolio weight in each stock needs to be modeled as a function of state variables (factors ...
2
votes
0answers
51 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 ...