Questions tagged [pyalgotrade]

PyAlgoTrade is an event driven algorithmic trading Python library.

Python Algorithmic Trading Library

PyAlgoTrade is a Python Algorithmic Trading Library with focus on backtesting and support for paper-trading and live-trading. Let’s say you have an idea for a trading strategy and you’d like to evaluate it with historical data and see how it behaves. PyAlgoTrade allows you to do so with minimal effort.

Main Features

  • Event driven.
  • Supports Market, Limit, Stop and StopLimit orders.
  • Supports any type of time-series data in CSV format like Yahoo! Finance, Google Finance, Quandl and NinjaTrader.
  • Bitcoin trading support through Bitstamp.
  • Technical indicators and filters like SMA, WMA, EMA, RSI, Bollinger Bands, Hurst exponent and others.
  • Performance metrics like Sharpe ratio and drawdown analysis.
  • Handling Twitter events in realtime.
  • Event profiler.
  • TA-Lib integration.

Home page: http://gbeced.github.io/pyalgotrade/

77 questions
10
votes
2 answers

How to create a composite strategy, using multiple instruments, in Pyalgotrade?

I'm using pyalgotrade for a trading strategy where I want to use multiple tickers in a list. The way it is set up now, it runs the strategy for each individual ticker in the list, but what I want it to do is to run them all as one, composite…
7
votes
3 answers

How do I feed in my own data into PyAlgoTrade?

I'm trying to use PyAlogoTrade's event profiler However I don't want to use data from yahoo!finance, I want to use my own but can't figure out how to parse in the CSV, it is in the format: Timestamp Low Open Close High BTC_vol …
3
votes
2 answers

interactive brokers api python - fire order during "pre market"

I'm using the IB API in order to automatically fire orders during pre-market time. I am unable to figure out why the order is waiting for the market opening time instead of buying during the pre-market period. After looking at the API documentation…
3
votes
1 answer

Unexpected results when checking all values in a Python dictionary are None

Let's consider the following three dictionaries: topByClass = {'Real Estate': 'VNO', 'Construction': 'TOL', 'Utilities': 'EXC'} shouldPass = {'Real Estate': None, 'Construction': None, 'Utilities': 'EXC'} shouldFail = {'Real Estate': None,…
laventnc
  • 175
  • 13
3
votes
1 answer

Pyalgotrade advice needed for stoploss orders

I want to backtest a trading strategy in pyalgotrade, but I’m having problems submitting the stoploss order. In the documentation it states: Positions are higher level abstractions for placing orders. They are escentially a pair of entry-exit orders…
Ale
  • 247
  • 3
  • 10
2
votes
1 answer

Backtesting using multiple instruments in PyAlgoTrade

Hi I want to generalize the strategy from 1 to 10 possible investments using an array ("instruments") to simplify the tasks of loading the 10 feeds, creating the 10 SMAs and then, each day, checking if a signal crossing happened in one (or more) of…
PalFS
  • 731
  • 6
  • 16
2
votes
1 answer

how to work around yahoo data issue? Not enough volume to fill

I am working on a MACD strategy backtest, and sometimes I came across this warning: 2015-02-19 00:00:00 broker.backtesting [DEBUG] Not enough volume to fill 1988.HK market order [1] for 55258 share/s Then I checked the csv data source and…
Chan Austin
  • 2,260
  • 4
  • 14
  • 18
2
votes
1 answer

Configure event profile in pyalgotrade to look back further than one bar ( eg bards[-2] )

I'm trying to write various predicates on simple candle stick structures. For example one component of a '3 green candles in a row' predicate would require a look back of -4 To start off simple I try an test it with a 'higher_highs' predicate. If…
David Hancock
  • 1,063
  • 4
  • 16
  • 28
2
votes
4 answers

Importing python module in Django: __init__.py classes not loaded

The following code works fine in a python shell, displaying the content of the feed object: from pyalgotrade import strategy from pyalgotrade.barfeed import yahoofeed class MyStrategy(strategy.BacktestingStrategy): def __init__(self, feed,…
Bertrand
  • 23
  • 3
1
vote
1 answer

Python program that buys options using IBKR

So I have built the following program from ibapi.client import EClient from ibapi.wrapper import EWrapper from ibapi.contract import Contract from ibapi.order import * import threading import time class IBapi(EWrapper, EClient): def…
user20876058
1
vote
1 answer

python program that downloads options data using IBKR

So I have written the following program: from ibapi.client import EClient from ibapi.wrapper import EWrapper from ibapi.contract import Contract import threading import time class IBapi(EWrapper, EClient): def __init__(self): …
user20876058
1
vote
0 answers

PyAlgoTrade: How to use resampleBarFeed with multiple instruments?

I am resampling a few instruments with [pyalogtrade][1]. I have a base barfeed for 1-minute data, which is working fine I have added a resampler to resample for 2 minutes, as follows: class Strategy(strategy.BaseStrategy): def __init__(self,…
1
vote
0 answers

Adding custom function to handle additional column/ data while resampleBarFeed in PyAlgoTrade

I am resampling custom columns with pyalogtrade. Say I have an extra column called EX other than the default columns (open, close, high, low, etc). This is initialized and passed around in the bar.BasicBar() function as {'extraCol1' : 1.09 }. By…
1
vote
3 answers

Testnet Binance Future : Invalid API-key, IP, or permissions for action

I spent a whole day solving this problem and still have not found any solution. I do not know why I did not see any similar case in Demo testnet.binancefuture. I created four accounts with different Gmails on different servers... from…
M.a.RS
  • 137
  • 2
  • 12
1
vote
1 answer

PyAlgoTrade custom CSV date error Invalid datetime. It must be bigger than that last one

I am trying to add custom csv data into PyAlgoTrade using the addValuesFromCSV method, and I am getting this error: 2021-10-14 17:50:00 {'Open': 4886.0, 'High': 4888.0, 'Low': 4879.0, 'Close': 4883.0} 2021-10-14 17:55:00 {'Open': 4883.0, 'High':…
1
2 3 4 5 6