Questions tagged [python]

Python is a dynamically and strongly typed programming language whose design philosophy emphasizes code readability. Two significantly different versions of Python (2 and 3) are in use. Please mention the version that you are using when asking a question about Python.

0
votes
0answers
37 views

Why doesn't tenor of Euribor index change spot rate in Quantlib?

I'm trying to create a yield curve in QuantLib based on swap rates. The swap rates I'm using have a 6 months fixed frequency and a 3 month float frequency based on LIBOR. What I don't understand is ...
0
votes
0answers
38 views

Zero rate computation in Quantlib [on hold]

I am trying following code, zerorates which is received is different than I expect. Can someone suggest where am I going wrong? ...
0
votes
1answer
54 views

How to programmatically define financial leverage?

Financial leverage could be easily described as the tool that allows traders to multiply returns at the cost of multiplying also the risk involved in every trade. So, for instance, if a stock today ...
1
vote
1answer
63 views

How to use both yield curve and discount curve to value call in QuantLib

I'm new to QuantLib, and I'm trying value a simple European call. QuantLib's Black-Scholes-Merton Process makes sense to me, but I don't know how to incorporate a discount curve into it. Please see ...
1
vote
1answer
74 views

suggestions for improving monitoring of trading bots?

I'm simply looking for tips and ideas to make my system a little more professional. The structure: The botting script is hosted on a VPS. There's a database hosted on yet another VPS. There's a ...
5
votes
2answers
421 views

Random Portfolios vs Efficient Frontier

I understand the concept of the efficient frontier and am able to calculate it in Python. But even when generating 50'000 random 10 asset portfolios, the single portfolios are not even close to the ...
1
vote
0answers
30 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 ...
1
vote
1answer
57 views

Python Numpy FFT array size limit?

I am trying to find the price of an Option based on the fft technique within the binomial model and it works fine until N>40000 where I start getting negative values and weird convergene and I am not ...
0
votes
3answers
68 views

Python libraries for Monte Carlo simulations?

I am learning about monte carlo simulations and I have found many blogs explaining its implementation in python. Because its a widely known and an important technique for structuring asset prices. I ...
3
votes
0answers
74 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
22 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
1
vote
2answers
63 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 ...
2
votes
1answer
190 views

What are some beginner quantitative option trading strategies?

I'm new to quantitative trading, with good knowledge in finance and coding (mainly Python, Java, R, etc). I would like to know if there are any basic quantitative option trading strategies that can ...
1
vote
1answer
123 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 ...
2
votes
2answers
283 views

Local Volatility calculation in Python

I am trying to price Local Volatility in Python using Dupire (Finite Difference Method). I have following set of information Spot: 770.05, Strike: 850, Type: 'C', rfr: 0.0066, time to maturity = ...
1
vote
0answers
24 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
1answer
115 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 ...
4
votes
0answers
70 views

Numerical simulation of Heston model

I am trying to simulate on Python random paths for a general asset price as described by the Heston model: \begin{equation} \begin{aligned} dS_t &= \mu S_t dt + \sqrt{\nu_t} S_t dW^S_t \\ d\nu_t &...
1
vote
1answer
72 views

Efficient computing of stock returns taking dividends into account

I have two DataFrames as follows: Dividends: ...
1
vote
0answers
150 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 ...
0
votes
2answers
195 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
297 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
50 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: ...
1
vote
1answer
89 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, ...
2
votes
0answers
53 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
203 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 <...
1
vote
0answers
49 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
83 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
81 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 ...
1
vote
3answers
284 views

Regularizers to compute Minimum Variance Portfolio weights

I need to compute the mimimum variance portfolio using different regularizers, to compare the results and use validation methods to find the optimal parameters. Currently my work has been performed ...
1
vote
1answer
79 views

Compare portfolio variance using different regularizers

I'm given a question like below. Using the 48_Industry_Portfolios_daily dataset: characterize/describe the dataset and focus on the global minimum variance portfolio. Compare the portfolio variance ...
4
votes
1answer
338 views

Optimal Portfolio from Efficient Frontier

