Ejemplo n.º 1
0
 def sell(self, trading_pair: str, amount: Decimal, order_type=OrderType.MARKET,
          price: Decimal = s_decimal_NaN, **kwargs) -> str:
     """
     Sells an amount of base asset (of the given trading pair). This function returns immediately.
     To see an actual order, you'll have to wait for SellOrderCreatedEvent.
     :param trading_pair: The market (e.g. BTC-USDT) to sell from
     :param amount: The amount in base token value
     :param order_type: The order type
     :param price: The price (note: this is no longer optional)
     :returns A new internal order id
     """
     order_id: str = k2_utils.get_new_client_order_id(False, trading_pair)
     safe_ensure_future(self._create_order(TradeType.SELL, order_id, trading_pair, amount, order_type, price))
     return order_id
Ejemplo n.º 2
0
 def buy(self, trading_pair: str, amount: Decimal, order_type=OrderType.MARKET,
         price: Decimal = s_decimal_NaN, **kwargs) -> str:
     """
     Buys an amount of base asset (of the given trading pair). This function returns immediately.
     To see an actual order, you'll have to wait for BuyOrderCreatedEvent.
     :param trading_pair: The market (e.g. BTC-USDT) to buy from
     :param amount: The amount in base token value
     :param order_type: The order type
     :param price: The price (note: this is no longer optional)
     :returns A new internal order id
     """
     # TODO: Determine if there is a way to assign client_order_id as indicated by `tempid` parameter
     order_id: str = k2_utils.get_new_client_order_id(True, trading_pair)
     safe_ensure_future(self._create_order(TradeType.BUY, order_id, trading_pair, amount, order_type, price))
     return order_id