Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
0answers
11 views

chartSeries {quantmod}: How to change the color of bars for Volume

I'm using the following code to extract a symbol and drawing line chart for closing price and bar chart for volume. ...
0
votes
1answer
44 views

Dealing with weekends/gaps in financial data

My script takes some data from IEX and then outputs a pandas dataframe: ...
1
vote
0answers
27 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 ...
0
votes
0answers
25 views

How to fit and test VaR in R

I have estimated the below model with gjr-garch11 gjrgarch11n.spec = ugarchspec(variance.model = list(model = "gjrGARCH", garchOrder=c(1,1)), mean.model = list(armaOrder=c(1,0), include.mean = TRUE), ...
5
votes
2answers
76 views

Create Tick Bars with R

How do I get OHLC bars with tick count (i.e. 500 ticks) instead of time? I prefer quantmod. Currently I have tick data and can already convert to minute bars using xts. ...
2
votes
1answer
142 views

Alpha vantage API Not working for NSE while the same query is giving output for NYSE stocks

Was trying to pull intraday data with free api from alpha vantage but unable to download it; While At the same time I'm able to download daily OHLC data. Also, intraday data query is working for NYSE ...
1
vote
0answers
27 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
2k 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: ...
-1
votes
1answer
549 views

Choosing programming language for the next generation of a pricing library [closed]

If I were to start development of a pricing library, which programming language would be most suitable to satisfy the following needs: Implement highly parallelizable pricing models using GPU or any ...
0
votes
0answers
72 views

How can I calculate Asian Option value when the averaging interval starts in the future?

So, actually the question is very straightforward. Say, at 01-Aug-2018 I bought an Asian Option with maturity at 01-Nov-2020. Averaging period is between 01-Aug-2020 - 01-Nov-2020. I would like to use ...
1
vote
0answers
32 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 ...
0
votes
0answers
51 views

Bubble detection: R package MultipleBubbles

I would like to use the R package "MultipleBubbles" with different variations of the ADF test (augmented Dickey-Fuller test). These methods should facilitate the detection of financial bubbles. For ...
0
votes
1answer
86 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 ...
5
votes
1answer
103 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 ...
2
votes
1answer
26 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 ...
4
votes
0answers
84 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 ...
0
votes
0answers
37 views

Why the spread is calculated on raw prices instead on the price changes?

I'm reading *Quantitative Trading With R * written by Harry Georgakopoulos. In chapter 6 he exposes a basic quantitative strategy based on setting up a stock spread and buy when it is below a lower ...
3
votes
0answers
75 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 ...
0
votes
0answers
50 views

Gonzalo Granger and Hasbrouck Information Share

I am trying to implement the two methods for price discovery following this paper Price Discovery in CDS and Bond Markets. I allready looked for implementation and based my work on this R project ...
0
votes
0answers
51 views

Calculate monthly returns for a QUARTERLY and YEARLY rebalanced portfolio in R

I built a minimum variance, equal weight, inverse volatility, and equal risk contribution portfolios based on the same data set of monthly returns for 30 different companies. The covariance matrix is ...
2
votes
1answer
73 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 ...
0
votes
0answers
51 views

Finding ETF Symbols for alpha vantange

I'd like to use the api of https://www.alphavantage.co/ which is pretty well documented, in terms of avaliable functions (but not parameters). However, in order to get an API response, one needs to ...
0
votes
0answers
28 views

Quantlib : How to get fixed leg NPV?

for my project using Quantlib 1.13 C++, I have to create a swap by creating each leg separately. So for instance in the case of a Vanilla swap, I have a Leg corresponding to a vector of ...
0
votes
0answers
27 views

BBands problem in quantstrat

I am currently trying to write a simple strategy using Bollinger Bands in R. The goal is to enter a long position when the closing price touches the lower band and ...
0
votes
0answers
24 views

Understanding QuantLib qlYieldTSForwardRate

I'm trying to understand the QuantLibXL function qlYieldTSForwardRate() but the QuantLib manual is not of much help so I'm hoping to find answers here. I think I ...
0
votes
1answer
162 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/...
2
votes
1answer
100 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 ...
0
votes
1answer
135 views

Programmatically detect RSI divergence

How can I programmatically detect bullish and bearish RSI divergences? A bullish divergence occurs when the underlying security makes a lower low and RSI forms a higher low. RSI does not confirm the ...
0
votes
0answers
20 views

How to interpret constant in a fixed effect panel data regression when using Stata

Dear Stackexchange community, I am running a panel data regression on 20 years of monthly historical excess returns of the stocks in the S&P 500 at 31/12/2017. I like to test the effectiveness of ...
1
vote
0answers
31 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
49 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, ...
2
votes
1answer
144 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-...
1
vote
0answers
46 views

European Call Option Modelling under 2 factor Hull White interest rates

I have modelled the yield curve through the two factor Hull White Model. Now I want to implement in Matlab the price development of a ATM-Call-Option (European). Has someone an idea how to combine ...
0
votes
0answers
24 views

Is there a good back-test library for Matlab, similar to Quantopian's Zipline for Python?

If so, what? I'm keen to back-test some currency trading strategies and am restricted to using only Matlab. The back-test is intended to contain forward contracts for which I only have monthly data.
1
vote
1answer
115 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}{\...
0
votes
0answers
22 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....
0
votes
0answers
23 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 ...
3
votes
1answer
173 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
2answers
301 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$ ...
2
votes
1answer
226 views

Backtesting C++ Algorithms

What software is available for backtesting trading algorithms written in the C++ programming language? I would not like to use an online service such as Quantopian or Quantconnect (they don’t offer C+...
1
vote
0answers
46 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 ...
0
votes
0answers
20 views

How to get Financial Information of Stocks in R [duplicate]

I am trying to get financial Information like NAV, Dividends, Liabilities. I try to get all the stock information using quantmod package. But it is not working for <...
2
votes
1answer
160 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 ...
1
vote
1answer
61 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
1answer
115 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 ...
0
votes
0answers
31 views

Fitting an explicit copula in R

I am running a simulation to price a CMS and I am varying the copula I am using to measure the effect of the latter on pricing. I have come across a series of copula that can easily be implemented in ...
1
vote
0answers
40 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, <...
0
votes
1answer
113 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 ...
2
votes
1answer
113 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 ...
0
votes
0answers
62 views

Unlabelled mid-price stock data

The mid-price at time $t$ is denoted by $$p_t = \frac{s_t^{a,1} + s_t^{b,1}}{2}.$$ This mid-price can evolve in minimum increments of half a tick but is almost always observed to move at ...