# 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.

450 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1 vote
297 views

### $n$-day ahead forecast for asymmetric DCC-GARCH model

I am working on forecasting covariances with the use of MGARCH models. I was wondering if anyone knows how to implement a n-day ahead forecast of the aDCC (asymmetric DCC) model in R. The ...
1 vote
128 views

### Maximum Sharpe ratio portfolio - derivation

I want mathematical derivation of how to construct maximum Sharpe ratio portfolio. Any resources with mathematical derivation (if its implemented in Python, that will be great) will be useful
• 11
1 vote
107 views

### What is a call-spread and its formula?

I am attempting Mark Joshi's The Concepts and Practice of Mathematical Finance. In B.3 Project 1: Vanilla options in a Black-Scholes world, he asked the following question. We need to be sure that ...
• 840
1 vote
265 views

### Pnl Explanation using R (blotter)

I have a portfolio of stocks based on a proprietary strategy. I would like to explain the Pnl over a period, for example I would like to find the pnl contribution of each name of the period. Is there ...
• 171
1 vote
287 views

### quantlib isda cds time-series

I am trying to use quantlib from python to work with time series of cds quote, e.g I would like to evaluate the PV or PUF or other metrics on many different days. Each day has an associated yield ...
1 vote
123 views

### Using news to predict Stock Prices dataset

In order to build Regression or Deep Learning models for predicting the market, we need a bunch of historical data. Prices and technical indicators are easily accessible, but getting news from the ...
1 vote
2k views

### I am getting an Invalid API call from Alpha Vantage TIME_SERIES_DAILY_ADJUSTED for Mexico or Toronto Stocks (with a period). Why?

I have used the following: https://www.alphavantage.co/query?function=SYMBOL_SEARCH&keywords=URBI&apikey=nnnnnnnnn I get back this: ...
• 11
1 vote
118 views

### How to correctly simulate volatility shocks?

