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
28 views

Confidence Intervals for ARMA+GARCH forecasts

I have fitted an ARMA(1,1)+GARCH(1,1) model to my logreturns series. When it comes to my standarized error's distribution however, I have opted for a Skewed Generalized Error Distribution, because of ...
1
vote
0answers
48 views

To calculate the Hedge Efficiency and Optimal Hedge Ratio with BEKK in R

I estimated an MGARCH-BEKK model (using the R package BEKK). (BEKK= Baba, Engle, Kraft and Kroner; see Engle and Kroner (1995)) on time series of spot and futures prices. The estimated parameters are: ...
1
vote
1answer
40 views

RQuantlib not returning greeks for options

I do not manage to get Delta/Gamma/Vega/Theta using the simplified AmericanOption function from RQuantLib: ...
2
votes
4answers
113 views

Which rate to use as a risk free rate in emerging markets?

By looking at Fama and Frenchs global Portfolios, they just use the USD-RF rate as the risk free rate, because they converted their Returns to US-Dollar. Im currently estimating Strategy Returns in ...
0
votes
1answer
49 views

LIBOR Market Model implementation in R

Does anyone know an available LIBOR market model implementation in R? It should not be too sophisticated, as this is a smaller task of a larger work. I am rather thinking about a similar ...
4
votes
1answer
218 views

Rolling seasonal and seasonal reversal patterns factor investing

