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.

learn more… | top users | synonyms

0
votes
0answers
85 views

Ideas for speeding up greek calculations

My current calculations using the vollib library averages 0.5 seconds. Is there any way to get it faster? Any tips/best practice notes will be helpful. This is for a scripting language such as ...
0
votes
2answers
56 views

How can I find stocks that have had a X% price swing within Y days, sorted by recency of said swing? [closed]

Let's say that I want to find stocks that have moved +-20% within a 10 day period. ABC would match if at t, ...
1
vote
0answers
35 views

How to fit exogenous + GARCH Model In Python?

I am studying a textbook of statistics / econometrics, using Python for my computational needs. I have encountered GARCH models and my understanding is that this is a commonly used model. In an ...
3
votes
1answer
116 views

Which Algorithmic trading library would you recommend for trading Bitcoin?

I am starting to do Algorithmic trading in cryptocurrencies using Python libraries. Most exchanges have RESTful API that make it easy to write you own code and get started. However, I would like to ...
7
votes
2answers
202 views

What time series database can be used with Python and Pandas?

I'm looking for a time series database that can be easily used with Python and Pandas objects such as DataFrame, Panel... But these objects will always contains time series. Ideally I'm looking for ...
-1
votes
2answers
48 views

Is there a python code for estimating the parameters of geometric brownian motion?

I was trying to find the parameters of GBM but could not find a python code for the same.
1
vote
0answers
105 views

Formula behind pandas.Options() implied volatility

