Stack Exchange Network

Stack Exchange network consists of 174 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
0answers
17 views

Binary Option model not tying to Bloomberg

I'm using the following Python code to value a currency binary option (USD/JPY) with the following inputs: Spot 113.75 Strike 102.16 Time = 3 years Volatility = 8.55% Rate Foreign = -0.738% Rate ...
1
vote
0answers
60 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
0answers
29 views

Hull White 2 Factor

I have calibrated HW 1 Factor using Caps using closed form solutions like these. Could someone please direct me to a paper where they done something similar for 2 factor which i can code in python......
-3
votes
0answers
38 views

How do you deal with 'inf' when using pct_change? [closed]

I have a time-series of number and I want to create feature out from this, one method that I use is pct_change. However it returns some inf or -inf value. What is the general practical to deal with ...
0
votes
0answers
29 views

How do I derive the historical bond price series from FRED yields using QuantLib Python?

I'm interested in using QuantLib Python to derive daily historical price series from the following yield series: 3-Month Treasury Bill (https://fred.stlouisfed.org/series/DTB3) 10-Year Treasury ...
0
votes
1answer
94 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 + ...
0
votes
0answers
17 views

CameronFIX Python Algos

I'm looking to now if any of you have experience loading python algorithms over CameronFix engine or could give me some orientation of how I can connect a python algo to Cameron.
1
vote
2answers
213 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 ...
0
votes
0answers
32 views

Bootstrap Survival Curve using ISDA Conventions Python QuantLib

Is there currently any way to bootstrap the survival probability curve given a term structure of credit spreads using the ISDA CDS Standard Model conventions? I see that this has been done with the ...
0
votes
0answers
34 views

QuantLib-Swig Python ISDA CDS Model

I saw that a new swig has been added to the QuantLib with a link to the ISDA CDS engine. Has someone tested it and can confirm that it agrees with Bloomberg. https://github.com/lballabio/QuantLib-...
3
votes
1answer
99 views

Why my implementation of CRR model does not converge?

