We’re rewarding the question askers & reputations are being recalculated! Read more.

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

How to calculate YTW (yield-to-worst) in QuantLib?

After defining a CallableFixedRateBond object in QuantLib, I can calculate YTM (yield-to-maturity) right now. I'm using Python so the function is bondYield(). Is there any way to calculate YTW (yield-...
1
vote
0answers
36 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 ...
3
votes
1answer
1k views

FX Option strikes from ATM, RR, BF quotes

I am trying to replicate the results in Consistent Pricing of FX Options, A. Castagna and F. Mercurio. However, when I calculate the strike prices for 25-delta put and call and ATM I cannot get the ...
1
vote
0answers
48 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
83 views

Extend mean-variance optimisation to fama five factor

I'm new to quant finance, and as I'm not a mathematician, I am using python to try an understand it. There are a number of blogs on the internet which explain mean variance optimisation, but no-one ...
1
vote
0answers
29 views

How do I calculate from discountfactor to zerorate in Python using Quantlib [closed]

I knew rate to discountfactor InterestRate.discountFactor(yearFraction) I want to calculation discountfactor to zerorate
2
votes
1answer
80 views
0
votes
1answer
67 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 ...
0
votes
1answer
141 views

Dealing with weekends/gaps in financial data

My script takes some data from IEX and then outputs a pandas dataframe: ...
4
votes
4answers
5k views

List of Intraday stock prices API

I am looking for an API to request intraday data for the London stock exchange. I have seen products like eSignal but this seems to include a lot more than the simple data as XML or JSON and is fairly ...
1
vote
2answers
116 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
179 views

Can someone confirm if I am correct about these numbers on companies' financial documents?

I am looking to implement Piotroski's F-score Value strategy discussed in the paper "Piotroski, J. D. (2000). Value investing: The use of historical financial statement information to separate winners ...
3
votes
4answers
5k views

Place to get free live Forex quotes via API?

Are any free Forex data APIs available? There are a ton of historical data repositories that are freely available but what about a live, streaming data API? 1 minute updates or tick data would be ...
1
vote
0answers
29 views

TWS API Python_Remaining Positions [closed]

I am trying to get the number of filled/remaining positions using the function orderStatus() under EWrapper class. I tried something like, print(p.orderStatus(orderId=6, filled)), which didn't work. ...
1
vote
0answers
252 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 ...
3
votes
0answers
194 views

rugarch and rolling estimation

I use Rugarch for a long time in order to calibrate GARCH models on FX rates time series and perform simulations. I am trying to understand the ugarchroll method. However even if I can find plenty of ...
0
votes
4answers
1k views

Where to find sample intraday data? One to two days or more

I'm looking for some intraday stock data. Doesn't really matter what kind of security... I'm just looking for price, volume, bid, and ask. I'm looking to test a model based on the dynamics and ...
0
votes
3answers
170 views

Combining Quantitative data with fundamental data

These day, there is relatively new phenomena of combining quantitative data and fundamental data called 'Quantamentals'. In this regards, I was wondering how to combine Four Essential Types of ...
1
vote
1answer
45 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
135 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
35 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
74 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 ...
1
vote
0answers
370 views

Calibration of Theta, A(t) and B(t) of Hull White 1Factor model

I’m simulating interest rates via the HullWhite One factor model. To simulate the short rate I’m using the code from the Quantlib Python Cookbook, chapter 15 and beyond (By Goutham Balaraman and Luigi ...
1
vote
2answers
479 views

CDS ISDA model/Bloomberg

I am becoming more acquainted with QuantLib as a platform. I've been using both the python implementation and QuantLib XL. As I have started to look at CDS, I would like to know if there is a ...
2
votes
1answer
686 views

Quantlib-Python: use zero rates to get the originally bootstrapped curve

Let's say I am trying to build a curve using deposits, future and swaps with one of the three Quantlib methods in Python as below: ...
1
vote
1answer
78 views

Calculating QuantLib IborCoupon with / from given index fixing

How can I calc with QuantLib the coupon amount of a floating rate IborCoupon on the 3M Euribor Index with a given 3M Euribor Index Fixing? If I try the following Python code: ...
12
votes
2answers
3k views

robust portfolio optimization re-balancing with transaction costs

The optimal re-balancing strategy takes account of factors including i) objective function, ii) current portfolio weights, iii) expected return vector containing updated views/alpha forecasts, iv) ...
1
vote
0answers
101 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 ...
5
votes
1answer
319 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
104 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 ...
4
votes
3answers
196 views