I am working on the comparison of different volatility timing/target strategies on portfolios starting from different conditions (data, asset classes, calculation of realized volatility, different ...
• 41
1 vote
162 views

### Annualizing Sharpe Ratio using small time frames

I have coded a strategy that works 5m time frame. I know you multiply it by 252 but i am using 5m or sometimes 1h time frame. Which number do i have to chose to multiply? There are 72576 five minutes ...
• 139
1 vote
141 views

### Bloomberg C# / CS.NET SDK for STDY Functions

I have downloaded and installed the CS.NET SDK from STDY. I have installed this as admin and had no problems with the install. However, when I open VS2017 (last version supported by BBG) I do not see ...
• 2,272
1 vote
80 views

### Why don't these betas match?

I am sure I am missing something simple, but I would expect my portfolio beta when regressed against the market to match my individual component betas multiplied by the portfolio weights. I have ...
• 165
1 vote
189 views

### Walk Forward Analysis Using Portfolio Analytics R

I am learning how to use the Portfolio Analytics package in R and I am concerned with overfitting the data for the optimization. The optimize.portfolio.rebalancing() function has 2 parameters that ...
• 181
1 vote
471 views

### Quantlib Python OISRateHelper using Quantlib Cookbook - hands on Quant Finance

I am completely new to Python, just trying to reference Quantlib Cookbook to construct eonia curve, here is my code. I didn't change much compared to the cookbook Eonia Curve BootStrapping chapter, ...
• 11
1 vote
118 views

### How does the mean interest rate of a loan shift over time?

I have a loan dataset (300MB) that comes from the Lending Club and I would like to know how has the average interest rate of a loan varied over time. I have the int_rate column but I'm not familiar ...
1 vote
41 views

### How to check if the people segmentation based on prime and sub prime loans is accurate?

Using Lending Club dataset I have a dataframe with characteristics of loans of some borrowers. Here is their distribution of the sub-grades: ...
1 vote
114 views

### Framework for analyzing transaction history

After many years of being discretionary trader I'm finally moving to systematized trading. I have all the transaction history from my broker I want to be the basis of my models. Is there a framework ...
• 161
1 vote
521 views

### Matching the yield on a bond with the zeroRate on a curve in Quantlib

I am using QuantLib to generate a US Treasury curve from 1y, 3y, 5y, and 10y yield quotes. However, after building the curve and running zeroRate on it, it ...
1 vote
283 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 ...
• 133
1 vote
74 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, ...
• 133
1 vote
74 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 ...
• 382
1 vote
210 views

### How to apply multiplicative price seasonality to bond prices in quantlib?

Can someone please give a brief or any link which explains how to apply multiplicative price seasonality to inflation linked bonds in Quantlib using python modules. Have gone through most of the ...
• 111
1 vote
73 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(...
• 11
1 vote
281 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: ...
• 113
1 vote
629 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 ...
• 127
1 vote
768 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 ...
• 11
1 vote
263 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 ...
• 11
1 vote
186 views

### Is it Possible to replicate SPAN?

I currently trade intraday Options on the nearest term expiry and futures. Both E-mini S&P. I am trying to replicate the SPAN margin calculation for the entire portfolio of options and futures. So ...
1 vote
121 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
265 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 ...
• 25
1 vote
220 views

### Derivative of the stock price and volume at time t

According to Forecasting of Jump Arrivals in Stock Prices: New Attention-based Network Architecture using Limit Order Book Data at page 9, I would be interested in deriving the the price (ask and bid ...
• 329
1 vote
209 views

### Holding Period Return abnormally high

I've been doing my Dissertation and I was told to create a value - weighted portfolio on the 1979's 200 largest cap corporations (based on Market Value). I was also told that the correct way to build ...
1 vote
45 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 ...
1 vote
485 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
759 views

### Poor results forecasting stock price volatility using Python's GARCH model

As far as I understand, forecasting stock price volatility should be more achievable than forecasting absolute prices or returns. It seems as though GARCH models are the traditional and most widely ...
• 193
1 vote
214 views

### Issue with chart.RiskReturnScatter in performance analytics, need finite 'ylim' values error

I am currently trying to create a Risk Return Scatter plot using the following code ...
• 11
1 vote
156 views

### Time series analysis for stock prices

I am using GARCH model to simulate price of an index for 7 years. For input I am using difference of Log of prices (log of return). GARCH(1,1) has the lowest AIC, and I found parameters for the ...
• 11
1 vote
339 views

### Convertible bonds pricer - implementation

Where I can find numerical implementation (in any programming language) of convertible bonds pricer based on the following article: E. Ayache, P. A. Forsyth, K. R. Vetzal, "The Valuation of ...
• 83
1 vote
108 views

### VaR calculation using excel gives different value than VaR using R at all c values except at c=0.5

This is VaR calculation in excel using variance-covariance method. This is VaR calculation in R. ...
1 vote
70 views

### Is my coding for my kalman filter off when testing this specific set of pairs?

My kalman filter seems to be off for this specific set of pairs I'm looking at. As you can see, in the kalman filtered linear regression, there seems to be an outlying blue line nowhere near the data ...
• 11
1 vote
24 views

### Simulating Taxed Equity Return Series (U.S.)

I'm looking to learn how to correctly simulate taxes on dividends and capital gains on simulated return series for U.S. Equities with dividend reinvestment. I understand I will have to keep track of ...
• 1,641
1 vote
43 views

### Finding the distribution and moments of returns with GARCH models (in R if possible)

I understand the GARCH type models and I know how to fit a model to a time series. But, there is a paper which calculates the moments of the distribution of returns (Variance, Skewness, and Kurtosis) ...
• 155
1 vote
182 views

### European Call Option Modelling under 2 factor Hull White interest rates

I have modelled the yield curve through the two factor Hull White Model. Now I want to implement in Matlab the price development of a ATM-Call-Option (European). Has someone an idea how to combine ...
• 33
1 vote
35 views

### Trading Platform APIs which support editing holdings

I am developing a tool to assist human traders using a trading platform. For testing, I was wondering if anyone was aware of any trading platforms which support editing the holdings of a paper account....
• 111
1 vote
66 views

### Trouble calculating the Dow Jones Industrial Average

I can successfully calculate the Dow Jones closing price by taking the sum of closing prices of the 30 component companies. However, using this same method, I'm unable to calculate the correct opening ...
• 111
1 vote
339 views

### Mean Variance Optimization of 2000 pairs of securities (Python)

I would like to take the opportunity to ask for your help on an assignment I'm trying to complete. For this 'Modern Robo Advisory' course we are asked to solve a (target) goal-based investment ...
• 31
1 vote
193 views

### How to debug Example_1 of the Open Risk Engine (ORE) library?

Following the manual, I have built an Open Risk Engine library and I would like to learn the library by modifying examples that come together with the library. Question: How to run, for instance, <...
• 23
1 vote
486 views

### QuantLib in Python, are there any existing methods to handle the options delta on expiration day?

Tried [ql.Settings.instance().includeReferenceDateEvents = True] and it works for the calculation of NPV using intrinsic value of the option. But Delta is nan for an in-the-money option. I understand ...
• 11
1 vote
296 views

### Open Source library for calculating exposures?

I would like to know an open source quantitative library/ies that can calculate exposures out of the box (I have investigated a bit on OpenGamma/Strata libraries with no luck and the website of ...
• 23
1 vote