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
1
vote
1answer
13 views

Factor Model Regression Market Factor Statistically Insignificant After Adding Extra Factors

I am running a simple 4 factor model which includes the factors: Benchmark (Market - FortyConsumerSixtyHealthcare), SMB, HML and MOM. When I simply apply the regression to the portfolio returns and ...
0
votes
0answers
15 views

TD Ameritrade “Get Orders By Query” API call documentation/help

First time to algorithm trading, python, and Quantitate Finance so apologies up front. I have noticed a lack of any good documentation for the TD Ameritrade API anywhere and especially with any of the ...
-2
votes
0answers
26 views

TA-Lib abstract API benefits [closed]

I don't get the benefits of using TA-Lib abstract ¿is it speed? ¿less processing? I went through the documentation, examples, and code examples, but can't get it. ¿can anyone explain it?
0
votes
0answers
15 views

Sector Contribution Analysis

I am trying to conduct a sector contribution analysis of a certain mutual funds. But I don't quite understand the logic. I am given these datasets. stock universe dataset.(it is a dataframe ...
-4
votes
0answers
53 views

Black Scholes model calibration with Python - small error in the code

Hey I write this code to calibrate Black Scholes model, but I got an error and I don't know how to correct it. Can anyone look and tell me what should I do? ...
0
votes
2answers
21 views

Obtaining current list of companies in the FTSE 100 via an API

I'm making an app that displays the last close price of each ticker in the ftse 100 but for the life of me I can't seem to find an API that has this functionality. Particularly which companies ...
0
votes
0answers
22 views

Python arch_model package last_obs vs. for loop rolling window slight differences