Data sources to get past news articles

Are there data sources from which we could get news articles from the last 2 years? I tried reuters but they had data spanning back to just 3 months. Any suggestion/pointers are appreciated
0
votes
1answer
53 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
24 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 ...
29
votes
4answers
21k views

How to derive the implied probability distribution from B-S volatilities?

The general problem I have is visualization of the implied distribution of returns of a currency pair. I usually use QQplots for historical returns, so for example versus the normal distribution: ...
2
votes
1answer
716 views

How to implement the herding measure proposed by Lakonishok et. al (1992) in python

I would like to test for herding behaviour using the herding measure developed by Lakonishok et. al (1992) on a dataset containing trader transactions during 2013, however, i am having some trouble ...
3
votes
2answers
753 views

C# - Using Black Scholes Newton returns NaN occasionally

First caveat: I'm a programmer doing this for a client, and my knowledge of options probably has holes in it. So be a little forgiving here. =) The Issue: When I run Black Scholes Newton against ...
1
vote
1answer
98 views

Objective function: as close to equal weight as possible

I am having trouble coming up with a function to optimize the weights to be as equal as possible. It is a long-short portfolio with 6 positions weights is a cvx variable: [long, long, short, short, ...
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 ...
2
votes
0answers
84 views

Constraints for a Long-Short Mean Variance Objective Function

Problem: I am trying to set up constraints for a long/short mean variance optimization problem. My constraints include: beta neutrality cash neutrality equality constraints on categories: <...
1
vote
1answer
352 views

python scipy optimize minimize arguments for Implied Volatility

I am having some trouble getting the 'correct' solution to a function where I am trying to utilize scipy.optimize.minimize. In the code below, I create a function <...
3
votes
1answer
2k views

Programmatically detect RSI divergence

How can I programmatically detect bullish and bearish RSI divergences? A bullish divergence occurs when the underlying security makes a lower low and RSI forms a higher low. RSI does not confirm the ...
1
vote
0answers
58 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 ...
0
votes
0answers
446 views

How can I export intraday stock data into CSV from Interactive Broker or Yahoo Finance?

Google Finance API seems to be down forever. Are there instructions or manuals for downloading intraday stock data into CSV files from Interactive Broker OR Yahoo Finance?
0
votes
0answers
157 views

John Ehlers - Forward Reverse EMA indicator calculation in pandas

I found a lot of translations of the John Ehlers - Forward Reverse EMA indicator in different specifics language (TRADESTATION, METASTOCK, ESIGNAL, WEALTH-LAB, AMIBROKER, NEUROSHELL TRADER, ...
2
votes
1answer
189 views

Stateful Technical Analysis Indicator Libray For Python

I an looking for a TA indicator library in python, that offers indicators you can update with ticks, in contrast to indicators that perform calculations on an entire data set. For example, an RSI ...
2
votes
3answers
448 views

Efficient frontier doesn't look good

Hi I'm trying to draw an efficient frontier. Below is what I used. returns parameter consists of 9 column returns of portfolio. I selected 10,000 portfolios and this is how my efficient frontier ...
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 ...
-1
votes
4answers
1k views

How to download bloomberg intraday data efficiently with API

so I would download a bunch of intraday data, for a bunch of securities, but we keep hitting our monthly cap limit. We don't want to upgrade to a more expensive package as this is simply a research ...