Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
36 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
34 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
0answers
17 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
28 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
31 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
27 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
23 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
29 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
76 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
0answers
17 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
0answers
38 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
89 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
53 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
103 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 ...
1
vote
1answer
78 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
73 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 ...
1
vote
1answer
70 views

Efficient computing of stock returns taking dividends into account

I have two DataFrames as follows: Dividends: ...
1
vote
1answer
40 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
68 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
20 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
64 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
99 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
87 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
45 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
17 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
53 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
48 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 ...
2
votes
0answers
31 views

Mixed-Frequency VAR -packages

My intention is to retrieve forecast error variance decomposition from a MF-VAR with no latent processes following Ghysels (2012) https://www.hec.ca/finance/seminaires/Ghysels.pdf I found the ...
1
vote
1answer
70 views

How can I calculate the amount of volume to use to ensure highest profit on an arbitrage trade of two Constant Product Market Making exchanges? [closed]

If there exists an arbitrage opportunity between two Constant Product Market Making exchanges, how can you confidently determine the maximum volume to use in order to ensure highest profit? I can ...
3
votes
3answers
155 views

Are there recommended books/readings for advanced option pricing

I am learning option pricing and derivative markets this year in class. I have had some background on stochastic calculus so it was relatively manageable for me to write vanilla and American option ...
1
vote
0answers
28 views

Fractional cointegration in R

I'm looking for a package (or some code that anyone has written) that will help me to estimate a VECM for fractionally cointegrated series. I.e. like the ca.jo ...
1
vote
0answers
47 views

How to find the tangency portfolio using quadprog in R with different risk free rates

I am trying to find the optimal tangency portfolio for the efficient frontier (calculated using qp.solver in quadprog) but subject to different risk-free rates. Demos for quadprog in R show that to ...
2
votes
2answers
79 views

Group name for currencies, equities and other financial products

I am working on a financial software system that deals with crypto currencies. This system has a model called 'Currency' that describes for example 'BTC' and market for which there is a 'base' and '...
3
votes
1answer
60 views
2
votes
0answers
58 views

Backtesting :: Migration to Simulated / Real-Time Trading

I am relatively new to backtesting and I want to migrate my system to simulated trading via Amibrokers Interactive Broker's API. What I have been doing is setting trade delays such that when a Buy or ...
1
vote
0answers
52 views

Error in QuantLib-Python when I use function “Bond”

I am using the "Bond" function in QuantLib-Python 1.14. I am planning to use it in this way: ...
2
votes
1answer
61 views

(R-studio) Incorporating overnight returns in high-frequency data

Turning here since I haven't been able to find any help online. I'm currently dealing with a high-frequency data set in R of some stock indicies and I'm currently trying to clean the data so that I ...
3
votes
1answer
111 views

Residuals Fama MacBeth Regression

I am still asking myself what the pricing error terms in the Fama-MacBeth regression are. Are they the intercept I regress across all assets in each month, once? Or are they the residuals of each ...
2
votes
1answer
154 views

After hours data - Interactive Brokers

I just started using Interactive Brokers because of their API. I'm using the IBrokers package in R. I've managed to get data for S&P 500 and other indices but now I want data for S&P 500 after ...
3
votes
0answers
90 views

Detecting leading stocks using lag correlation

I am working on a project to find leading stocks in a stock market by using lag correlation. Say I want to compare 2 stocks, X and Y, and I have the time series of stock prices. Assume that the ...
3
votes
0answers
72 views

Is there a more efficient data structure to implement binomial trees than 2d array?

I'm just curious what is the "industry standard" for implementing a binomial tree (if "standards" exist in this case). For simplicity, let's just talk about the simplest trees with recombining nodes. ...
1
vote
1answer
127 views

Is studying R quantstrat worth the effort for an individual trader? [closed]

I see at least two problems. The R package quantstrat is poorly documented. And one must have dividends adjusted data. Otherwise the test results will be irrelevant.
7
votes
0answers
100 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}\...
1
vote
0answers
32 views

Value function does not converge when applying the general value iteration adaptive dynamic programming [closed]

Recently,I am trying to control a marco traffic system with the general value iteration adaptive dynamic programming algorithm.However,the results do not reach my expectation. Here is the pseudo code:...
1
vote
0answers
27 views

Getbars for matured interest rate products

Using the getbars function from rblpapi package. Can you extract intraday data for a matured interest rate product? For example a German bubill The function works for interest rate products that are ...
0
votes
1answer
106 views

Interactive brokers historical data availability

I'm considering Interactive Brokers because of the IBrokers package for R. On this site there is a small section on data availability and I'm having a hard time understanding the table. Lets say I ...
1
vote
0answers
107 views

Python book on derivative pricing

Are there any books that show how to price exotic options in Python with monte carlo methods? I am aware of two books by Yves Hilpisch, but in his books there are only simple options. I am struggling ...
1
vote
1answer
72 views

Calculate New Portfolio Weights Given Today's Returns

I'm looking for a formula to recalculate my portfolio's weights at the end of time $T$, given a vector of the asset weights at $T$ and a vector of returns at $T$. For example: ...
2
votes
1answer
106 views

Merton's Jump diffusion model: Specify poisson rate

Currently applying the Merton's jump diffusion to test how Option price change as parameters change. However, I am struggling to specify the poisson rate $\lambda$. We know that: $P(\text{There is a ...
-2
votes
1answer
195 views

Is R suited for a Quantitative Finance executable application

I wonder if a R-Shiny application works well for a production environment or the only option is C++. I make this question taking in account that R and C++ have a widely set of quant libraries that ...