Defined the same commission model as with equities for now. We need to fix the data precision in the bundles.

This commit is contained in:
fredfortier
2017-09-21 01:17:10 -04:00
parent 10a5b5412e
commit 7335810cc2
3 changed files with 26 additions and 1 deletions
+1 -1
View File
@@ -1135,7 +1135,7 @@ class TradingAlgorithm(object):
'date_rule. You should use keyword argument '
'time_rule= when calling schedule_function without '
'specifying a date_rule', stacklevel=3)
freq = self.sim_params.data_frequency
date_rule = date_rule or date_rules.every_day()
+6
View File
@@ -29,6 +29,7 @@ from catalyst.algorithm import TradingAlgorithm
from catalyst.data.minute_bars import BcolzMinuteBarWriter, \
BcolzMinuteBarReader
from catalyst.errors import OrderInBeforeTradingStart
from catalyst.exchange.exchange_blotter import ExchangeBlotter
from catalyst.exchange.exchange_errors import (
ExchangeRequestError,
ExchangePortfolioDataError,
@@ -190,6 +191,11 @@ class ExchangeTradingAlgorithmBacktest(ExchangeTradingAlgorithmBase):
def __init__(self, *args, **kwargs):
super(ExchangeTradingAlgorithmBacktest, self).__init__(*args, **kwargs)
self.blotter = ExchangeBlotter(
data_frequency=self.data_frequency,
# Default to NeverCancel in catalyst
cancel_policy=self.cancel_policy,
)
log.info('initialized trading algorithm in backtest mode')
+19
View File
@@ -0,0 +1,19 @@
from catalyst.finance.blotter import Blotter
from catalyst.finance.commission import PerShare
from catalyst.finance.slippage import VolumeShareSlippage
from catalyst.assets._assets import TradingPair
class ExchangeBlotter(Blotter):
def __init__(self, *args, **kwargs):
super(ExchangeBlotter, self).__init__(*args, **kwargs)
# Using the equity models for now
# We may be able to define more sophisticated models based on the fee
# structure of each exchange.
self.slippage_models = {
TradingPair: VolumeShareSlippage()
}
self.commission_models = {
TradingPair: PerShare()
}