We’re rewarding the question askers & reputations are being recalculated! Read more.

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
5
votes
3answers
2k views

Are there Python algorithmic trading libraries supporting forex?

I know about zipline and ultrafinance, but as far as I know, they don't support fx trading. Which libraries do?
4
votes
1answer
3k views

QuantLib Python Swap Yield Curve Bootstrapping Dates and Maturities

This is somewhat related to the question I asked here but simpler. I am trying to bootstrap a yield curve from swaps, and am having a problem with the dates/maturities that are coming out. The code ...
2
votes
1answer
1k views

short-sale constraint with nonpositive-definite matrix in portfolio optimization

I need help about portfolio optimization in R. I have inverted matrix and I want to use it as an input in portfolio optimization. It was non-positive definite before I have handled it. In portfolio ...
5
votes
0answers
472 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 ...
3
votes
2answers
1k views

Swap Bootstrapping with quantlib

I've been trying to get the zero rates of the Chilean Swap curve with Quantlib in Python, but I haven't been able to set up the parameters correctly. This is my code: ...
3
votes
1answer
10k views

Duration of a floating rate note

I have the following C# code for calculating the modified duration of fixed coupon bonds: ...
3
votes
1answer
159 views

Finance: Portfolio - Long Short Portfolio construction

I am trying to construct a Long / Short portfolio in R. Say I have two portfolios Tech and Mature and I want to go long on the <...
2
votes
1answer
248 views

TOIS (CHF), TONAR (JPY), AONIA(AUD) in Quantlib

I am looking for the TOIS, TONAR, AONIA in Quantlib for discounting. I only could find the EOINA, FEDFUNDS, SONIA etc.Do I miss something? In case they don't exist how can I use the corresponding rate ...
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 ...
10
votes
5answers
2k views

Is Visual Basic a fast enough for millisecond orders

I have an API that for an order routing platform that is in visual basic. The maximum frequency or orders to exchanges will be milliseconds, where the underlying systems are expected to be able to ...
4
votes
2answers
2k views

Using the termstrc package in R

I am attempting to use the function estim_nss from the termstrc package in R to find the spot curve from constant maturity rates published by the Fed. I am using this package because I will need to ...
4
votes
2answers
1k views

ruGarch - Interpret test results

I'm working on a R project, trying to calibrate a GARCH (so far, (1,1) ) model to the yields of the STOXX50 index over the last 2 years. I've tried the garch function of the tseries package, but it ...
4
votes
3answers
767 views

Compute tangency portfolio with asset allocation constraints

I am looking to compute the tangency portfolio of the efficient frontier, but taking into account min_allocations and ...
3
votes
2answers
173 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 ...
3
votes
1answer
3k views

How to calculate bond yield in QuantLib - Python

