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

3
votes
0answers
45 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 the Coupons, Face Values and Closing Prices from Thomson Reuters, which ...
0
votes
0answers
19 views

Examples using PyOpenCL for backtesting trading strategies?

Anyone used PyOpenCL for backtesting trading strategies? Any qualitative/quantitative benchmarks of implementations in Python, Cython, PyOpenCl? Is it worth it spending time implementing extra Lines ...
0
votes
0answers
22 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 ...
1
vote
1answer
28 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
54 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
41 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: ...
16
votes
5answers
1k 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
215 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
133 views

IbPy download historical price data

How can i download historical price data from interactive brokers using IbPy and python?
0
votes
1answer
41 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 ...
0
votes
1answer
157 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: ...
0
votes
0answers
95 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
111 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, ...
7
votes
1answer
770 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
77 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
338 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
1answer
102 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
1k 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
148 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
493 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
730 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
604 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
568 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
500 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
175 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
926 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 ? ...
3
votes
1answer
929 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?
12
votes
7answers
7k 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
315 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" ...
5
votes
3answers
832 views

Generate tick data from candlestick

Is there software (or Python / R / ... scripts) to generate (pseudo) tick data from candlestick data. I have candlestick data (CSV format) from monthly timeframe (MN) to minute timeframe (M1) but ...
3
votes
1answer
1k views

Historical volatility from close prices (Haug pg 166)

I have implemented a function for calculating historical volatility using close the close method as described by Haug on page 166. When I implemented the formula given by Haug, it resulted in some ...
15
votes
7answers
5k views

What tools exist for order book analysis and visualization?

What tools exist for order book analysis and visualization? In particular, if one wanted to examine a limit order book and understand how it changes throughout the day where would you turn for ...
17
votes
7answers
9k views

Python library for Portfolio Optimization

Does anyone know of a python library/source that is able to calculate the traditional mean-variance portfolio? To press my luck, any resources where the library/source also contains functions such as ...