I found this code on plotly site, using CVXOPT to find the efficient frontier, and then, the optimal Portfolio. The optimal function is ...
0
votes
0answers
51 views

QuantLib FuturesRateHelper how do I input Future type = 'ASX', the 'IMM' date check is causing Runtime Error

How do I input Future type = 'ASX', the 'IMM' date check is causing Runtime Error future_maturities 1 2019-06-14 2 2019-09-13 3 2019-12-13 4 2020-03-13 5 2020-06-12 6 2020-09-11 ...
2
votes
3answers
356 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 ...
3
votes
1answer
81 views

forward + displacement

I I am trying to price a cap/floor using Quantlib in Python. the initial code from from this website: http://gouthamanbalaraman.com/blog/interest-rate-cap-floor-valuation-quantlib-python.html Here is ...
5
votes
2answers
189 views

Estimation of Risk-Neutral Densities Using Positive Convolution Approximation - Python

I'm trying to estimate the risk-neutral density through positive convolution approximation (introduced by Bondarenko 2002: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=375781). I'm currently ...
1
vote
1answer
88 views

How to take back-tested code and convert it to forward-testing code? (in Python)

How do you take back-tested code written using the zipline API and convert that into forward-testing code using the IB API (or better yet ib-insync API)? It seems like you would have to completely re-...
3
votes
1answer
88 views

Errors on Finite Differences + Implicit Scheme + Black & Scholes

I'm solving the classical Black & Scholes (BS) PDE for a European option using finite difference and the implicit scheme. In other words, I'm trying to solve $\displaystyle\frac{\partial V}{\...
1
vote
0answers
73 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 ...
4
votes
0answers
242 views

Understanding and simulating the jumps in Merton's Jump-Diffusion SDE?

I found this great post deriving the solution to the Merton Jump-Diffusion SDE $$S_t = S_0\exp\left(\left(\mu - \frac{\sigma^2}{2}\right)t + \sigma W_t\right)\prod_{j=0}^{N_t}V_j$$ The first part of ...
2
votes
0answers
45 views

SquareRootProcess in QuantLib - Python

I would like to price an American put option using the SquareRootProcess class in QuantLib - Python but it seems that it does not exist. As the underlying follows the following model : $$\rm{d}S_t=...
1
vote
0answers
83 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 ...
2
votes
0answers
95 views

Binomial Model Implementation Trouble - American and European options come out equal

I'm Trying to implement the binomial option price model in python and get reasonable performance by using memoization. I checked the output against a black and scholes model and for European options ...
0
votes
0answers
156 views

Rolling forecast using GARCH model

EDIT This is not a duplicate of my original question linked, since I have since overcome that problem and have posted an answer. Since solving the previous problem, I have run into the problem ...
1
vote
0answers
27 views

Drop NaN in a for loop for each column [closed]

I will try to explain my problem. So I have two DataFrames , Df1 and Df2. Each of them has 3 columns and 4 rows. I will solve a quadratic functions with np.polyfit. ...
1
vote
0answers
80 views

Machine Learnign for Factor Model python [closed]

I have read several articles about Factor Model using Deep Learning or machine learning, but none of them post the code. Where can I find the python code for anything similar?
1
vote
1answer
213 views

Is this the correct way to forecast stock price volatility using GARCH

I am attempting to make a forecast of a stock's volatility some time into the future (say 90 days). It seems that GARCH is a traditionally used model for this. I have implemented this below using ...
1
vote
0answers
127 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 ...
-2
votes
2answers
314 views

Least-Squares-Monte-Carlo by Neural Network Estimator for pricing American Option Python [closed]

First I did the LSM (Longstaff-Schwartz) to understand how its work to price an American option. code for standard_normal ...
2
votes
0answers
84 views

QuantLib - Synthetic deposit/FRA rates in yield curve

In my flat forwards dollar curve implemented in QuantLib I would like to add the following instrument: Today is 12/28/2018 Pillar quote is 1% p.a. (ACT/360) Pillar start is 1/30/2019 (specific ...