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.

2
votes
0answers
175 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
132 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
24 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
588 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
33 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
712 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). ...
2
votes
1answer
9k views

Duration of a floating rate note

I have the following C# code for calculating the modified duration of fixed coupon bonds: ...
0
votes
1answer
596 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
203 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
193 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
273 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
239 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
77 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
503 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
347 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
283 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
87 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
466 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
55k 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
384 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
168 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
107 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
92 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
810 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
50 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
1answer
2k views

How to build an execution trading system with CQG API?

I am currently using CQG for spread trading and have a spread trading strategy in CQG chart. I am trying to automate my spread trading strategy in CQG, but CQG told me to look at CQG API samples to ...
2
votes
1answer
358 views

Calibration of Heston version of CIR

I'd like to calibrate a variant of Heston model for interest rates which is describe by this couple of SDE \begin{aligned}dr_t&=a(b-r_t)+\sqrt{r_t}\sigma_t dW_t^1 \\ d\sigma_t&=k(\theta-\...
2
votes
1answer
249 views

Creating a portfolio in R : good practices

I am quite new to quantfin, but wanting to learn. I've searched for the answer (google and stackex), but haven't found anything satisfactory (but I might not be asking the correct questions...) The ...
12
votes
1answer
1k views

How to compute modified-CVaR in the PerformanceAnalytics package?

My objective is to measure the modified-CVAR for a portfolio given its weights and matrix of security returns. Luckily the wonderful package PerformanceAnalytics has an ES() function that does just ...
8
votes
0answers
170 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 ...
-1
votes
1answer
224 views

Calculating intraday returns from imperfect data in R [closed]

The aim is to calculate minute returns in R. Given is minute price data in a tbl_df. A row was only added if there actually were trades. ...
1
vote
1answer
1k views

Pricing a double barrier option using Monte Carlo (C++ & Python code included)

I'm trying to price an option with upper and lower barriers using MC where the payoff is $B_u$ when $S_t > B_u$, $B_l$ when $S_t < B_l$ and $S_t$ when $B_l < S_t < B_u$. I have written ...
2
votes
0answers
535 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 ...
1
vote
1answer
270 views

How to sample from a copula in matlab

I have two random variables (say, X and Y). Each of these rv's are defined by their CDFs (CDF_X and CDF_Y). These CDFs were obtained empirically, so they are a "stair" graph. I also have a copula C ...
32
votes
12answers
10k views

Is F# used in trading systems?

Similar to this other question about Scala, I'm interested in knowing whether F# is used to any measurable degree in financial circles. Have there been any successful shops using it, any research on ...
1
vote
0answers
361 views

bloomberg api: how to handle the max 1000 requests limit

I am using the Bloomberg API in R (package Rblpapi) to find the nearby price at elevator locations for Soybean/Corn in given states in the US. I use the function lookupSecurity: ...
1
vote
0answers
50 views

Seeking data source for index constituents and changes

I need to find a definitive list of US and UK index constituents. I'm currently monitoring S&P100, S&P500, DJIA, FTSE100, FTSE350 etc. and curating the list manually, which is causing problems....
3
votes
2answers
219 views

Tools/R-code to create gain/loss-asymmetry plots

The gain/loss asymmetry is a well known stylized fact: It basically states that real financial time series take longer for going up than going down. To detect it a heavy statistical machinery is ...
3
votes
1answer
194 views

Trying to replicate the Beta of Yahoo in R but am getting an answer that is way off

Yahoo calculates the Beta by using 3 years of monthly returns and using the S&P 500 as a market proxy but I cannot seem to replicate this or even get close using R. I downloaded the data from ...
1
vote
0answers
49 views

Market Profiling open source packages or tools

after reading the book Mind Over Market by Dalton I was wondering if there are any open source packages for Market Profiling (the technique developed by J. Peter Steidlmayer for representing price ...
1
vote
0answers
48 views

Force Index EMA calculation for stock indicator

I am trying to smooth a 13 period EMA Elder Force Index in c++, and nobody really describes this as anything more than : ...
8
votes
4answers
13k views

What is the difference between the Interactive Brokers demo account and a personal paper trader account?

I'm interested in testing my trading strategy using the Interactive Brokers API for Trader Workstation. A demo account is provided to play with TWS for free, but if I fund a real account I will be ...
-1
votes
2answers
196 views

Calculate day-to-day change in value of open position

From a list of trades I would like to calculate the change in profit during the time the position is open. Does anyone have a script to do this, either python or R? The profits are based on a contract ...
4
votes
0answers
115 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 ...