Modified the Position handling to use long/short instead of buy/sell for side/position_type. Also modified the unit tests for both Portfolio and Position to reflect these changes. Added a basic historical backtesting capability via backtest.py and using CSV tick data for currency pairs.

This commit is contained in:
Michael Halls-Moore
2015-04-17 12:34:31 +01:00
parent d9a7444fc2
commit e74777802b
12 changed files with 519 additions and 192 deletions
+30 -1
View File
@@ -1,8 +1,37 @@
from abc import ABCMeta, abstractmethod
import httplib
import urllib
class Execution(object):
class ExecutionHandler(object):
"""
Provides an abstract base class to handle all execution in the
backtesting and live trading system.
"""
__metaclass__ = ABCMeta
@abstractmethod
def execute_order(self):
"""
Send the order to the brokerage.
"""
raise NotImplementedError("Should implement execute_order()")
class SimulatedExecution(object):
"""
Provides a simulated execution handling environment. This class
actually does nothing - it simply receives an order to execute.
Instead, the Portfolio object actually provides fill handling.
This will be modified in later versions.
"""
def execute_order(self, event):
pass
class OANDAExecutionHandler(ExecutionHandler):
def __init__(self, domain, access_token, account_id):
self.domain = domain
self.access_token = access_token