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 [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
1answer
25 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
46 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
43 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 ...
-1
votes
0answers
25 views

Help!! how can do i compute bond price with YTM in python? [on hold]

Given FV = 1000 coupon rate = [0.01, 0.015, 0.023, 0.038] ytm = [0.016, 0.021, 0.045, 0.065]
1
vote
0answers
33 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
21 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
83 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
61 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 &...
0
votes
0answers
8 views

How to plot the last values of a dataframe on boxplot? [migrated]

I have a 2*4 box plot, each contains 21 boxes. For each of them, I would like to plot the last value of each dataframe column. A closer look at one of them: ...
1
vote
1answer
56 views

Efficient computing of stock returns taking dividends into account

I have two DataFrames as follows: Dividends: ...
1
vote
0answers
38 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 ...
-3
votes
0answers
27 views

Adding argument to ERC function in Python makes it break down

I am using xlwings to implement Python code in Excel. I put the following code in Spyder and imported it into Excel to arrive at equal risk contribution weights for a 7-asset portfolio. ...
0
votes
2answers
117 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
212 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
30 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
82 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
46 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
108 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
48 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
47 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
50 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
2answers
235 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
74 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
238 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
36 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
325 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
67 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
170 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
76 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
79 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
69 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
107 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
42 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
80 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
63 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
69 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
22 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
62 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?
0
votes
0answers
38 views

What volatility to use to estimate BDT?

I am attempting to estimate the value of a bond with prepayment option (callable bond). In order to do so, I am fitting a lattice to the Libor Swap curve using a BDT model. The measurement date is ...
1
vote
1answer
113 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
102 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 ...
0
votes
2answers
233 views

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

First I did the LSM (Longstaff-Schwartz) to understand how its work to price an American option. code for standard_normal ...
2
votes
0answers
57 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 ...
1
vote
1answer
157 views

Crossing the spread as a ML signal

In the optic of high-frequency trading, most of the standard trading algorithms work on the principle of mid-price prediction or mid-price movement prediction. However a big drawback of this technique ...
1
vote
1answer
89 views

How to go about computing RSI?

I've written python code that I believe computes RSI. I wrote the code based on what I saw in stockcharts.com found here Here is the code: ...
3
votes
3answers
328 views

Compute tangency portfolio with asset allocation constraints

I am looking to compute the tangency portfolio of the efficient frontier, but taking into account min_allocations and ...
-2
votes
4answers
110 views

Sending order to Forex or Stocks from Python strategy

I have my own strategy developed in Python. But I couldn't find a reliable method to send, close, and modify orders using Python. Are there any tools that help order management using Python? I also ...
1
vote
0answers
86 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 ...
0
votes
1answer
554 views

Python package for option pricing models?

Is there a good python package for various option pricing models, e.g., Heston, SABR, etc? I found that it's even hard to find a good python implementation of Black-Scholes model (i.e., price + IV + ...
1
vote
2answers
815 views

Predicting stock returns with GARCH in Python

I have seen this post: Correctly applying GARCH in Python which shows how to correctly apply GARCH models in Python using the arch library. Now I am wondering how I ...