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
0
votes
3answers
58 views

How is forex price precision (of the actual floating point number) determined?

I wrote some python code that tries to calculate this by samplying 1000 forex prices using polygon.io's REST api. However, will the precision ever change or is it fixed by something. How do they ...
0
votes
0answers
14 views

Question on the choice of boundary in the CUSUM test when we make some resampling

Question on the choice of boundary in the CUSUM test when we make some resampling We are considering to make a CUSUM test for some economical time series $X=(𝑥_1,..,x_n)$. Suppose $X$ contains many ...
0
votes
0answers
28 views

Spread betting risk management in backtesting in Python

My background is in Spread Betting. I know how to calculate my position size based on how far away my stop is from my entry, I calculate the amount per pip so that I only ever risk a fixed percentage ...
0
votes
0answers
32 views

Convert stock symbols so that they are useful for Yahoo Finance (yfinance)

I am working on my first investment algorithm, and I am using the following list of stock symbols and company names: https://public.acho.io/embed/...
0
votes
0answers
19 views

Default model for Adco LDM? [closed]

What is the default LDM model does Adco use? ...
0
votes
1answer
75 views

Bloomberg python API - intraday tick/bar request for options?

Is it possible to request intraday tick/bar data for a particular option (e.g. AMC 4/30 10c @ $0.91) with the python bloomberg BLPAPI? I've managed to do pull intraday tick data (with ...
0
votes
0answers
46 views

Backtesting a permanent portfolio

I'm looking to backtest this portfolio: Global Bonds, gold, Global Stocks, short-term t-bills (1/4 each) from 1990 up to this year, rebalanced monthly. Then take a variety of statistics on the time ...
0
votes
0answers
62 views

Convex optimization of ex-ante information ratio

I am trying to optimize an ex-ante information ratio using a convex optimizer. I have started with the Sharpe ratio and have managed to reform it into a conic problem as such: https://people.stat.sc....
0
votes
0answers
19 views

LSM Python Implementation Undervaluation Problem

I am trying to implement the LSM method in Python. My implementation leads to American put prices lower than those as reported in Table 1 of the Longstaff-Schwartz paper and in some cases they are ...
1
vote
0answers
72 views

Valuing American Options using Tilley algorithm

Hey I want to implement Tilley's algorithm (Valuing American Options in a Path Simulation Model by JA Tilley, 1993) to price american options. Where can I find implementation of this method in any ...
0
votes
0answers
23 views

GET REAL TIME CURRENCY EXCHANGE RATE [duplicate]

I need to get currency exchange rates in real time, every seconds. On websites or when using APIs, the rates are only updated every minutes, or every 30s... Is there any way I can get these datas, ...
0
votes
0answers
24 views

Is is possible to estimate a changing transition matrix in PyKalman?

For a process where a variable in the transition matrix changes with every time sample, can that variable be estimated in PyKalman? I'm trying to replicate Didier Marti's paper (link here) on using a ...
0
votes
0answers
33 views

How to Calculate JDK RS Ratio of a brazilian stock

I'm trying to calculate JDK - RS Ratio using python, however it seems it is not working well. These are some articles that i've found on the internet, concerning JDK RS Ratio: How to calculate the JdK ...
0
votes
1answer
65 views

Bad plots in python, good plots in excel

I am wondering if you could solve the mystery about why matplotlib / seaborn give me a line plot of the IBM stock price, which is terrible as you can see below, with some vertical lines that are of ...
0
votes
1answer
46 views

Calculate DV01 for a vanilla swal for MXN index using quantlib

I am trying to calculate dv01 for a vanilla swap using quantlib. Its a MXN TIIE Swaps for built an index like ...
0
votes
1answer
31 views

AlphaVantage Search Symbol - Brazilian Tickers

I'm trying to find in AlphaVantage Python API the following Brazilian Index, however i didn't find it. IMAT (Materials Brazilian Index) UTIL (Utility Brazilian Index) What i've tried the following: <...
0
votes
0answers
25 views

Multiple independent variables (returns) on common dependent variables (Fama-French risk factors): Efficiency and data structure in Python

