Python Backtesting framework - Matlab, R project and Python | futures io social day trading
futures io futures trading


Python Backtesting framework
Updated: Views / Replies:7,951 / 28
Created: by ericbrown Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Python Backtesting framework

  #11 (permalink)
Elite Member
Baltimore Maryland/United States
 
Futures Experience: Advanced
Platform: Custom
Broker/Data: IB
Favorite Futures: Asian Stocks / Indexes
 
Branzol's Avatar
 
Posts: 39 since May 2014
Thanks: 43 given, 60 received


DarkPoolTrading View Post
Which do you think would be easier to pick up for a beginner?

I think it really depends on what you want to backtest. Depending on what your looking to backtest none of them may be right for you. When I first started using Python as a platform to backtest. Like @treydog999 I pretty much found out none of the framework out there was designed to handle anything I needed it to do. I ended up on the long journey of writing my own to handle what Zipline couldn't. At the time I started this I had never written code in Python, and over the course of this journey I feel I learned quite a bit. I'm still no expert, but I was able to code what I specifically needed. If you have the time to invest, doing something on your own is extremely rewarding.

Reply With Quote
The following 2 users say Thank You to Branzol for this post:
 
  #12 (permalink)
Trading Apprentice
western NY
 
Futures Experience: Intermediate
Platform: NinjaTrader, Python
Favorite Futures: equities, bonds, currency, commodities
 
Posts: 42 since Apr 2015
Thanks: 9 given, 25 received

branzol, what do your classes look like for your tester?

I really like what I have read with BT's Algo, Algostack, and then tree structure Strategy class sounds quite interesting although I am still trying to grasp the tree structure part.

I do think the problem with a big group project is that to me python is only useful if you understand the classes so you can make them your own. Once things get too complicated I just end up moving on. Backtesting needs are so different I almost think a less is more approach is best. Much like the micro alternatives to django for web.

What is the best design pattern for a back tester is really the interesting question.

Reply With Quote
The following user says Thank You to Darthtrader4beta for this post:
 
  #13 (permalink)
Trading Apprentice
western NY
 
Futures Experience: Intermediate
Platform: NinjaTrader, Python
Favorite Futures: equities, bonds, currency, commodities
 
Posts: 42 since Apr 2015
Thanks: 9 given, 25 received


The tree structure in BT is quite brilliant
The Tree Structure ? bt 0.1.2 documentation

My mind is kind of blown.

Reply With Quote
 
  #14 (permalink)
Elite Member
Baltimore Maryland/United States
 
Futures Experience: Advanced
Platform: Custom
Broker/Data: IB
Favorite Futures: Asian Stocks / Indexes
 
Branzol's Avatar
 
Posts: 39 since May 2014
Thanks: 43 given, 60 received


Darthtrader4beta View Post
branzol, what do your classes look like for your tester?

Brief non-abridged examples would be Instrument/Profit Calculation/Instrument Update/Position/Strategy(one for each type of strategy I test). But mine is a bit different tied into my system that pull's real-time data from multiple sources and populates my TokuMX Database, The instrument class pulls from the database to feed the event driven engine. It relies heavily on threading and the que, both were my bane. Honestly the only reason I didn't use the ones out there was mainly due to the fact that I'm back testing things that currently were not addressed in the other framework. Opening Ranges at certain times, thinking back now that could be implemented fairly easily in either. The big one I take into account is time sales data, along with depth of the order book, and news in two of my strategies. It was easier to start from scratch on that one. If I was back-testing a lot of the normal TA related things, I would have stuck with Zipline most likely as it does that extremely well, an 75% of the work is done for you. Like I mentioned before your approach should really be geared towards what you intend to backtest. If the current framework handles that I would stick with it.



Darthtrader4beta View Post
I do think the problem with a big group project is that to me python is only useful if you understand the classes so you can make them your own. Once things get too complicated I just end up moving on. Backtesting needs are so different I almost think a less is more approach is best. Much like the micro alternatives to django for web.

Like @Big Mike said, I think there is enough talent on here to combine a lot of our current codes and make something amazing. I think the biggest problem is going to be getting everyone to contribute. As a lot of people have invested 1000's of hours in what they've created, and it's tough to just hand all that away. It might be possible to do if there were enough of us that wanted to contribute. At that point we just laid out what we thought was the best approach to framework, what we all wanted..etc. Then maybe each person could contribute to a section they felt that had already addressed in their solution. That way no one is just putting there personal code fully out there.

