thanks Grant, yeah i'm trying a stochastic algo right now and it looks like it's trading 1 day late. thanks for confirming.
from looking at that slipage model you posted, here is my hack to allow trading at the preceeding close:
class OrderAtTodaysClose:
'''
wrapper for ordering, lets the TradeAtTodaysCloseSlippageModel know what today's price was.
'''
def __init__(this):
this.closePrices = {}
def order_target_percent(this,data,sid,percent, limitPrice=None, stopPrice=None):
this.closePrices[sid]=data[sid].close_price
return order_target_percent(sid,percent,limitPrice,stopPrice)
global orderAtTodaysClose
orderAtTodaysClose = OrderAtTodaysClose()
class TradeAtTodaysCloseSlippageModel(slippage.SlippageModel):
''' simulate selling immediatly at the close (hack to let interday pretend to be intraday)
YOU MUST USE OrderAtTodaysClose.order_target_percent() for this to take effect.
'''
def __init__(self):
pass
def process_order(self, trade_bar, order):
#doesn't work with daily
#price_history = history(bar_count=2, frequency='1d', field='price')
#price = price_history[trade_bar.sid][-2]
return slippage.create_transaction(
trade_bar,
order,
orderAtTodaysClose.closePrices[trade_bar.sid],
order.amount
)