I want to calculate yield of bond having market price and coupons. I try to replicate C++ from (https://mhittesdorf.wordpress.com/2013/03/03/introducing-quantlib-internal-rate-of-return/) in Python ...
3
votes
2answers
3k views

backtesting options strategies in R

I would like to backtest an options strategy in R. I require the ability to delta hedge and rebalance to options in the portfolio at different frequencies (daily, monthly,etc.) What packages are the ...
3
votes
3answers
5k views

What is the Most Efficient Way to Calculate the Internal Rate of Return IRR?

I have built a program that prices financial assets and it does this in part by calculating the IRR. The problem is that it does not run as quickly as I would like it to. I currently use the Newton-...
2
votes
0answers
640 views

Any one know how to implement the Heston and Rouwenhorst country-sector effects regression in R?

Heston and Rouwenhorst (1994) devised an empirical estimation strategy to decompose stock returns into three components: a pure industry effect, a pure country effect, and a world-factor return. ...
2
votes
1answer
380 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 ...
2
votes
2answers
2k views

How to calculate the volatility matrix with multiple stocks

calculating the volatility for a single stock is straightforward. However, I'm not sure whether my approach for calculating the volatility matrix for multiple stocks is correct: I assume a log-normal ...
1
vote
1answer
1k views

Calculating Discount Margin on a floating rate bond using QuantLib

Going off Luigi's hint on this answer: Setting up Schedule for an amortizing floater in QuantLib I was able to cobble something together but I'm unable to verify if it's correct. TLDR: I was able to ...
1
vote
1answer
5k views

Is there a good backtesting package in R?

My model exports a vector that have for each day b-buy s-sell or h- hold it's look like this: sig [1] b b s s b b b s s b s b s s b s b s s s s b b s s b b b b b b s b b b b b b b I want to ...
1
vote
4answers
10k 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 ...
1
vote
1answer
375 views

Constant decreasing volatility, GARCH forecasting

I am trying to forecast the volatility using GARCH modelling in R. I fit an ARMA(1,1)-GARCH(1,1) model, but my sigma predictions are constantly decreasing. Anybody know why? ...
0
votes
0answers
396 views

Rolling forecast using GARCH model

EDIT This is not a duplicate of my original question linked, since I have since overcome that problem and have posted an answer. Since solving the previous problem, I have run into the problem ...
4
votes
2answers
2k 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 ...
3
votes
1answer
205 views

What is wrong in this GBM simulation?

I am trying to generate a few samples of GBM using the following very simple MATLAB code: ...
3
votes
1answer
149 views

forward + displacement

I I am trying to price a cap/floor using Quantlib in Python. the initial code from from this website: http://gouthamanbalaraman.com/blog/interest-rate-cap-floor-valuation-quantlib-python.html Here is ...
3
votes
2answers
639 views

How to perform portfolio optimization with user-defined expected return and variances using R?

I found some functions for Markowitz mean variance portfolio optimization in R such as portfolio.optim in tseries package. ...
3
votes
1answer
1k views

How to sum interest rate curves in QuantLib

C++ code taken from Bonds.cpp and slightly amended: ...
2
votes
1answer
210 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-...
2
votes
0answers
190 views

Binomial Model Implementation Trouble - American and European options come out equal

I'm Trying to implement the binomial option price model in python and get reasonable performance by using memoization. I checked the output against a black and scholes model and for European options ...
2
votes
2answers
150 views

Problem with obtaining densities

For my research I need to obtain a series of densities, however, I am encountering some problems. The first problem is perhaps very simple, but the answer eludes me. Let's say I have an observation ...
2
votes
1answer
6k views

IbPy download historical price data

How can i download historical price data from interactive brokers using IbPy and python?
1
vote
1answer
383 views

Is this the correct way to forecast stock price volatility using GARCH

I am attempting to make a forecast of a stock's volatility some time into the future (say 90 days). It seems that GARCH is a traditionally used model for this. I have implemented this below using ...
1
vote
2answers
1k views

garchOxFit in R

Could someone please help me with trying to get the Ox interface to work in R. I followed the steps outlined in this paper (http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1752095), but I get the ...
1
vote
1answer
108 views

Historic and future (next) round of machine readable dividend info

Is there a source of historic dividend dates, ex-dividend dates and dividend values? Also, the next dividend date / ex-dividend date. Ideally in a machine readable form? The publically available APIs ...
1
vote
1answer
690 views

Calculating Accrued Interest of Bonds

I am trying to calculate the accrued interest for a set of Treasury Bonds. I am comparing the answer from the code below with that for the 1st Bond(row) over here. In the link the AI is ...
1
vote
0answers
370 views

Portfolio Optimization with equal weight for assets selected

I have a data frame of bets, with 1 being a win and 0 being a loss. These bets are correlated so I cannot just pick the highest winning percentage. Goal is to get 2 optimizations, 1 for max sharpe ...
1
vote
0answers
92 views

To calculate the Hedge Efficiency and Optimal Hedge Ratio with BEKK in R

I estimated an MGARCH-BEKK model (using the R package BEKK, i.e. Baba, Engle, Kraft and Kroner; see Engle and Kroner (1995)) on time series of spot and futures ...
1
vote
1answer
100 views

Compare portfolio variance using different regularizers

I'm given a question like below. Using the 48_Industry_Portfolios_daily dataset: characterize/describe the dataset and focus on the global minimum variance portfolio. Compare the portfolio variance ...
1
vote
1answer
173 views

Correct Theoretical Discount Factors from Nelson-Siegel-Svensson?

I am calculating the theoretical discount factors associated with a bond that has 30 months to maturity from today with the parameters below obtained from here using the Nelson-Siegel-Svensson Model. ...
0
votes
1answer
778 views

QL-Python Bootstrapping Yield Curve FuturesRateHelper throwing off results

I'm trying to perform a bootstrap of a yield curve from deposit rates, futures, and swaps, and the interpolation is "blowing up" for the futures maturities being off by two orders of magnitude (100x). ...
0
votes
0answers
446 views

How can I export intraday stock data into CSV from Interactive Broker or Yahoo Finance?

Google Finance API seems to be down forever. Are there instructions or manuals for downloading intraday stock data into CSV files from Interactive Broker OR Yahoo Finance?
-1
votes
1answer
158 views

Use random-shift Halton sequence to obtain 40 independent estimates for the price of a European call

Background Information: Random-shift Halton sequence: Consider the first six Halton vectors in dimension $2$, using base $2$ and $3$: $$\begin{bmatrix} 1/2\\ 1/3 \end{bmatrix}, \begin{bmatrix} 1/4\\ ...
-1
votes
1answer
111 views

Separate market and limit orders from market depth/tick data

From the website https://www.algoseek.com/equities/, we can get a sample of the full depth market/tick data. From the paper https://arxiv.org/pdf/1710.03870.pdf page 8, I would like to extract the ...