Reply With Quote
The following 2 users say Thank You to Branzol for this post:
 
  #15 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,367 since Jun 2009
Thanks: 3,574 given, 3,983 received

Maybe the answer is somewhere else, but which library would you use to store historical data with millisecond precision?

Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following user says Thank You to sam028 for this post:
 
  #16 (permalink)
Trading Apprentice
western NY
 
Futures Experience: Intermediate
Platform: NinjaTrader, Python
Favorite Futures: equities, bonds, currency, commodities
 
Posts: 42 since Apr 2015
Thanks: 9 given, 25 received


Branzol View Post

Like @Big Mike said, I think there is enough talent on here to combine a lot of our current codes and make something amazing

I am sure that is true but if you have the man power why not do it in a compiled language?

I am just going to rip BT apart and see what happens. This is pretty much the perfect size project for me.

Reply With Quote
 
  #17 (permalink)
Trading Apprentice
western NY
 
Futures Experience: Intermediate
Platform: NinjaTrader, Python
Favorite Futures: equities, bonds, currency, commodities
 
Posts: 42 since Apr 2015
Thanks: 9 given, 25 received

This is what BT is built on and quite nice on its own:
API ? ffn 0.1 documentation

"ffn is a library that contains many useful functions for those who work in quantitative finance. It stands on the shoulders of giants (Pandas, Numpy, Scipy, etc.) and provides a vast array of utilities, from performance measurement and evaluation to graphing and common data transformations."

Reply With Quote
 
  #18 (permalink)
Elite Member
San Diego, CA
 
Futures Experience: Intermediate
Platform: x_trader pro, Excel
Broker/Data: Advantage
Favorite Futures: CL
 
baywolf's Avatar
 
Posts: 47 since Sep 2009
Thanks: 24 given, 24 received

Related web offering is quantopian. It is python based as well.

Reply With Quote
 
  #19 (permalink)
Trading Apprentice
western NY
 
Futures Experience: Intermediate
Platform: NinjaTrader, Python
Favorite Futures: equities, bonds, currency, commodities
 
Posts: 42 since Apr 2015
Thanks: 9 given, 25 received


sam028 View Post
Maybe the answer is somewhere else, but which library would you use to store historical data with millisecond precision?

This notebook goes over tick data in pandas
http://nbviewer.ipython.org/github/changhiskhan/talks/blob/master/pydata2012/pandas_timeseries.ipynb

Once you have things as a dataframe it is real easy to store in pytables with pandas HDFStore.

If your data for SPY is in a dataframe called SPY for daily data you can just do to write:

import pandas as pd

h5 = pd.HDFStore('stockData.h5', 'w')
h5['SPY'] = SPY
h5.close()

#then to read back to a dataframe:
h5 = pd.HDFStore('stockData.h5', 'r')
SPY = h5['SPY']
h5.close()

For tick data the idea would be the same but maybe you would want to have an H5 file for each instrument and then store the dataframe by date?

Reply With Quote
The following user says Thank You to Darthtrader4beta for this post:
 
  #20 (permalink)
Elite Member
Jacksonville, Florida United States
 
Futures Experience: Intermediate
Platform: NT8, Fully custom
Broker/Data: NT Brokerage, Interactive Brokers
Favorite Futures: ES
 
Jasonnator's Avatar
 
Posts: 69 since Dec 2014
Thanks: 19 given, 44 received



Big Mike View Post
If everyone would collectively step up, futures.io (formerly BMT) members could code a new proper backtester better than anything currently available.

Mike

I'm in! Anyone else?

Reply With Quote

Reply



futures io > > > > Python Backtesting framework

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python: Strategy backtesting baxline Matlab, R project and Python 4 October 18th, 2017 02:37 AM
Event driven backtesting in Python or R Big Mike Matlab, R project and Python 28 November 13th, 2014 01:26 AM
Hotkey Manager Framework gomi The Elite Circle 14 March 8th, 2014 12:19 AM
GomdRecorder framework and database Mrbaffalo The Elite Circle 6 March 11th, 2013 04:38 PM
Microtends Ninjatrader Framework kandlekid Trading Reviews and Vendors 2 September 17th, 2012 02:23 PM


All times are GMT -4. The time now is 08:56 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-18 in 0.19 seconds with 19 queries on phoenix via your IP 107.20.115.174