As a common topic in factor investing, I wish to implement the well-known Fama-French regressions on several stocks (+2000 IDs). In a deep sense, factor regressions tell how the right hand (returns) ...
0
votes
0answers
62 views

Understanding GARCH

I asked this on stats.stackexchange but I realized this might be a better place to ask this question. I am new to finance and volatility forecasting and am trying to understand how garch model works. ...
2
votes
0answers
187 views

Implementing a Variance Swap Hedging in R

I am trying to compute a hedge for a variance swap, in a simulation. Fo that I am using the following equation:\begin{align*} E^Q\bigg(\sum_{i=1}^n \bigg(\frac{S_{t_{i}}-S_{t_{i-1}}}{S_{t_{i-1}}}\bigg)...
2
votes
1answer
90 views

Error in has.Ad(x) : object 'BRK' not found

I am trying to merge a list of adjusted closes of a multitude of firms for my research on ESG, in relation to risk/reward. None of the firms seem to have a problem, except for the Berkshire Hathaway ...
0
votes
0answers
47 views

Is alpha vantage api for fundamental data reliable?

Can anyone speak to the reliability of the Alpha Vantage (AV) api for fundamental stock data? I have tried for a couple of stocks to get balance sheet data, and it seems close to accurate but I feel ...
1
vote
1answer
102 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 ...
0
votes
1answer
54 views

Pandas rolling mean not working properly [closed]

I have the following dataframe df on which I want to compute a 4-window moving average : ...
0
votes
0answers
58 views

solve.QP in R doesn't give a solution satisfying the constraint

I've dealing with a quadratic programming problem as following, and my objective is to get a 49*1 vector. $$\widehat{\boldsymbol{w}}^{0}(\tau):=\underset{\boldsymbol{w}(\tau) \in \mathbb{W}}{\arg \min ...
0
votes
0answers
37 views

How to backtest using portfolio compositions in python using backtrader

I have a csv file / pandas dataframe which looks like this. It contains various portfolio compositions for different strategies. Mostly based on different optimisation methods, max sharpe, min VaR etc....
0
votes
1answer
90 views

How are the values of the ARMA process linked in python

In the code below, you can see that 'ret' is an ARMA process, and I am trying to see how the ret[0], etc... ret3, ret4, etc. are linked to each other, and although I know the formula for the ARMA ...
0
votes
1answer
98 views

What data should I use for a machine learning model

I would like to ask you for an advice of any of you could help me with this information it would be really helpful. I am trying to build a reinforcement learning trading bot that based on the current ...
6
votes
0answers
130 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 ...
1
vote
0answers
58 views

Is there an alternative to the rugarch package for GARCH modelling?

I have been trying to use the rugarch package but I find it sometimes limiting. After certain amount of data points the package doesn't converge and it becomes kind of annoying. Is there any R/Python/...
0
votes
0answers
34 views

What is the best way to impute missing values for financial data?

I've been tasked with imputing missing values for a dataset of ca. 4000 firms and 225 key metrics (e.g. revenue, net income, EPS, PE etc.). Since I haven't found a thread on here which answers my ...
0
votes
0answers
38 views

Computing the marginal expected shortfall (MES)

I found the following Matlab code to compute the marginal expected shortfall (MES). I understand the code but the mathematical part is not clear to me. More specifically, I don't understand these two ...
0
votes
1answer
46 views

Approach for studying price gaps in US equities

A price gap is defined as any day when the high / low / close price bar for that day does not overlap the previous day’s high / low / close price bar. I am interested in studying stock price gaps ...
0
votes
0answers
34 views

Calibrating Hull-White 2 Factor in Quantlib

I am trying to calibrate Hull White 2 factor model in Quantlib in Python. Since, the Quantlib doesn't have Hull-White 2 Factor, I am using G2(Gaussian 2-Factor Model). Ideally, the interest rates ...
0
votes
0answers
22 views

Backtesting python libraries [duplicate]

Might there be any backtesting libraries in Python that computes the various statistics (Sharpe Ratio, Calmar Ratio, drawdown, win rate etc) given a dataframe of holdings and its holding duration (...
0
votes
1answer
96 views

Simulating several paths of stock prices with Heston Model in R

I am working with a Heston model discretization through truncation, given by the following code: ...
0
votes
0answers
48 views

Is there any method/module/library to directly solve an SDE in python? Especially if it's just geometric brownian motion

Now, I'm given an SDE $$dS_t = 2S_t\,dt + 4 S_t\,dW_t$$ which I need to find the solution of. I have the solution on paper, but I want to know if there's any way I can solve this directly in python. ...
0
votes
0answers
30 views

does anybody know a package for the estimation in python of multivariate garch model? [duplicate]

is there any package in python for the estimation of multivariate garch models? (bekk, dcc) i tried with the package mgarch but it provides only a few commands and wanted to know if there are some ...
0
votes
0answers
25 views

Market Scanner for IBKR API using Python

I'm trying to make a market scanner to search for halted US Stocks using Interactive Brokers python API. I'm currently using the ScannerSubscription library from ibapi.scanner but I can't seem to find ...
0
votes
0answers
97 views

Rebonatos's formula in C++

I'm trying to code in C++ Rebonato's formula for swaption volatilities $$ v_{\alpha,\beta}^2=\frac{1}{T_\alpha} \sum_{i,j=\alpha+1}^{\beta} \frac{w_i(0)w_j(0)F_i(0)F_j(0)}{S_{\alpha\beta}^2(0)}\rho_{i,...
0
votes
0answers
16 views

Backtesting multiple portfolio optimisation and trading strategies using number of stocks to purchase as input

I want to backtest a trading strategy + portfolio optimization but I have never used a backtesting program before. I am comfortable with python I think. My outputs from my trading logic (after ...
1
vote
1answer
39 views

Practice of using parallel programming in numeric libraries

This is a soft, and probably also an opinion based question. Suppose I am writing a library for numeric linear algebra for the purposes of working with financial data. My goals are: Since I work with ...
0
votes
1answer
84 views

Problem with implementing a implied volaitility function in R

I am new to programming, and I have been exposed to the basic of R and Python. I have been trying to implement the volatility smile function using a unit root function(a traditional procedure) but I ...
-1
votes
2answers
82 views

How does trndbot generate buy/sell signals?

I was looking at trndbot and it's buy/sell signals are pretty good - what algorithm are they using to generate these signals? Although it maybe similar to bollinger bands, it algorithmically ...
1
vote
3answers
207 views

How to structure a stock market data database

I would like to download stock market data from the internet (for example by scraping…) and organize them in a database (I am using python and SQL) which updates daily or on request. (The idea is to ...
1
vote
0answers
61 views

Deriving the tangency portfolio with a condition in Python

If there are sister-sites better suited for this question please let me know, I thought this to be the most fitting I have the covariance matrix, the return vector and some scores (ESG scores). The ...
0
votes
1answer
30 views

Not getting coefficient estimates when running a Fama Macbeth Analysis

I am trying to run a Fama Macbeth analysis in R, where I am using the 'pmg' function with the following code: ...
1
vote
1answer
70 views

cvxpy Portfolio Optimization

I am trying to understand which is the best way to construct the parameters using the cvxpy engine. I have seen this post: more of list-like way of constructing constraints etc and this post: more ...
0
votes
0answers
195 views

Nelson-Siegel-Svensson Yield Curve Estimation From Zero-rates Using QuantLib (Python)

I am using QuantLib in Python to estimate yield curves using the Nelson-Siegel-Svensson (NSS) model with zero-rates as input. Since the NSS model in QuantLib uses the discount function to estimate the ...
0
votes
2answers
117 views

Alpha Vantage API time series intraday for foreign stocks into a pandas df

I need to compile stock price data for ADR and ORD pairs (and the currency between them) into a Pandas dataframe. I just started using the Alpha Vantage API for this, which works great for getting the ...
0
votes
1answer
121 views

Second by second stock data from Bloomberg API (or anywhere else that is free) into Pandas Dataframe

I need to compile stock price data for ADR and ORD pairs (and the currency between them) into a Pandas dataframe. My initial plan was use Python's requests library and a free Rapid API account to get ...

1
2 3 4 5
30