Пример #1
0
def test_order():

    asset = Asset('asset-id', 'NSDQ', symbol='AAPL')

    o = Order(datetime.now(), asset, 3)
    assert o.asset == asset
    assert o.sid == asset
    assert o.open

    o.filled = 3
    assert o.open_amount == 0
    assert not o.open

    assert type(o.to_api_obj()) == proto.Order
Пример #2
0
 def _order2zp(self, order):
     zp_order = ZPOrder(
         id=order.client_order_id,
         asset=symbol_lookup(order.symbol),
         amount=int(order.qty) if order.side == 'buy' else -int(order.qty),
         stop=float(order.stop_price) if order.stop_price else None,
         limit=float(order.limit_price) if order.limit_price else None,
         dt=order.submitted_at,
         commission=0,
     )
     zp_order._status = ZP_ORDER_STATUS.OPEN
     if order.canceled_at:
         zp_order._status = ZP_ORDER_STATUS.CANCELLED
     if order.failed_at:
         zp_order._status = ZP_ORDER_STATUS.REJECTED
     if order.filled_at:
         zp_order._status = ZP_ORDER_STATUS.FILLED
         zp_order.filled = int(order.filled_qty)
     return zp_order