Recall that CRR (Cox-Ross-Rubinstein) model for option pricing is the usual binomial tree model with $u$ (up-factor) and $p$ (one of the risk-neutral probabilities) defined as follows: $$u = e^{\sigma\...
0
votes
2answers
102 views

How to calculate “portfolio cumulative return” from individual price data and weight of them?

I'm trying to run backtest in a vectorized way using Python Pandas and need to calculate a portfolio cumulative return from price data and weight of asset data. I ...
1
vote
0answers
39 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 ...
0
votes
1answer
83 views

Structured Payoff Scripting in QuantLib

I'm trying to price a snowball payoff in quantlib and would like to create a payoff like: $$Coupon = PreviousCoupon + FloorPayoff$$ Would the payoff class be able to reference the previous coupon? ...
0
votes
1answer
33 views

how to change the value set by the addFixing method in QuantLib

Suppose we have had constructed an index for forecasting future interests of a floating bond, and as suggested by the official document, I used addFixing method to set a past fixing for the current ...
0
votes
1answer
47 views

Swing option pricing in QuantLib-Python

Is it possible to use the QuantLib python wrapper to price swing options? I've seen the QuantLib Github repository contains a C++ implementation, swingoption.cpp, but have found no reference to swing ...
0
votes
0answers
19 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 ...
2
votes
1answer
126 views

Option Strategy: Python Implementation Advice

I've been tasked to create and backtest an option strategy. The strategy, in vague terms, is to essentially write call options on securities in a universe, i.e., selling insurance. I have an idea of ...
2
votes
1answer
183 views

Limit and Market Order for training a ML model

Goal : Using deep learning to build a ML model which would predict the right places where a stock price will increase, decrease or stay stable. For the current question, assume the labels are well ...
-2
votes
1answer
71 views

Separate market and limit orders from market depth/tick data

From the website https://www.algoseek.com/equities/, we can get a sample of the full depth market/tick data. From the paper https://arxiv.org/pdf/1710.03870.pdf page 8, I would like to extract the ...
-1
votes
1answer
126 views

How to simulate this Gamma expansion in a Python way

Here is the simulation that I want to do: For each of the 10 million simulation paths, I have n = 100 lambda values in sequence (the lambda vector is the same for all paths), Using each of the lambda ...
-1
votes
1answer
592 views

Choosing programming language for the next generation of a pricing library [closed]

If I were to start development of a pricing library, which programming language would be most suitable to satisfy the following needs: Implement highly parallelizable pricing models using GPU or any ...
0
votes
0answers
85 views

Calculate tenor wise DV01 of a Swap in Quantlib Python, i.e. Key-rate Duration

Is there a way I can get DV01 breakup of a Swap across different tenors of the deal in Quantlib-Python. The question asked here, follows the basic method of re-valuing the swap by shifting the curve ...
1
vote
0answers
51 views

Binary Options: convert from “Cash or Nothing” to “Asset or Nothing”

I have a formula that uses Black-Scholes to compute the implied pricing of a "Cash or Nothing" binary option on the price of a currency. The option is priced/traded in the same currency as S, K and ...
3
votes
1answer
109 views

Quantlib derivative valuation from zero curve

I have newly started with Quantlib-Python for valuing derivatives. In all the examples stated in this bolg or in other places, market quote is inserted and bootstrapping is done via individual rate ...
3
votes
1answer
99 views

QuantLib in Python : Execution time with OISRateHelper compared to Swap/Deposit RateHelper

I have been working on valuation of interest rate swaps using dual curve bootstrapping. And for this I use OISRateHelper to create a discount term structure using OIS rates. The entire code below : <...
1
vote
1answer
118 views

Black-Scholes for Binary Option

Something is wrong with this python code designed to apply Black Scholes to the price of a binary option (all or nothing, 0 or 100 payout). The results I get here is 0.4512780109614. Which I know ...
2
votes
1answer
131 views

Backtesting Fundamental Equity Strategies in Python

I am trying to run a local backtest using Python and Zipline seems to be the most popular package out there. Does any one have isnight on ingesting fundamental data for the backtest? The documentation ...
0
votes
0answers
128 views

Quantlib Python: Issue withg Heston MC Paths generation

I am trying to price a corridor Variance Swap with Heston. I am generating paths with the following code, however I get weird results of the MC simulation. Any idea why ? ...
0
votes
1answer
204 views

Why are my eigenvalues coming out negative for my positive definite covariance matrix?

I have a 51 x 51 covariance matrix that is derived from historic forward rates that is positive definite. I know it is because in Python np.cholesky returns a correct cholesky decomposition. However, ...
0
votes
1answer
221 views

Automatically get iShares ETF holdings

I heard that ETF's must publicly report their holdings all the time. I have seen that for example on the iShares website I can download the list of holdings as a csv file: https://www.ishares.com/us/...
1
vote
0answers
87 views

Chat bot for traders [closed]

In the framework of my internship at a bank, I want to write a chat bot program in Python that allows our bond traders via their Bloomberg terminal chat box application to type in structured command ...
2
votes
1answer
109 views

How to interpret and define statistics of GBM output

I am trying to model the future prices of a number of commodities. For this, I am applying geometric Brownian motion, writing a Monte Carlo code in Python. Given that I want to estimate tommorows ...
1
vote
2answers
82 views

How to change the YieldTermStructureHandle's referenceDate in QuantLib

Suppose we have already known the dates and rates of a spot rate curve, and I passed the data to the ZeroCurve class to construct a discount curve for bond pricing. What I wanna find is how to change ...
1
vote
1answer
124 views

Implementing the Sharpe's return-based style analysis on Python

I am trying to implement the Sharpe's return-based style analysis on Python. The problem is formulated as follows: ...
1
vote
2answers
119 views

Working with time series with different resolutions

I’m looking at making predictions of close prices (stocks/commodities), and have access to various data sources to help predict. However, most of these sources are in a different time frame, ...
1
vote
1answer
88 views

Pricing an option with sparse data, high underlying volatility and returns

I'm currently pricing American and European options on an underlying with sparse data (interpolated), high annual volatility and returns over the last year around 300%. The product isn't similar to ...
2
votes
2answers
190 views

QuantLib-Python: How to set fixed reference dates when bootstrapping the term structure?

I am borrowing from an example in the "Quantlib Python Cookbook" section 7, to ask my question. To make the point as clear as possible I simplify the code a bit. The aim is to strip the EONIA curve ...
1
vote
1answer
67 views

Using DayCounter ActualActual.ISMA in QuantLib

Suppose we have a semiannual coupon bond. The calculation date is 5/8 2017. The ex-coupon date is 4/20 2017 and next coupon date is 10/20 2017. ...
1
vote
1answer
82 views

QuantLib-Python: What is “index = Euribor1Y(term_structure)” doing?

I am currently reading thorugh the QuantLib-Python cookbook to learn about this nice pice of software. On page 141 I encountered a block of code that made me wonder what it is exactly doing. The code ...
2
votes
1answer
72 views

Quantlib - model changes in option value on day of expiry

I'm trying to model option value changes during the progression of the last trading day before expiry. All option pricing Quantlib examples that I've seen work with day-level granularity. I'm ...
1
vote
1answer
199 views

Pricing fixed coupon bond with ytm in QuantLib python

I'm new to QuantLib and I'm confused about ZeroCurve in YieldTermStructureHandle The start date is Oct 20, 2001. Assuming the ...
1
vote
2answers
351 views

Efficient algorithm for calculating Beta coefficient

I'm using Python/Pandas. Using naive nested for-loops to do Beta calculation for all ~5k stocks by ~5k days (moving window ~250 days) is unbearably slow. Is there any fast and elegant way to ...
2
votes
1answer
582 views

How to calculate Sharpe Ratio from $ returns?

I have a pairs strategy that I am trying to calculate the sharpe ratio for. Currently I am using python for my analysis and calculation. I have a dataframe that contains the cumulative returns in $'s ...
2
votes
1answer
82 views

QuantLib-Python: Splitting the NPV of an option into intrinsic & time

I am right now working throught the "cookbook" of Goutham Balaraman & Luigi Ballabio. By the way a very nice introduction into QuantLib-Python and a good starting point :-) In section four there ...
1
vote
0answers
92 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 ...
1
vote
1answer
206 views

QuantLib-Python: Getting a list of all holidays between D1 & D2 with function “holidayList”

I figured out that the C++ version of QuantLib offers a function called holidayList in the calendar class. ...
0
votes
0answers
122 views

How to understand the forecasted output values of GARCH model in python?

arch_model in python produces the following output values in its forecast method: mean - forecast conditional mean variance - forecast conditional variance Query 1. I would like to know what do ...
0
votes
1answer
193 views

Pandas: Close-to-Open return on stocks

I am trying to daily calculate the close-to-open return for j stocks for t days. Is there anyway I can calculate without using a for loop? I have one Dataframe for daily close prices and one for daily ...
1
vote
0answers
78 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 ...