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
1answer
15 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
35 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
77 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
50 views

Pandas rolling mean not working properly

I have the following dataframe df on which I want to compute a 4-window moving average : ...
0
votes
0answers
57 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
30 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
82 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
90 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 ...
4
votes
0answers
93 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
47 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
31 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
37 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
27 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
20 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
85 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
46 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
23 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
95 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
14 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
82 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
70 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
181 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
60 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
29 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: ...
0
votes
1answer
62 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
108 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
90 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
97 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 ...
0
votes
0answers
28 views

Import an external term rates structure in QuantLib

I need to create a Monte Carlo simulation for a Hull-White process. I have the term rates structure already given in a csv, and imported it into Python with the name "rates". However, I have ...
1
vote
2answers
112 views

Replicating momentum strategies (UMD/MOM, SUE and CAR3) in R

I am writing my Master Thesis on momentum strategies including price momentum (UMD/MOM) and two fundamental momentum strategies (SUE and CAR3). Right now I'm trying to create the three momentum ...
0
votes
0answers
50 views

Modeling overnight rates vs Central Bank benchmark using an Ornstein-Uhlenbeck model

I am working in a simple model for the overnight rate for an Latin American country(Chile). Currently the average overnight index trades around the benchmark rate set by the central bank(currently at ...
2
votes
4answers
151 views

Cant replicate minimum variance portfolio variance by simulating many random portfolios in R

I have computed the theoretical minimum variance portfolio using the 30 stocks in the Dow. The formula used is: $$\underset{N\times 1}{\omega_{mvp}}=\frac{\lambda}{2}\cdot \Sigma^{-1}\iota=\frac{\...
1
vote
1answer
69 views

The best approach for screening ATH values for equities

I am trying to automate the trading strategy that I have been previously executing manually. I am having problems with figuring out the most efficient way for a specific step of the strategy. An ...
0
votes
0answers
41 views

What is the difference between np.cov(array) and array.cov()?

I'm trying to find a covariance matrix, so when i use returns.cov() on my returns variable, I get a good result. Unfortunately, when i want to use ...
1
vote
0answers
43 views

Extracting implied dividends from American options

I am using end of day options data and want to extract discrete dividend information contained in the option prices. I am doing this for ETFs like SPY where I know the dividend schedule. These are the ...
1
vote
0answers
43 views

MatLab code does not work for Heston model calibration

I am trying to calibrate Heston model on some data and I have the following code. Code is supposed, after it reads the data, to give back 5 parameters. However, I get an empty answer from MatLab. Does ...
0
votes
1answer
76 views

QuantLib Python: how to calculate duration and convexity for irregular cashflows? Can I use SimpleCashFlow or must I define a custom bond?

I have 2 questions: If I want to discount a set of irregular cashflows, I can do it using the SimpleCashFlow class, or defining a bond with custom cashflows (thank you to Ballabio and David Duarte for ...
0
votes
0answers
26 views

Whitespace in Option Symbols

A while ago exchange-traded option symbols migrated to a 21-character descriptor, formalized by the Options Clearing Corporation (OCC), consisting of: 7 characters: root or underlying symbol 6 ...
1
vote
0answers
67 views

Heston Model Calibration with MatLab: model prices do not fall in the bid-ask range

I am currently implementing the MatLab code reported below for the calibration of Heston Model. The code seems fine and, by reading the paper where I took the code, I was able to calibrate and price ...
0
votes
1answer
54 views

QuantLib Python: why is the NPV different? NPV(0.1,[0,110]) should be 100, not 99.53

I am trying to learn QuantLib for Python. Further to my previous question on the syntax for CashFlows.npv(), now that I understand how the syntax works, I have a question on why the output differs ...
0
votes
2answers
58 views

QuantLib Python: how to calculate the npv of irregular cashflows?

I am trying to learn QuantLib for Python but I must say I am banging my head against the documentation (I also bought Ballabio's python cookbook) - maybe it's me, but even finding the most basic ...
0
votes
1answer
80 views

Converting pandas datetime to QuantLib dates: why do the inputs need to be converted to int only some times? It seems random

I am trying to use the QuantLib library with Python. In the example below, I create a pandas dataframe with some dates and some cashflows, convert the dates from pandas' format to QuantLib's, and use ...
0
votes
0answers
34 views

Generate random timeseries in Python

I'm trying to test a particular trading strategy under different assumptions and would like to do so on different random time series. I would like to be able to specify the following: Start price End ...
1
vote
1answer
83 views

Python library for tick-based backtesting on cryptos

I saw and reviewed many python backtesting libraries - pyalgotrade, zipline, catalyst, backtrader, etc. It seems that none of the provide a straightforward way to perform "Tick-based or Multi-...
1
vote
1answer
124 views

Option pricing using discrete fourier transform (python)

I am trying to implement the pricing formula for a European (call) option given in Ales Cerny's paper "Introduction to Fast Fourier Transform in Finance" (paper can be found here), as ...
0
votes
1answer
107 views

BQL Question [New to BQL and programming in general]

I have this BQL query to grab a list of Russell 3000 members and get the firm names. Is there any way I can grab other data with the company names such as industry/sector name, total assets, EPS, etc.....
0
votes
0answers
34 views

Fundamentals for German and Austrian companies (look for an API)

I am looking for an API to import fundamentals for German and Austrian companies either via Python or in R. The data shall cover the usual metrics like from Datastream or Bloomberg (e.g Gross Margin (...

1
2 3 4 5
30