Пример #1
0
 def __buildAcceptedLimitOrder(self, action, limitPrice, quantity):
     ret = broker.LimitOrder(action, "orcl", limitPrice, quantity, DefaultTraits())
     self.assertEquals(ret.getSubmitDateTime(), None)
     ret.switchState(broker.Order.State.SUBMITTED)
     ret.setSubmitted(1, datetime.datetime.now())
     self.assertNotEquals(ret.getSubmitDateTime(), None)
     ret.switchState(broker.Order.State.ACCEPTED)
     return ret
Пример #2
0
def build_order_from_open_order(openOrder, instrumentTraits):
    if openOrder.isBuy():
        action = broker.Order.Action.BUY
    elif openOrder.isSell():
        action = broker.Order.Action.SELL
    else:
        raise Exception("Invalid order type")

    ret = broker.LimitOrder(action, common.btc_symbol, openOrder.getPrice(),
                            openOrder.getAmount(), instrumentTraits)
    ret.setSubmitted(openOrder.getId(), openOrder.getDateTime())
    ret.setState(broker.Order.State.ACCEPTED)
    return ret
Пример #3
0
    def createLimitOrder(self, action, instrument, limitPrice, quantity):
        if instrument != common.btc_symbol:
            raise Exception("Only BTC instrument is supported")

        if action == broker.Order.Action.BUY_TO_COVER:
            action = broker.Order.Action.BUY
        elif action == broker.Order.Action.SELL_SHORT:
            action = broker.Order.Action.SELL

        if action not in [broker.Order.Action.BUY, broker.Order.Action.SELL]:
            raise Exception("Only BUY/SELL orders are supported")

        instrumentTraits = self.getInstrumentTraits(instrument)
        limitPrice = round(limitPrice, 2)
        quantity = instrumentTraits.roundQuantity(quantity)
        return broker.LimitOrder(action, instrument, limitPrice, quantity,
                                 instrumentTraits)
Пример #4
0
 def createLimitOrder(self, action, instrument, limitPrice, quantity):
     instrumentTraits = self.getInstrumentTraits()
     limitPrice = round(limitPrice, 2)
     quantity = instrumentTraits.roundQuantity(quantity)
     return broker.LimitOrder(action, instrument, limitPrice, quantity,
                              instrumentTraits)