mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-09 11:19:23 +08:00
ENH: Update ordering API to support new ExecutionStyle class in favor of
existing `limit_price` and `stop_price` parameters. The goal of this change is to refactor the existing ordering API to provide a cleaner interface for defining more complex order types. Adds a new module, zipline.finance.execution, which defines the ExecutionStyle abstract base class, along with concrete MarketOrder, LimitOrder, StopOrder, and StopLimitOrder subclasses. Adds a new `style` keyword argument to the function signature of the `order` API method, which accepts an instance of ExecutionStyle. The existing limit_price and stop_price parameters are still supported at this time, but are converted into the new ExecutionStyle objects before being passed to Blotter.order.
This commit is contained in:
@@ -40,6 +40,7 @@ from zipline.finance.blotter import Blotter
|
||||
from zipline.gens.composites import date_sorted_sources
|
||||
|
||||
from zipline.finance import trading
|
||||
from zipline.finance.execution import MarketOrder, LimitOrder
|
||||
from zipline.finance.trading import SimulationParameters
|
||||
|
||||
from zipline.finance.performance import PerformanceTracker
|
||||
@@ -319,7 +320,7 @@ class FinanceTestCase(TestCase):
|
||||
for i in range(order_count):
|
||||
|
||||
blotter.set_date(order_date)
|
||||
blotter.order(sid, order_amount * alternator ** i, None, None)
|
||||
blotter.order(sid, order_amount * alternator ** i, MarketOrder())
|
||||
|
||||
order_date = order_date + order_interval
|
||||
# move after market orders to just after market next
|
||||
@@ -400,8 +401,8 @@ class FinanceTestCase(TestCase):
|
||||
|
||||
# set up two open limit orders with very low limit prices,
|
||||
# one for sid 1 and one for sid 2
|
||||
blotter.order(1, 100, 10, None, None)
|
||||
blotter.order(2, 100, 10, None, None)
|
||||
blotter.order(1, 100, LimitOrder(10))
|
||||
blotter.order(2, 100, LimitOrder(10))
|
||||
|
||||
# send in a split for sid 2
|
||||
split_event = factory.create_split(2, 0.33333,
|
||||
|
||||
Reference in New Issue
Block a user