My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members

goal

Ever wondered what would have happened if you had always followed the trend of a currency price? or done the opposite of the trend? or if you had set take-profit twice as big as stop-loss prices?

Efx-backtest is a minimalist back test engine. It lets you implement an automatic trading strategy in a few lines of Python and provides you with a PnL chart and simple metrics.

usage

  • Implement the method strategy.order_for_price(p) to send the engine a specific order, if any, after receiving a given price. See the default implementation for details.
  • Run the program. It will:
    1. read a price from a history file, check current orders with this price
    2. give strategy.order_for_price(p) the price to get a new order
    3. repeat with the next price.
  • Cumulated PnL is written on stdout to be ploted by gnuplot, metrics are written on stderr.

$ python market.py > pnl.txt && gnuplot pnl.gnuplot && open pnl.png

sample output

 number of prices : 2601
 number of trades : 1115 (579 win, 533 lose)
 max_exposure     : 30000.000000
 realized pnl     : 7198.400000
 unrealized pnl   : -4.000000

Powered by Google Project Hosting