i am using the GARCH package in Python to forecast volatility of the SPX Index. According to the documentation, there are two arguments "first_obs" and "last_obs" first_obs({int, ...
-4
votes
0answers
35 views

Kou model matlab/python code [closed]

Hey I need some code to implement the Kou model to price call option. I prefer Python but can be any other language. I am not a programmer, so I can not write it myself. Cna anyone help me?
0
votes
1answer
66 views

Issues making series stationary

I am trying to run some ARIMA forecasts and I switched recently from R to Python. I am struggling for some reason to make this series stationary . I try to take the log returns of stock prices as such ...
2
votes
0answers
61 views

How to estimate the intensity rate $\lambda$ of a Cox Process

In a Cox Process, or doubly stochastic Poisson process, the intensity rate itself is a stochastic process that varies across space or time. Let us assume that the intensity rate has the following form ...
0
votes
1answer
55 views

Why does the closed formula result for a Barrier option price deviate so strongly from the Monte Carlo approximation?

I am trying to price a down-and-out, leveraged Barrier option using the closed form formula of Hull (2015). When the price of the underlying asset falls and hits a certain barrier (H), the contract ...
2
votes
2answers
2k views

Augmented Dickey-Fuller Test/ Unit Root test on multiple time series dataframe in R

I have a dataset/dataframe in which I have calculated the daily log returns of five thousand companies and these companies are as column as well. I want carry out ADF test on this dataframe. I have ...
0
votes
0answers
19 views

Alpha vantage API Not working for NSE any help [closed]

I am using below url, but alpha vantage not returning any data. Can I get any help? https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=NSE:BIOCON&apikey=xxxxxx
3
votes
0answers
132 views

Estimate market price of risk $\lambda_t$

The pricing of derivatives in a risk-neutral framework often requires the input of an unobservable market price of risk. Let us assume that we observe two macroeconomic factors in the state vector $...
-1
votes
0answers
40 views

ZigZag Indicator in Python [closed]

I would like to reply a Metastock Formula (ZigZag based on Close Price) I had some similar results but not the right ones! Formula: ...
1
vote
0answers
13 views

Selecting the correct MaxLag for Granger's Causality

I have a developer who has created a python script to determine the granger's causality of several datasets that are approximately 3 years worth of daily data (approx 1100 data points for each time ...
2
votes
1answer
986 views

Calibration of Theta, A(t) and B(t) of Hull White 1Factor model

I’m simulating interest rates via the HullWhite One factor model. To simulate the short rate I’m using the code from the Quantlib Python Cookbook, chapter 15 and beyond (By Goutham Balaraman and Luigi ...
0
votes
0answers
26 views

how to interpret the results of a GARCH model fit R/python

I have got the following output from a gjrGARCH model, and I need help to interpret it in order to decide whether it is already a good model and proceed with the forecast. ...
2
votes
0answers
28 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. ...
1
vote
0answers
44 views

Has AlphaVantage stopped NSE stock quotes data? [closed]

I have been using AlphaVantage to get the historic data for NSE stocks (NSE= National Stock Exchange of India Ltd.). But since past 1 month the API has stopped returning data for NSE stocks. It ...
0
votes
0answers
33 views

Commodities API data source [duplicate]

I'm trying to get commodity historical information via API. I found this https://www.alphavantage.co/documentation/ which does somewhat provide some data for stocks and others but not commodities and ...
1
vote
1answer
51 views

How to compute returns from cumulative returns in Python? [closed]

If X is a $T\times N$ pandas DataFrame of multivariate asset returns, the cumulative returns can be computed in python as (1 + X).cumprod() - 1 How can I reverse this operation so that I go ...
2
votes
4answers
291 views

ARIMA model coefficients from discontinuous data series

Stock prices are not stationary processes during all week or all day. For example EURGBP has low variability at night in Europe but during working hours is changing much more dynamic because of market ...
17
votes
5answers
68k 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 ...
1
vote
1answer
221 views

Simulation of Heston process Quantlib-Python

I am wondering weather there exists some method such that one can simulate sample paths for the Heston model in Quantlib-Python. I am currently working on a project that require simulations with the ...
0
votes
2answers
210 views

Heston volatility surface in Python QuantLib

Does anyone have experience with the Python QuantLib function HestonBlackVolSurface? I'm trying to produce a 3D plot of the volatility surface as done in the ...
0
votes
1answer
42 views

How to make futuresHelpers in Quantlib work with monday settlement day not IMM?

My EuroDollar futures have monday of third week expiration and settlement date from CME exchange how ever Python Quantlib doesn't seem to like it. Anyway I can get away with IMM check? futures = { ql....
0
votes
2answers
60 views

I just got Matlab, what are some options that I should model in a jump diffusion

Don't worry I understand mathematics: ito's calc, martingales, etc. I am just curious what options I should test, and from what indices. Is there stuff I can test from the 2008 crash to measure their ...
1
vote
3answers
76 views

Volatility differences

To discover trading prices of high volatility, I measure the standard deviation of two currency pairs using a simple example: ...
1
vote
1answer
41 views

how to model the volatility of the currency exchange rate

I want to estimate/predict the volatility of the currency exchange rate. I have checked in literature a few models from very simple PPP to econometric factor model forecasting, to GARCH (for ...
0
votes
0answers
10 views

“ugarch” roll from “rugarch” not working in source()

I have an automatic rolling GARCH forecast using the rugarch package in R. It is stored in a file GARCH.R. When I try to run the code using source('GARCH.R'), I get ...
2
votes
1answer
88 views

Backtesting short-selling strategy using pandas dataframe

I would like to make a simple backtest for one of my short-selling strategies. I am using pandas dataframes. So I have a dataframe like the following, that indicates how many positions to open/close ...
4
votes
3answers
971 views

Extreme Value Theory in Risk Management

1 - I am trying to understand the concept of EVT and how we are able to calculate VaR and ES from that. I would like to understand the maths in more detail. 2 - If I have a portfolio of Long and ...
4
votes
1answer
651 views

Optimal Portfolio from Efficient Frontier

I found this code on plotly site, using CVXOPT to find the efficient frontier, and then, the optimal Portfolio. The optimal function is ...
2
votes
0answers
357 views

Downloading IB futures data and then making a datapump to another program

I never have programmed before in my life but I wouldn't mind learning if I knew what i needed to do in order to solve my problem. I use neuroshell for day trading and use it extensively for trading ...
0
votes
1answer
53 views

How to download all stocks from NYSE, AMEX and Nasdaq from CRSP without entering individual company codes?

I was wondering if there is an efficient way to extract data on all the stocks from the CRSP dataset? In the Query Form I only have the option to enter company codes individually or to upload a .txt ...
-2
votes
1answer
50 views

ready codes for calculating integrals, FFT, MLE, drawing graphs, simulate trajectories [closed]

I'm looking for ready-made codes (R, Python or Matlab) for calculating integrals, simulate trajectories of stochastic processes (like CGMY), Fast Fourier Transform, maximum likelihood estimation and ...
3
votes
1answer
156 views

Which Maximum Diversification Approach in MATLAB is correct?

I am currently trying to find the portfolio weights of the Maximum Diversification Portfolio and found two approaches which result in different outcomes. The first one is based on this paper:https://...
7
votes
2answers
187 views

Oil price model calibration with Kalman Filter and MLE in python

I am trying to calibrate a one-factor mean-reverting process in python 3. The process is defined as: \begin{equation} dX = k(\alpha - X)dt + \sigma dW , \end{equation} where $\alpha = \mu - \frac{\...
1
vote
0answers
44 views

Downloading Historical Data from Finam.ru

I am looking for free historical intraday data (e.g., 30 mins, 1 hour) and I have came up to this website finam.ru, which is in Russian but it can be translated. The link to download the data is here. ...
3
votes
0answers
100 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. ...
10
votes
1answer
8k views

How to use statsmodels' Granger causality test to measure the lag between two time series?

I am using the Granger causality test to measure the lag between pairs of time series where it is already apparent that one is following the other. So I am not expecting this test to tell me whether ...
1
vote
0answers
44 views

How to connect Bloomberg's xbbp api to “Bloomberg Anywhere”

Due to COVID's remote work situation I found myself unable to access my physical terminal so I've had to use bloomberg anywhere (bba), the issue I'm having is that when I try to use python's xbbg on ...
3
votes
1answer
150 views

evaluating garch models

I used ugarchroll to backtest my garch model on S&P returns this is my code ...
1
vote
1answer
366 views

Is my python solution good? : Global Minimum Variance portfolio with 'no-short sale' constraint

Question Is my python code an answer (at least a close answer) to get the weight vector of the Global Minimum Variance portfolio problem? My codes are shown below after some explanations. Details ...
0
votes
1answer
73 views

Which curve is better to approximate bond yields (python)

I would like to approximate bond yields in python. But the question arose which curve describes this better? ...
1
vote
1answer
32 views

QuantLib in Python - RuntimeError: could not bootstrap optionlet:

I receiving the following error when I try to compute a cap price. However, I'm not sure how to solve this error. " error: nu (-1.00062) must be >= -1.0 expiry: June 4th, 2020 annuity: 0....
2
votes
2answers
1k views

Does QuantConnect use both bid and ask data for backtesting?

Or Quantopian? How about Python libraries like ultrafinance and PyAlgoTrader?
0
votes
0answers
49 views

How to fix my Ornstein-Uhlenbeck parameter MLE in Python?

I am trying to fit time-series data into an Ornstein-Uhlenbeck process. Here is my code so far: ...
2
votes
1answer
127 views

Pricing Variance Swap [closed]

I want to calculate the NPV of a Variance Swap wherein the cash flow happens every months based on the standard Variance formula of the close prices of S&P500 ...

1
2 3 4 5
28