I noted that implied volatility (IV field) from pandas.Options class is very different (especially, for out of money options) than what I compute with Black-Scholes model. (risk free rate is pulled ...
0
votes
0answers
16 views

Selling two uncorrelated OTM options lowers the over all probability of profit?

I am trying to simulate shorting two uncorrelated put options, I wrote a python program and used monte carlo method to simulate the PnL on expiration: gist It seems the probability of profit is ...
3
votes
1answer
171 views

Shannon's entropy for financial times-series (return)

I'm looking at Shannon entropy, and generaly at ways to tell noise from signal when observing intraday returns (at the minute level for now). In python, e.g. I've implemented the fomula (sum of ...
2
votes
1answer
67 views

Bloomberg Python Question - How do you access PRTU via python?

I am having some trouble using python to access Bloomberg as I cant find much documentation. All I really need to do is a simple lookup of dates in the PRTU function of Bloomberg, PRTU via a python ...
0
votes
0answers
124 views

Can I use PyAlgoTrade for Forex?

Is it possible to use PyAlgoTrade for Forex related algorithms? If it is, please point me in the right direction on how to get PyAlgoTrade to work on Forex data.
2
votes
0answers
34 views

Black-Scholes explicit Euler implementation python

I've written some code for the explicit finite difference method to solve the BS equation. For certain sets of parameters (time-steps and asset-steps) I get a stable but wrong solution. For others, ...
1
vote
2answers
102 views

Calculating log-returns across multiple securities and time

I've been getting very confused on the topic of calculating returns. To get cumulative returns in time, log-returns are used, but apparently log-returns aren't used across different securities at a ...
1
vote
1answer
84 views

quantlib python : missing methods?

I'm reading Introduction to Selected Classes of the QuantLib Library I by Dimitri Reiswich and tries to "convert" it to Python. It seems to me that some C++ possibilities aren't available in python. ...
2
votes
1answer
81 views

How to get the IMM dates in Python for a given symbol?

How can I get an IMM date from its 2 character symbol (eg. "U6", "Z8") in python? I have not been able to install the quantlib addin (it's hard if you aren't tech savy), so please don't point me in ...
0
votes
1answer
64 views

Binary Option valuation problem in R using RQuantLib; also result validation aspect

When I am trying to value Binary Option using RQuantLib I am not getting all the greeks for exctype "american" wheras "european" exctype is fine. What is the problem here ? ...
2
votes
2answers
167 views

Multivariate GARCH in Python

Is there a package to run simplified multivariate GARCH models in Python? I found the Arch package but that seems to work on only univariate models. I'd like to test out some of the more simple ...
1
vote
1answer
252 views

Calculate and plot historical volatility with Python

I have downloaded historical data for FTSE from 1984 to now. What I would like to do is to graph volatility as a function of time. What I have written is: ...
0
votes
1answer
42 views

need help with Donchian-channels function!

I want to be able to plot Donchian-channels. It's probably easier to use numpy but, am not that fluent with numpy yet so i thought i could make a function that takes two arrays as input(Highs and ...
3
votes
1answer
158 views

Wrong discount factors when finding Nelson Siegel Svensson model parameters

I am trying to determine the parameters for the Nelson Siegel Svensson model and am solving a Non- Linear Optimization problem to do this. Some of the code I have written is below and this is where my ...
1
vote
1answer
113 views

Broker or source of intraday futures data for a python API?

I am looking for a broker that offers a python API for downloading historical intraday data on futures. So far I have only seen Interactive Brokers and Tradestation. Are there some other brokers ...
1
vote
0answers
54 views

Issue with Naive Bootstrapping (US Government Bonds)

I am using the formula here to determine the discount factor function. I get the data for Coupons, Face Values and Closing Prices from Thomson Reuters, which I insert into the Dataframe ...
2
votes
0answers
89 views

Problem with Naive Bootstrapping (US Government Bonds)

I am using the formula here to determine the discount factor function and eventually the zero-coupon yields. I get the data for Coupons, Face Values and Closing Prices from Thomson Reuters, which I ...
1
vote
0answers
74 views

bandwith portfolio rebalancing in python

I want to calculate a bandwith rebalancing machanism for a portfolio of two assets. As soon as the performance of one ov the assets gets bigger or smaller than the other one + a defined tolerance ...
2
votes
1answer
55 views

importing columns of returns data into python from excel/csv [closed]

I'm fairly new to the quant finance space, and I was hoping to get some guidance. Say I have a csv/excel file with columns of daily returns data for various asset classes or securities (one column per ...
0
votes
1answer
168 views

How can I calculate the Maximum Drawdown MDD in python

I need to calculate the a time dynamic Maximum Drawdown in Python. The problem is that e.g.: ( df.CLOSE_SPX.max() - df.CLOSE_SPX.min() ) / df.CLOSE_SPX.max() ...
1
vote
1answer
206 views

calculate YTD return / find first available datapoint of a year in python

I need to calculate the year-to-date relative return of a given dataset. I usually caculate the cumulative relative return with this simple function: ...
30
votes
7answers
4k views

Is R being replaced by Python at quant desks?

I know the title sounds a little extreme but I wonder whether R is phased out by a lot of quant desks at sell side banks as well as hedge funds in favor of Python. I get the impression that with ...
4
votes
1answer
429 views

Moving window forecasting in Python

I am looking to create some code that will out-of-sample forecast the HAR-RV model. The model itself is formulated as the following, and the betas are estimated through HAC-OLS or Newey-West. ...
0
votes
1answer
693 views

IbPy download historical price data

How can i download historical price data from interactive brokers using IbPy and python?
0
votes
1answer
106 views

KeyError in Python code used to determine a trade signal for Pair Trading

I'm basically running some code as follows. Basically I'm just retrieving pairs of stocks (laid out as Row 1-Stock 1,2, Row 2-Stock 1,2 and so on, where Stock 1 and 2 are different in each row) from a ...
1
vote
1answer
699 views

How to get positions of your portfolio from Interactive Brokers with python ibPy?

I am using ibpy to get the positions of my portfolio. I understand that I can do: ...
1
vote
0answers
310 views

Implied volatility from American options using python

I am currently trying to construct volatility surface from american option prices (using Cox-Ross-Rubinstein tree) in Python 2.7. Below you can find the code I came up with. Any corrections would be ...
1
vote
3answers
201 views

Building custom indices; getting data from web; stats analysis; Python or R?

I would like to build a couple of custom indices. I would like to be able to enter ticker(s) into an input and have ohlc, volume, qualitative ...data downloaded from yahoofinance, google finance, ...
11
votes
1answer
2k views

Correctly applying GARCH in Python

Problem: Correct usage of GARCH(1,1) Aim of research: Forecasting volatility/variance. Tools used: Python Instrument: SPX (specifically adjusted close prices) Reference material: On Estimation of ...
2
votes
1answer
100 views

How to model bracket orders?

I'm looking for a way to make my own Python backtester (like zipline or pyalgotrade) or improve one of these backtesters. One major lack of these backtesters is the lack of support of bracket orders ...
1
vote
1answer
782 views

Python code to download historical firm data

I am looking for a Python code that scraps a website to download historical firm data such as market capitalization, dividend-yield, and so on. I have a code that downloads the current firm data from ...
-2
votes
2answers
186 views

Modified or Macauley Duration in python

are there any existing python modules that can calculate Modified and/or Macauley Duration of a bond.
2
votes
2answers
2k views

Build a customizable trading engine in python [closed]

I am planning building fully customizable backtesting trading engine in python from scratch as a open source project, the main features i am considering is, It should be fully customizable from ...
1
vote
0answers
203 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 ...
0
votes
1answer
826 views

Calculate bond yield in python

I want to run the newton method on a large dataset to calculate bond yield. Below is the code I created using a loop. I need to run it on ~50 million lines and the loop is quite unwieldy. Is there a ...
0
votes
2answers
1k views

Technical analysis in Python - source of knowledge

I did my best, but I could not find answer for this one - is there any good and in-depth source of knowledge about using Python for technical analysis ? Obviously, there are plenty of tutorials, blogs ...
0
votes
1answer
971 views

How do I do a mean variance optimization with constraints?

I am using python and the cvxopt library to calculate an efficient frontier, per the docs: http://cvxopt.org/examples/book/portfolio.html However, I cannot figure out how to add a constraint so that ...
0
votes
1answer
899 views

estimate implied volatility using newton-raphson in python

I am trying to calculate the implied volatility using newton-raphson in python, but the value diverges instead of converge. What is wrong with the code? ...
2
votes
2answers
1k views

Calculating Bollinger Band Correctly

My bollinger band comes out like the below, which doesn't seem right. Any idea what is wrong with my code for calculating upper and lower bollinber bands? I obtained my data from here ...
4
votes
1answer
181 views

Why does regression capture differences in volatility?

I read the following statement in the book python for data analysis, chapter 11, and I was wondering if someone could give me intuition about why regression has this effect? The purpose of the ...
1
vote
0answers
1k views

Black Scholes well coded Python

I have some trouble with the following code. Some jump and a decentered path are present but it's not the case, normally for Black Scholes diffusion ! Is anyone see a problem in my code ? ...
4
votes
1answer
1k views

Are there Python algorithmic trading libraries supporting forex?

I know about zipline and ultrafinance, but as far as I know, they don't support fx trading. Which libraries do?
17
votes
9answers
11k views

Except Zipline, are there any other Pythonic algorithmic trading library I can choose?

Except Zipline, are there any other Pythonic algorithmic trading library I can choose? Especially, for backtesting?
4
votes
0answers
331 views

Rate Distortion Minimization in a Python Clustering Algorithm

I'm attempting to solve for $\hat{k}$ clusters, such that the rate distortion is minimized, as described here, however, the answers that I am getting from my algorithm are not following the "Jump" ...