Example #1
0
    def update_from_raw(self, raw_order):
        if self.side is None or self.order_type is None:
            self.__update_type_from_raw(raw_order)
            if self.taker_or_maker is None:
                self.__update_taker_maker_from_raw()

        return self.update(
            **{
                "symbol":
                raw_order[ExchangeConstantsOrderColumns.SYMBOL.value],
                "current_price":
                raw_order[ExchangeConstantsOrderColumns.PRICE.value],
                "quantity":
                raw_order[ExchangeConstantsOrderColumns.AMOUNT.value],
                "price":
                raw_order[ExchangeConstantsOrderColumns.PRICE.value],
                "stop_price":
                None,
                "status":
                OrderStatus(raw_order[
                    ExchangeConstantsOrderColumns.STATUS.value]),
                "order_id":
                raw_order[ExchangeConstantsOrderColumns.ID.value],
                "quantity_filled":
                raw_order[ExchangeConstantsOrderColumns.FILLED.value],
                "filled_price":
                raw_order[ExchangeConstantsOrderColumns.PRICE.value],
                "total_cost":
                raw_order[ExchangeConstantsOrderColumns.COST.value],
                "fee":
                raw_order[ExchangeConstantsOrderColumns.FEE.value],
                "timestamp":
                raw_order[ExchangeConstantsOrderColumns.TIMESTAMP.value]
            })
 def parse_status(self, status):
     return OrderStatus(self.client.parse_order_status(status))
Example #3
0
def parse_order_status(raw_order):
    try:
        return OrderStatus(
            raw_order[ExchangeConstantsOrderColumns.STATUS.value])
    except KeyError:
        return KeyError("Could not parse new order status")