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
35 votes
4 answers
29k views

How to derive the implied probability distribution from B-S volatilities?

The general problem I have is visualization of the implied distribution of returns of a currency pair. I usually use QQplots for historical returns, so for example versus the normal distribution: ...
Thomas Browne's user avatar
27 votes
17 answers
92k views

What programming languages are most commonly used in quantitative finance?

What programming languages are the most common in quantitative finance, and why are these languages used? Note: I do not mean, what languages are used to develop the accounting system at a hedge fund:...
8 votes
1 answer
8k views

Understanding Yang-Zhang Volatility Estimator

I am using TTR in R and I am trying to understand the Yang Zhang volatility estimator (without drift). The following equations seem to imply a single value: $$ \sigma = \sqrt{{\sigma_o^2}+k\sigma_c^2+...
user avatar
11 votes
1 answer
2k views

Obtaining risk-neutral probability from option prices

Suppose I have the following data (for the current stock and option prices of the Bank of America) Strike Last IV Probability 4 8 5.43 0.5813566 0.0000000 7 11 2.45 0.2868052 ...
tosik's user avatar
  • 476
3 votes
2 answers
470 views

How to add the effect of skewness in the portfolio optimisation objective function?

I have the following risk adjusted portfolio which I optimise, where gamma is the risk return trade off, $r$ are the returns and $C$ is the covariance matrix which considers scenarios, so it is not ...
Luigi87's user avatar
  • 326
0 votes
0 answers
462 views

How to compute the Brazilian Plain vanilla swap using Quantlib?

How to compute the BRL plain vanilla swap. I have followed the below methodology to calculate the valuation for other indexes but BRL-CDI is far off from actual valuation. Please suggest if anything ...
robin's user avatar
  • 105
7 votes
3 answers
9k views

What is an efficient method to find implied volatility?

I have a code that finds the implied volatility using the Newton-Raphson method. I set the number of trial to 1000 but sometimes it fails to converge and doesn't find the result. Is there a better ...
opt's user avatar
  • 559
4 votes
1 answer
556 views

Bartlett's delta gives wrong signs for calls and puts

There is a paper by Bruce Bartlett introducing a modified delta for SABR model which accounts for the correlation between forward and volatility processes. The main result of the paper is that if $dF$ ...
Hasek's user avatar
  • 814
4 votes
1 answer
15k 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....
hoonzis's user avatar
  • 213
3 votes
2 answers
5k views

Excel YIELD function equivalent in python Quantlib

I am struggling to get an equivalent of Excel's YIELD function using Quantlib in python. As you can see from the Excel documentation on YIELD here, only a few parameters are needed compared to this ...
tsando's user avatar
  • 139
3 votes
5 answers
3k views

Efficient frontier doesn't look good

Hi I'm trying to draw an efficient frontier. Below is what I used. returns parameter consists of 9 column returns of portfolio. I selected 10,000 portfolios and this is how my efficient frontier ...
Hiru's user avatar
  • 103
1 vote
3 answers
610 views

Future Value: the functions in Excel, Matlab and Numpy Financial don't work when the number of periods is large

The Future Value function and its expected behaviour Excel's function FV(rate, nper, pmt, pv) calculates the future value of an investment based on periodic, ...
Pythonista anonymous's user avatar
63 votes
21 answers
60k views

Is there any thing out there as a substitute for KDB?

thanks a lot for your discussions on the original post. following your suggestions, let me re-phrase a bit : kdb is known for its efficiency, and such efficiency comes at a terrible price. However, ...
Peter Peter's user avatar
44 votes
9 answers
22k views

What tools exist for order book analysis and visualization?

What tools exist for order book analysis and visualization? In particular, if one wanted to examine a limit order book and understand how it changes throughout the day where would you turn for ...
Louis Marascio's user avatar
24 votes
3 answers
5k views

Tools in R for estimating time-varying copulas?

Are there libraries in R for estimating time-varying joint distributions via copulas? Hedibert Lopes has an excellent paper on the topic here. I know there is an existing packaged called copula but ...
Ram Ahluwalia's user avatar
23 votes
6 answers
69k views

How to fit ARMA+GARCH Model In R?

I am currently working on ARMA+GARCH model using R. I am looking out for example which explain step by step explanation for fitting this model in R. I have time series which is stationary and I am ...
Add's user avatar
  • 1,397
21 votes
3 answers
9k views

Is there an all Java options-pricing library (preferably open source) besides jquantlib?

I am looking for an all-java implementation of black scholes, preferably open source. I found jquantlib and quantlib (C++). Any other recommendations? The jquantlib site seems to be down. I'd prefer ...
colin's user avatar
  • 249
18 votes
1 answer
28k views

Forecasting using rugarch package

I want to do one step ahead in-sample forecasts. My data can be found here. This is just a data frame with the date as the rownames. I specify my model and do the fit and show the plots with ...
Stat Tistician's user avatar
14 votes
1 answer
2k views

Does your Parkinson volatility ratio work as Taleb explained?

According to Dynamic Hedging: Managing Vanilla and Exotic Options (Taleb, 1997), the Parkison volatility estimator has several meaningful properties. It is defined $$P=\sqrt{\frac{1}{n}\sum_{i=1}^{n}\...
Lisa Ann's user avatar
  • 2,131
14 votes
2 answers
22k views

GARCH model and prediction

I have a question about the prediction of volatility and returns of a time series. Basically it is a question about predict in the ...
math's user avatar
  • 1,718
13 votes
4 answers
4k views

What .NET library can I use to solve optimization problems?

I'm working with C# and I start being bored writing optimization algorithm. Do you know any free library containing this sort of algorithms? In particular I'm currently working with Semidefit ...
Zarbouzou's user avatar
  • 2,293
9 votes
1 answer
32k views

How to interpret results of Johansen Test?

I have two time-series a & b. The objective is to find out whether two series are cointegrated or not. I am using Johansen Test in R to find this out. I am using urca package of R. Here is the ...
techpaisa's user avatar
8 votes
1 answer
4k views

Issue Using QuantLib and Python to Calculate Price and Greeks for American Option With Discrete Dividends

I am having trouble using QuantLib with Python to calculate American options with discrete dividends. I am using Anaconda, Spyder, Python 3.6, and the most recent version of QuantLib. I created ...
fmc100's user avatar
  • 83
8 votes
1 answer
7k views

Use QuantLib Python to calculate Swap DV01

I would want to use QuantLib Python to calculate DV01 of an interest rate swap. Initially I was thinking of calculating the fixed leg DV01 and floating leg DV01 separately, then add both legs DV01 ...
lcheng's user avatar
  • 247
8 votes
2 answers
4k views

Is there a non-recursive way of calculating the exponential moving average?

I want to calculate the exponential moving average for many stocks in a large investable universe. To do this, I've seen the following formula: Because it references the previous day's exponential ...
user1953907's user avatar
8 votes
2 answers
3k views

Random Portfolios vs Efficient Frontier

I understand the concept of the efficient frontier and am able to calculate it in Python. But even when generating 50'000 random 10 asset portfolios, the single portfolios are not even close to the ...
R. Steigmeier's user avatar
7 votes
3 answers
13k views

How can I estimate the Ornstein-Uhlenbeck paramters of some mean reverting data that I have on R?

I have mean reverting data (Difference of 2 stock prices, that I want to do pairs trading on). I want to simulate my own mean reverting data as similar as possible to the real data that I have. The ...
JonSnow93's user avatar
5 votes
1 answer
4k views

SABR Model Pricing Engine in Python QuantLib

I am looking for a SABR model pricing engine in Python QuantLib setting. I do know that it exists in C++ version, but not sure if available in Python. Any suggestion/feedback with respect to Python ...
Desi_Quant's user avatar
4 votes
1 answer
451 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. ...
Pim's user avatar
  • 117
4 votes
2 answers
1k views

Valuing structured loans in QuantLib

I'm trying to figure out if it's possible to value structured products, mainly loans, in quantlib. The idea is to build a bond class with different cash flows. For example, a loan could have coupons ...
Jose Pedro Melo's user avatar
4 votes
2 answers
2k views

Detect pattern from OHLC data in Python

I'm trying to create a script that, from standard OHLC data, finds patterns. The specific pattern i'm looking for right now is sideways movement after a move up, here is an example: So basically my ...
Jack022's user avatar
  • 91
4 votes
1 answer
1k views

How to permanently add holidays to QuantLib calendars?

I am aware of QuantLib's functions addHoliday() and removeHoliday(), but I am wondering if there is a better way to edit the ...
imomushi8's user avatar
3 votes
4 answers
10k views

Python libraries for bloomberg?

I am very new with python, and I am used to work with bloomberg formulas for excel. I am starting to use a lot more python in my analysis, is there any library that performs same functions as bdp, bdh ...
Juan's user avatar
  • 31
2 votes
1 answer
3k 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 ...
KOB's user avatar
  • 193
1 vote
2 answers
4k views

QuantLib python ql.schedule getting end of month dates

i'm trying to get payment schedule of a bond that pays coupon quarterly. value date is 2020-04-01, first coupon date is 2020-06-30, maturity date is 2022-09-30. so I expect to have a list of dates: ...
user51725's user avatar
1 vote
1 answer
2k views

QuantLib Python price same swap on different evaluation dates

I want to use QuantLib Python to price a swap at 2 different evaluation dates during the life time of the swap. The following is what I've tried so far: ...
lcheng's user avatar
  • 247
1 vote
3 answers
2k views

C++ textbook recommendation for quants

I work as a Quant Dev at a financial institution where I'm mostly using Python for development and thus I have a few years of Python programming experience. I'm planning on learning C++ and therefore ...
user46044's user avatar
1 vote
0 answers
900 views

Quantlib : Valuation of inflation swaps of EUR-RPI using quantlib python?

Below is the sample code to compute the inflation swaps. I have referred the Quantlib cookbook to get the flavor of Inflation swaps. But I feel that the term structure and final NPV is not accurate ...
robin's user avatar
  • 105
1 vote
1 answer
1k views

negative gamma value for gjr-garch output

I was wondering if anyone could tell me if my model is completely incorrect as I haven't been able to find anything online for this. I am running a Gjr Garch model to measure volatility in gold ...
Ellen Hynes's user avatar
1 vote
1 answer
188 views

Find the right module for CDI DI BRL swaps valuation Quantlib

I'm trying to find a way to price BRL CDI Swaps with Quantlib but I can't find any solutions so far - so I was wondering if anyone encountered this issue: I don't see any solution on Quantlib. I ...
Gloomy's user avatar
  • 21
75 votes
8 answers
33k views

Is R being replaced by Python at quant desks?

I know the title sounds a little extreme but I wonder whether R is phased out by a lot of quant desks at sell side banks as well as hedge funds in favor of Python. I get the impression that with ...
Matt Wolf's user avatar
  • 14.4k
60 votes
13 answers
25k views

Switching from C++ to R - limitations/applications

I've only recently begun exploring and learning R (especially since Dirk recommended RStudio and a lot of people in here speak highly of R). I'm rather C(++) oriented, so it got me thinking - what are ...
Karol J. Piczak's user avatar
50 votes
12 answers
61k views

Why is C++ still a very popular language in quantitative finance? [closed]

I had to ask this question after reading the answers to What programming languages are most commonly used in quantitative finance? I understand that C++ programs can be optimized pretty well and are ...
Tae-Sung Shin's user avatar
47 votes
14 answers
35k views

Except Zipline, are there any other Pythonic algorithmic trading library I can choose?

Except Zipline, are there any other Pythonic algorithmic trading library I can choose? Especially, for backtesting? Update: Since Quantopian closed, there are some Zipline forks like: https://pypi....
Terence Ng's user avatar
33 votes
5 answers
14k views

What is a good broker for HFT?

Currently I trade trough IB. I run my HFT strategies (100 roundtrips per hour) but I think that latency is killing me and my profits are shrinking. I need the fastest possible brokers out there which ...
user40's user avatar
  • 2,697
31 votes
2 answers
29k views

Correctly applying GARCH in Python

Problem: Correct usage of GARCH(1,1) Aim of research: Forecasting volatility/variance. Tools used: Python Instrument: SPX (specifically adjusted close prices) Reference material: On Estimation of ...
WGS's user avatar
  • 313
28 votes
9 answers
6k views

How good is managed code for algo trading?

I am currently working in a firm that does algo trading. We do all of our stuff in Java. And we do make money out of it. We have debates all the time whether we would have made more money with native ...
Bick's user avatar
  • 613
28 votes
13 answers
21k views

What is the reference python library for portfolio optimization?

Does anyone know of a python library/source that is able to calculate the traditional mean-variance portfolio? To press my luck, any resources where the library/source also contains functions such as ...
Gabe's user avatar
  • 381
25 votes
5 answers
11k views

Implementing data-structures in a Limit order book

I'm working on implementing a 'LOB' and I'm being very careful about choosing my data-structures so as to maximize performance. Using F# as an example, I need to consider a List versus Array for ...
jordan.baucke's user avatar
24 votes
7 answers
34k views

Is the Interactive Brokers API suitable for hft?

By HFT here I mean anything with holding period less than 5 to 10 minutes. Any empirical/anecdotal evidence of using it successfully on even higher frequencies?
user40's user avatar
  • 2,697