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

    data['order_id'] = create_random_32_bytes_id()
    state_change = NewLimitOrderStateChange(data)
    dispatch_state_changes(state_change)

    return data['order_id']
Пример #2
0
 def create_offer(offer_type, base_amount, quote_amount, offer_lifetime,
                  trader_role):
     new_offer_id = create_random_32_bytes_id()
     timeout_date = time_plus(seconds=offer_lifetime)
     offer_model = Offer(new_offer_id, offer_type, base_amount,
                         quote_amount, timeout_date, trader_role)
     from raidex.raidex_node.order import fsm_offer
     fsm_offer.add_model(offer_model)
     return offer_model
Пример #3
0
    def from_dict(cls, data):

        if 'order_id' not in data or data['order_id'] is None:
            order_id = create_random_32_bytes_id()
        else:
            order_id = data['order_id']

        if 'lifetime' not in data:
            data['lifetime'] = DEFAULT_OFFER_LIFETIME

        if data['order_type'] == 'BUY':
            order_type = OfferType.BUY
        else:
            order_type = OfferType.SELL

        obj = cls(
            order_id,
            order_type,
            data['amount'],
            data['price'],
            data['lifetime']
        )
        return obj
Пример #4
0
def random_id():
    return create_random_32_bytes_id()