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.

420 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10 votes
0 answers
654 views

Block bootstrap to synthesize asset prices

I have a few basic questions on block bootstrapping on a financial time series ('TS'). Assuming my trade universe consists of 10 stocks, I would like to create a set of synthetic prices for all 10 ...
user avatar
9 votes
0 answers
813 views

Alternative to Block Bootstrap for Multivariate Time Series

I currently use the following process for bootstrapping a multivariate time series in R: Determine block sizes - run the function b.star in the np package which produces a block size for each series ...
user avatar
8 votes
0 answers
1k views

Replicating Bloomberg Swap Prices with QuantLib

I'm trying to learn more about the QuantLib python package and as an exercise I'm trying to replicate some swaps on Bloomberg. However, when I do so, it seems like my swaps are consistently ...
user avatar
  • 181
8 votes
0 answers
254 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 ...
user avatar
  • 181
7 votes
1 answer
903 views

Python Backtesting Framework Similar to Quantstrat

I use Quantstrat heavily for strategy research and optimisation. I have two Python developers about to join my team and would like to use it as an opportunity to diversify our research tools so we are ...
user avatar
6 votes
0 answers
764 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 ...
user avatar
  • 188
5 votes
1 answer
1k views

How to calculate average entry price for perpetual swap contracts?

I'm trying to calculate the average entry price for perpetual swap contracts for use in back-testing a trading strategy, as per Bitmex's documentation: A Perpetual Contract is a derivative product ...
user avatar
5 votes
0 answers
248 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 ...
user avatar
  • 101
5 votes
0 answers
4k views

Fitting GARCH(1,1) in Python for moderately large data sets

I am using the arch package in python to fit a GARCH(1,1) to fit daily S&P 500 returns from 1990 to 2017 (about 6800 data points). The code I am using is as follows: ...
user avatar
5 votes
0 answers
3k views

Implied volatility from American options using python

I am currently trying to construct volatility surface from american option prices (using Cox-Ross-Rubinstein tree) in Python 2.7. Below you can find the code I came up with. Any corrections would be ...
user avatar
  • 191
5 votes
0 answers
350 views

Algorithmic Trading Model Calculation and Stale Data

I'd like ask everyone a more concurrency programming but definitely quant-finance related question. How do you deal with staleness of data in market hours as quote ticks are streaming and your model ...
user avatar
  • 131
4 votes
0 answers
78 views

Implementing Hierarchical PCA for financial time series in R

I would like to implement the method "Hierarchical PCA", as described in the following paper and compare it to a "standard" PCA. I like to do this in R AVELLANEDA, Marco. ...
user avatar
  • 61
4 votes
1 answer
508 views

Complexity of using balanced-tree to model order book

I have bene researching on the best data structure to implement a limit order book. Some of the most common implementations include arrays and balanced trees. This link has a good set of references. ...
user avatar
4 votes
0 answers
128 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 ...
user avatar
  • 708
4 votes
0 answers
671 views

How to estimate option implied skewness and kurtosis in R

Suppose that i have data that for each day i have more than one option, either put or call. I.E. I have more than 20 put options and 20 call options for each specific day. What is the way to estimate ...
user avatar
4 votes
0 answers
179 views

VAR FPCA analysis paper replication

I've been trying to replicate the following publication: CONSISTENT FUNCTIONAL PCA FOR FINANCIAL TIME-SERIES, Sebastian Jaimungal, Eddie K. H. Ng, 2007 but I havent been able to get the same results ...
user avatar
4 votes
1 answer
807 views

Trader Workstation on Ubuntu cannot be connected to via the API

I am using ibPy to connect to TWS on a fairly fresh ubuntu machine. I have been successful in logging into the paper trading account and submitting buy and sell orders programatically via the ibPy ...
user avatar
4 votes
0 answers
835 views

Black-Scholes explicit Euler implementation python

I've written some code for the explicit finite difference method to solve the BS equation. For certain sets of parameters (time-steps and asset-steps) I get a stable but wrong solution. For others, ...
user avatar
4 votes
0 answers
261 views

