mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-23 12:50:22 +08:00
MAINT: Defines members of the Order object.
Instead of a loosely defined object for Order, explicitly defines the parameters and corresponding members. Clearing the way for adding more members to the Order object.
This commit is contained in:
@@ -52,10 +52,11 @@ class SlippageTestCase(TestCase):
|
||||
slippage_model = VolumeShareSlippage()
|
||||
|
||||
open_orders = {133: [
|
||||
Order(
|
||||
{'dt': datetime.datetime(2006, 1, 5, 14, 30, tzinfo=pytz.utc),
|
||||
'amount': 100,
|
||||
'filled': 0, 'sid': 133})
|
||||
Order(**{
|
||||
'dt': datetime.datetime(2006, 1, 5, 14, 30, tzinfo=pytz.utc),
|
||||
'amount': 100,
|
||||
'filled': 0,
|
||||
'sid': 133})
|
||||
]}
|
||||
|
||||
txn = slippage_model.simulate(
|
||||
|
||||
@@ -28,10 +28,19 @@ log = Logger('Trade Simulation')
|
||||
|
||||
|
||||
class Order(object):
|
||||
|
||||
def __init__(self, initial_values=None):
|
||||
if initial_values:
|
||||
self.__dict__ = initial_values
|
||||
def __init__(self, dt, sid, amount, filled=0):
|
||||
"""
|
||||
@dt - datetime.datetime that the order was placed
|
||||
@sid - stock sid of the order
|
||||
@amount - the number of shares to buy/sell
|
||||
a positive sign indicates a buy
|
||||
a negative sign indicates a sell
|
||||
@filled - how many shares of the order have been filled so far
|
||||
"""
|
||||
self.dt = dt
|
||||
self.sid = sid
|
||||
self.amount = amount
|
||||
self.filled = filled
|
||||
|
||||
|
||||
class TradeSimulationClient(object):
|
||||
@@ -177,7 +186,7 @@ class AlgorithmSimulator(object):
|
||||
Closure to pass into the user's algo to allow placing orders
|
||||
into the transaction simulator's dict of open orders.
|
||||
"""
|
||||
order = Order({
|
||||
order = Order(**{
|
||||
'dt': self.simulation_dt,
|
||||
'sid': sid,
|
||||
'amount': int(amount),
|
||||
|
||||
Reference in New Issue
Block a user