I am trying to create a pattern variable that takes the mean of the same month (lag 12, 24... 240) for the last 20 years and the mean of the other months lag (1-11, 13-23, 25-35... 229-239). (...
1
vote
1answer
69 views

What methods of Data-Screening are necessary before starting an analysis with Thomson Reuters Datastream?

So im currently focussing my research on Momentum-Trading Strategies. I downloaded Constitutents of different All Share indices (including Price, Return index, Market value and Dividend Yield). For ...
1
vote
1answer
108 views

Useful Book for starting to programming quantative Finance [closed]

Could anyone recommend me a good book for an introduction to start programming quantative finance (preferably in R)? I found a lot of different ones, but unfortunately without any reviews.
0
votes
0answers
31 views

Performance Analytics SnailTrail Chart subscript out of bounds error

I am running the chart.SnailTrail function from the PerformanceAnalytics package in r. I get the following subscript out of bounds error. Error in chart.SnailTrail(z, Rf = 0.009261, main = "", : ...
0
votes
0answers
37 views

Why do these Monthly vs. daily plots differ?

I got my data from Thomson Reuters Datastream. As an Input for my plot i calculated daily Returns based on the Return-Index provided by datastream. Then i plotted the Monthly and the daily Returns.(...
0
votes
0answers
33 views

Is this the right way to compute "realized daily market return variance, annualized, over the preceding 126 trading days”?

Realized.Variance<-rollapply((log(Fama.French.daily$Mkt+1)^2) ,126,sum,by=1) So Fama.French.dail$Mkt is my daily Market return. To calculate the realized ...
0
votes
0answers
19 views
0
votes
0answers
28 views

How can i fit the following regression in R? Why is the coefficient [second Columns] for R so low?

'Rwml' is the monthly log return So the first column is clear, I got nearly the same values, at least the same magnitude. But: If I regress on the variance, my input values are way too low to get a ...
0
votes
1answer
52 views

Don't know if it is obvious, but how do I fit the following model in R?

From the Paper "momentum crashes", Daniel and Moskowitz $I_B$ is a dummy Variable which could be either one or zero Is it possible to regress on two intercepts? or do i get something wrong ? Are ...
0
votes
0answers
45 views

Free dividend data API for non-US stocks

Is there are any free API for dividend data that does also include non-US stocks? I know of this question from three years ago. However, the situation has changed since then apparently, as there are ...
0
votes
0answers
19 views

How to forecast monthly volatility with daily gjrGarch estimates

I'm currently writing a paper and need to regress the 22 days realized volatility of the following month on its GARCH estimate and the 126days realized volatility up to t=1 The paper im referring to ...
0
votes
0answers
40 views

Gatheral's SVI implementation in Java/Scala

I am trying to fit equity option implied vols using SVI model in Java, and I am using apache math commons library. Some of the option expiries fit very well, but others are completely off, and I am ...
1
vote
0answers
41 views

Alternatives to irr function in Matlab to calculate internal rate of return

I am trying to calculate an IRR with several dimensions in Matlab 2019a. My formula below works in theory (ignoring the "multiple rates of return" warning for now), but the problem is that for bigger ...
1
vote
0answers
65 views

Small difference in IRR, big difference in NPV?

I calculated the following in Matlab 2019a, see code below. I was surprised about the big difference in present values (DiffPV, DiffPVpercentage) for only a small difference (DiffIRR, ...
0
votes
0answers
41 views

How to work with vine copula in R?

I have returns of 4 stocks: stock1, stock2, stock3, stock4. And I use R and library(VineCopula) to do: ...
0
votes
0answers
31 views

Extreme Value Simulation from Copulas with Monte Carlo

I'm trying to simulate the tail values from a multivariate distribution using copulas. I'm using Vine Copula package of R to derive the suitable copula for my data and I generate random samples out of ...
0
votes
0answers
39 views

Problem in copula fitting

I have returns of 2 stocks: stock1 and stock2. And I want to fit pair copula. I use this libraries library(VineCopula) library(copula) then I select an ...
0
votes
0answers
51 views

API returning company tickers found in provided news article

I'm looking for a REST API (paid or free) that accepts a string containing a news article (example below) as payload and returns an array of company tickers (eg TSLA for Tesla) mentioned in the ...
0
votes
0answers
44 views

What is the model behind Heston-Nandi functions in the fOptions R package?

I am dealing with Heston model in R and for this purpose I am using the package fOptions from RMetrics. The calibration formula requires the specification of some parameters (omega, lamda, alpha, ...
0
votes
0answers
39 views

Tangency portfolio with constraints

Hello to everyone I am trying to implement a version of MV optimization with constraints as UB and LB, it seems to work fine but now i was trying to figure out a simple way to derive a CML in the same ...
0
votes
1answer
45 views

Calculate return for a set of securities downloaded using quantmod

I downloaded adjusted closing price using quantmod for a set of securities. I want to calculate daily/weekly/monthly return for all securities. Usual dailyReturn, weeklyReturn etc not working. What do ...
0
votes
1answer
52 views

How to find sector/industry and market cap for securities in my portfolio using R?

I am working on a project where I need sector/industry classification and market cap for some securities, many of them are not in SP500, but are part of US market. I am using R for this. I don't have ...
0
votes
0answers
38 views

Fit a copula model in R

I want to accomplish the task of creating an optimal portfolio of stocks, the yield between which is modeled using kopulas. And I have data: return of 4 stocks: ...
1
vote
0answers
33 views

Why can't I take the Value at Risk “VaR” as a a risk objective in PerformanceAnalytics? (it does work for "ES)

I am currently playing around with PortfolioAnalytics package in R and some data and I am aiming to create different portfolios with different VaR. However, I am struggling first of all, add.objective(...
1
vote
0answers
28 views

fPortfolio specify our constraints for efficientPortfolio [closed]

I am working on the library fPortfolio in R and I have a question. How can we fix for a portfolio the sum of weights equal to 1 ? When I study the code, I see that we cannot choose which constraints ...
1
vote
0answers
41 views

How to migrate Octave Levenberg-Marquardt algorithm to Accord.Net (C#)

I am trying to migrate Matlab (Octave) Levenberg-Marquardt algorithm to Accord.Net (C#) but struggling to match input parameters For example this simple example available in the documentation here: ...
1
vote
2answers
149 views

How to calculate the Maximum Drawdown for a portfolio in MATLAB?

I would like to verify my approach of calculating the Maximum Drawdown for a portfolio in MATLAB. I've got a vector of returns for the portfolio, to which I add 1 for every return. Afterwards I ...
2
votes
1answer
35 views

Backtesting EGARCH-NIG CVaR in R

I fitted an EGARCH model with a NIG distribution to a series of returns. Using the following link I tried got how I should calculate the CVaR of the model http://r.789695.n4.nabble.com/CVaR-with-NIG-...
1
vote
1answer
82 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://...
1
vote
1answer
240 views

Monte Carlo simulations in Python using quasi random standard normal numbers using sobol sequences gives erroneous values

I am trying to perform Monte Carlo Simulations using quasi random standard normal numbers. I understand that we can use sobol sequences to generate uniform numbers, and then use probability integral ...
0
votes
1answer
63 views

DeMark Indicators

Would anyone know of a library in R that handles DeMarkindicators. Just wanted to check-in with the community before I invested a whole lot of time reinventing the ...
1
vote
2answers
112 views

R: Book with extensive examples for either portfolio optimization or volatility forecasting?

I'm at a new job and there's the option to use R (you don't have to, but I'd like to). I used R years ago, so I while I'm somewhat familiar with it, I have forgotten most of it. For me, the best ...
2
votes
1answer
85 views

Is there a straightforward way to get a “family tree” for a stock?

I would like to find a way to generate what might be called a "family tree" for a stock. Given a stock symbol and a future date, I'd like a graph (either literally or represented in list or other ...
1
vote
0answers
151 views

R Equilibrium FX using VEC or Behavioural Equilibrium Exchange Rate (BEER)

I dont have much experience with R. I would like to do create model for FX Equlibrium using VEC or BEER. I already know what variables I want to use in model: trade differential between UK and the ...
2
votes
1answer
77 views

Efficient computing of stock returns taking dividends into account

I have two DataFrames as follows: Dividends: ...
1
vote
1answer
44 views

Function price output hops around sometimes due to rounding

Say we have a function for estimating the fair price of a security. The function gives outputs rounded to the nearest 0.5 (that is, the raw output is not a rounded float, but can have a decimal part ...
1
vote
0answers
102 views

Pricing Knock Out Barrier Options by solving Black Scholes PDE (MATLAB)

This question is based on MATLAB functions. Suppose there is a stock S following the process $dS_t=(r-q)S_tdt+\sigma(S_t,t)dW_t$ r - risk-free rate, q - dividend yield, W - Weiner process The ...
1
vote
0answers
31 views

RUGARCH (output) and Residual Resampling using GARCH(1,1)

I try to replicate the methodology proposed by Freedman and Peters (1984a, 1984b) which was applied in the famous paper by Brock, Lakonishok and LeBaron (1992) to generate many artificial log return ...
1
vote
1answer
69 views

Need explanation on weird Gamma Behaviour Black Formula

I am using the RQuantlib package to price options on futures. With a slight modification one can go from the Black Model (76) to The BS Model. It can easily be shown that if we write S0 = (e-rt) * F0 ...
5
votes
1answer
222 views

Tick Imbalance Bars - clarification on T index

I have been trying to learn quant related things on my own. I recently picked up a book called "Advances in Financial Machine Learning" by Marcos Lopez De Prado. I am having difficulty understanding ...
4
votes
1answer
98 views

Monte Carlo for Asian Pricing

I'm trying to verify the accuracy of my Monte Carlo method for pricing mean options. I came across this paper that supposedly gives an 'exact' solution for the arithmetic mean option (asian). It's a ...
0
votes
1answer
49 views

How to optimize a series of equations whose outputs are a variable of the subsequent equatinos

The basic question is, given $f(x) = y$ and $f(y) = z$, how can you find $x$ such that $z$ is at its maximum? I can optimize each equation independently, but I do not know how to optimize when ...
0
votes
0answers
22 views

Termstrc data preparation from Bloomberg terminal

I am trying to use the R package termstrc to estimate yield curves for the Czech Republic. I have found the structure of the required class ...
0
votes
0answers
57 views

Get data from Yahoo or google finance

I want to get all data symbols belong to TSX (Toronto Stock Exchange) I have all symbols, but sometimes some symbols do not exist in yahoo finance. Is there any special package for my goal? I use ...
0
votes
1answer
52 views

Advantage to access “non-display data”?

There's data which is hidden from the exchanges called "non-display data"? For a standard stock day trader, is there an advantage to get that type of data? Can I be in the first people to see the big ...