How would it be possible to use Dynamic Programming to search a space of investment strategies to find an optimum?

As my question states, the problem I am having is finding a sensible way to search a large space. Any help or insight that could be provided would be hugely appreciated. Currently I am trying to ...
user avatar
  • 61
4 votes
0 answers
270 views

negative transition probabilities in the heston model

I've been trying to implement a bivariate tree for pricing american options with the heston model in R using the paper of Beliaeva and Nawalkha (http://papers.ssrn.com/sol3/papers.cfm?abstract_id=...
user avatar
  • 41
4 votes
0 answers
3k views

FIGARCH estimation in R

I am trying to estimate a FIGARCH(1,1) model in R for Value-at-Risk purposes. As I understand it, the rugarch package does not support FIGARCH or FIEGARCH. To that end, I used the garchOxFit function (...
user avatar
4 votes
0 answers
563 views

Rate Distortion Minimization in a Python Clustering Algorithm

I'm attempting to solve for $\hat{k}$ clusters, such that the rate distortion is minimized, as described here, however, the answers that I am getting from my algorithm are not following the "Jump" ...
user avatar
4 votes
0 answers
287 views

RQuantLib: any difference between FixedRateBond() and FixedRateBondPriceByYield() with flat term structure?

Please, consider the following functions from RQuantLib package: FixedRateBond() ...
user avatar
  • 2,046
4 votes
1 answer
2k views

Moving window forecasting in Python

I am looking to create some code that will out-of-sample forecast the HAR-RV model. The model itself is formulated as the following, and the betas are estimated through HAC-OLS or Newey-West. ...
user avatar
4 votes
1 answer
1k views

How to estimate parameters for 2 correlated Ornstein-Uhlenbeck processes with maximum likelihood?

I would like to use maximum likelihood to estimate the parameters of two correlated Ornstein-Uhlenbeck processes from empirical data. Do you have any good references for this? If you have any hints ...
user avatar
  • 113
3 votes
0 answers
152 views

Interesting finding... "Adjusted Kirk's" and "Bjerksund-Stensland" are exactly the same ??? Spread option calculation

This is more of an academic question. The results are SO close, I think they are ACTUALLY THE SAME FORMULAS. So someone published a paper with a "new" method to adjust Kirk's formula to ...
user avatar
  • 165
3 votes
0 answers
72 views

Manual Computation of Python QuantLib's NPV for Pricing of a Forward Rate Agreement

Following the question that I have asked on this link and response obtained, I have managed to price a 3x6 FRA using QuantLib Python, using the following codes: ...
user avatar
3 votes
1 answer
275 views

PortfolioAnalytics and regime switching issue

I've been playing around with the R package PortfolioAnalytics and I have spent more time than I'm willing to admit to try and resolve this issue: When I follow the regime switching example with the ...
user avatar
  • 31
3 votes
0 answers
1k views

Simulating correlated Geometric Brownian Motion in Python

I want to simulate two correlated Geometric Brownian Motion processes in Python. I found an implementation from Matlab (https://www.goddardconsulting.ca/matlab-monte-carlo-assetpaths-corr.html) and ...
user avatar
  • 63
3 votes
0 answers
2k views

Does Fidelity Have a Python Trading API?

I'd like to do my trading through a corporate account at Fidelity, but there does not seem to be a Python api. What I'm looking for is something like this: https://github.com/jmfernandes/robin_stocks
user avatar
3 votes
0 answers
235 views

Is it possible to match talib's RSI results down to machine precision using just python?

I want to match talib's RSI with just python down to machine precision and I'm struggling. Out of curiosity I also tried a bunch of libraries like tulipy and pandas_ta and the gaps are similar. ...
user avatar
3 votes
1 answer
341 views

GARCH(1,1)-M MLE optimization with fmincon in R

I've searched thru dozens of papers and did not find in any of them satisfying and enough theoretical answers to my concerns. So I've combined everything what I found below. Please indicate if my ...
user avatar
3 votes
0 answers
124 views

Identifying the same company behind stocks traded in different exchanges (e.g. CUSIP and WKN in 1990ies)

I would like to merge two data sources with companies headquartered in Germany between 1980-2000, but listed in Germany and the US. One source identifies "German companies" by their CUSIP, the other ...
user avatar
3 votes
0 answers
454 views

How to calculate YTW (yield-to-worst) in QuantLib?

After defining a CallableFixedRateBond object in QuantLib, I can calculate YTM (yield-to-maturity) right now. I'm using Python so the function is bondYield(). Is there any way to calculate YTW (yield-...
user avatar
3 votes
0 answers
139 views

Detecting leading stocks using lag correlation

I am working on a project to find leading stocks in a stock market by using lag correlation. Say I want to compare 2 stocks, X and Y, and I have the time series of stock prices. Assume that the ...
user avatar
  • 31
3 votes
0 answers
466 views

Is there a more efficient data structure to implement binomial trees than 2d array?

I'm just curious what is the "industry standard" for implementing a binomial tree (if "standards" exist in this case). For simplicity, let's just talk about the simplest trees with recombining nodes. ...
user avatar
  • 921
3 votes
0 answers
598 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 ...
user avatar
  • 205
3 votes
1 answer
475 views

VAR-aDCC full ARCH and GARCH parameter matrices in R

I am working with the rmgarch package in R and I estimated a VAR-aDCC model. Is there any way to extract the extended version of estimates (allowing for volatility ...
user avatar
3 votes
1 answer
10k views

Historical volatility on bloomberg API

Is there a way to obtain the historical volatility of a stock from the bloomberg API? I would be looking for the data in the HVT table. Actually 3-months historical volatility from now would be enough....
user avatar
  • 203
3 votes
0 answers
165 views

Approximate asian geometric option with Heston

I am trying to implement Theorem 1 from this Journal in RStudio. The journal says the it is possible to find a approximate price of a geometric asian option in a Heston setup this way: $$X_{1cGAO}=e^{...
user avatar
  • 31
3 votes
0 answers
239 views

Ledoit-Wolf portfolio weights calculation

I am trying to implement the Ledoit-Wolf minimum variance portfolio strategy on a real-world stock dataset. ...
user avatar
  • 31
3 votes
0 answers
708 views

GARCH modelling and forecasting

I have a few questions regarding GARCH modelling and forecasting and it would be great if someone could help me. I am modelling the log return of oil spot prices using various GARCH models: GARCH, ...
user avatar
3 votes
0 answers
734 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 ...
user avatar
  • 31
3 votes
0 answers
120 views

How do I specify Thirty360::European day counter in RQuantLib

I am taking liberty to ask the following question in quantLib forum though this question is about RQuantLib I am trying to use RQuantLib to calculate clean price of a fixed coupon bond using a Nelson-...
user avatar
  • 131
3 votes
0 answers
388 views

how to apply a simple copula model

I'm playing around with copulas and wanted to generate some sample based on copula techniques in R. For this purpose I applied the following algorithm: Generate three sample vectors coming from ...
user avatar
  • 1,638
3 votes
0 answers
220 views

rugarch and rolling estimation

I use Rugarch for a long time in order to calibrate GARCH models on FX rates time series and perform simulations. I am trying to understand the ugarchroll method. However even if I can find plenty of ...
user avatar
  • 171
3 votes
0 answers
3k views

Black Scholes diffusion well coded in Python

I have some trouble with the following code. Some jump and a decentered path are present but it's not the case, normally for Black Scholes diffusion! Is anyone see a problem in my code ? ...
user avatar
  • 166
3 votes
0 answers
467 views

What R-packages for SOCP problems are there?

Currently, I am looking deeper into the topic of second-order cone programming. Could you suggest packages that solve SOCP-problems in R? With your answer, please provide a short description of ...
user avatar
  • 2,894
3 votes
0 answers
2k views

Philips-Ouliaris test for cointegration

I'm trying to implement cointegration tests using the R urca package. I've figured out the Johansen test (ca.jo), but I'm having trouble with the Philips-Ouliaris test (ca.po). I have two questions: ...
user avatar

1
2 3 4 5
9