Exemplo n.º 1
0
    def cancel_order(self, symbol: object, order_id: object) -> object:
        """
        Submit cancel request for cancelling an order.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param order_id: The order id. (mandatory)
        :return: No return
        """
        call_sync(self.request_impl.cancel_order(symbol, order_id))
Exemplo n.º 2
0
    def cancel_withdraw(self, currency: 'str', withdraw_id: 'int') -> None:
        """
        Cancel an withdraw request.

        :param currency: The currency, like "btc". (mandatory)
        :param withdraw_id: withdraw id (mandatory)
        :return: No return.
        """
        call_sync(self.request_impl.cancel_withdraw(currency, withdraw_id))
Exemplo n.º 3
0
    def cancel_orders(self, symbol: 'str', order_id_list: 'list') -> None:
        """
        Submit cancel request for cancelling multiple orders.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param order_id_list: The list of order id. the max size is 50. (mandatory)
        :return: No return
        """
        call_sync(self.request_impl.cancel_orders(symbol, order_id_list))
Exemplo n.º 4
0
    def get_account_balance(self) -> list:
        """
        Get the balance of a all accounts.

        :return: The information of all account balance.
        """
        accounts = call_sync(self.request_impl.get_accounts())
        for item in accounts:
            balances = call_sync(self.request_impl.get_balance(item))
            item.balances = balances
        return accounts
Exemplo n.º 5
0
    def get_exchange_info(self) -> ExchangeInfo:
        """
        Get all the trading assets and currencies supported in hbclient.trade.
        The information of trading instrument, including base currency, quote precision, etc.

        :return: The information of trading instrument and currencies.
        """
        symbol_list = call_sync(self.request_impl.get_symbols())
        currencies = call_sync(self.request_impl.get_currencies())
        exchange_info = ExchangeInfo()
        exchange_info.symbol_list = symbol_list
        exchange_info.currencies = currencies
        return exchange_info
Exemplo n.º 6
0
    def get_account_balance_by_account_type(
            self, account_type: "AccountType") -> Account:
        """
        Get the balance of a all accounts or specified account.

        :param account_type: The specified account type. if it is not filled, this method will return all accounts (mandatory)
        :return: The information of the account that is specified type.
        """
        check_should_not_none(account_type, "account_type")
        accounts = call_sync(self.request_impl.get_accounts())
        for item in accounts:
            if account_type == item.account_type:
                balances = call_sync(self.request_impl.get_balance(item))
                item.balances = balances
                return item
Exemplo n.º 7
0
    def get_cross_margin_account_balance(self):
        """
        get cross margin account balance

        :return: cross-margin account.
        """
        return call_sync(self.request_impl.get_cross_margin_account_balance())
Exemplo n.º 8
0
    def create_order(self,
                     symbol: 'str',
                     account_type: 'AccountType',
                     order_type: 'OrderType',
                     amount: 'float',
                     price: 'float',
                     client_order_id=None,
                     stop_price=None,
                     operator=None) -> int:
        """
        Make an order in hbclient.trade.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param account_type: Account type. (mandatory)
        :param order_type: The order type. (mandatory)
        :param amount: The amount to buy (quote currency) or to sell (base currency). (mandatory)
        :param price: The limit price of limit order, only needed for limit order. (mandatory for buy-limit, sell-limit, buy-limit-maker and sell-limit-maker)
        :param client_order_id: unique Id which is user defined and must be unique in recent 24 hours
        :param stop_price: Price for auto sell to get the max benefit
        :param operator: the condition for stop_price, value can be "gte" or "lte",  gte – greater than and equal (>=), lte – less than and equal (<=)
        :return: The order id.
        """
        return call_sync(
            self.request_impl.create_order(symbol, account_type, order_type,
                                           amount, price, client_order_id,
                                           stop_price, operator))
Exemplo n.º 9
0
    def get_best_quote(self, symbol: 'str') -> BestQuote:
        """
        Get the best bid and ask.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :return: The best quote.
        """
        return call_sync(self.request_impl.get_best_quote(symbol))
Exemplo n.º 10
0
    def get_24h_trade_statistics(self, symbol: 'str') -> TradeStatistics:
        """
        Get trade statistics in 24 hours.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :return: Trade statistics.
        """
        return call_sync(self.request_impl.get_24h_trade_statistics(symbol))
Exemplo n.º 11
0
    def get_market_trade(self, symbol: 'str') -> list:
        """
        Get the most recent trades with their price, volume and direction.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :return: The list of trade.
        """
        return call_sync(self.request_impl.get_market_trade(symbol))
Exemplo n.º 12
0
    def post_cancel_withdraw(self, withdraw_id: 'int') -> int:
        """
        Cancel an withdraw request.

        :param withdraw_id: withdraw id (mandatory)
        :return: No return.
        """
        return call_sync(self.request_impl.post_cancel_withdraw(withdraw_id))
Exemplo n.º 13
0
    def get_fee_rate(self, symbols: 'str') -> list:
        """
        The request of get open orders.

        :param symbols: The symbol, like "btcusdt,htusdt". (mandatory)
        :return: The fee information.
        """
        return call_sync(self.request_impl.get_fee_rate(symbols))
Exemplo n.º 14
0
    def get_current_user_aggregated_balance(self):
        """
        Get the aggregated balance of all sub-accounts of the current user.

        :return: The balance of all the sub-account aggregated.
        """
        return call_sync(
            self.request_impl.get_current_user_aggregated_balance())
Exemplo n.º 15
0
    def get_specify_account_balance(self, sub_id):
        """
        Get account balance of a sub-account.

        :param sub_id: the specified sub account id to get balance for.
        :return: the balance of a sub-account specified by sub-account uid.
        """
        return call_sync(self.request_impl.get_specify_account_balance(sub_id))
Exemplo n.º 16
0
    def cancel_client_order(self, client_order_id: 'str') -> None:
        """
        Request to cancel open orders.

        :param client_order_id: user defined unique order id
        """
        return call_sync(
            self.request_impl.cancel_client_order(client_order_id))
Exemplo n.º 17
0
    def get_account_deposit_address(self, currency: 'str') -> list:
        """
        Get deposit address of corresponding chain, for a specific crypto currency (except IOTA)

        :param currency: The currency, like "btc". (optional)
        :return:
        """
        return call_sync(
            self.request_impl.get_account_deposit_address(currency))
Exemplo n.º 18
0
    def get_exchange_timestamp(self) -> int:
        """
        Get the timestamp from Huobi server. The timestamp is the Unix timestamp in millisecond.
        The count shows how many milliseconds passed from Jan 1st 1970, 00:00:00.000 at UTC.
        e.g. 1546300800000 is Thu, 1st Jan 2019 00:00:00.000 UTC.

        :return: The timestamp in UTC
        """
        return call_sync(self.request_impl.get_exchange_timestamp())
Exemplo n.º 19
0
    def get_exchange_symbol_list(self) -> list():
        """
        Get all the trading assets and currencies supported in hbclient.trade.
        The information of trading instrument etc.

        :return: The information of trading instrument.
        """
        symbol_list = call_sync(self.request_impl.get_symbols())
        return symbol_list
Exemplo n.º 20
0
    def get_match_results_by_order_id(self, order_id: 'int') -> list:
        """
        Get detail match results of an order.

        :param order_id: The order id. (mandatory)
        :return: The list of match result.
        """
        return call_sync(
            self.request_impl.get_match_results_by_order_id(order_id))
Exemplo n.º 21
0
    def get_exchange_currencies(self) -> list():
        """
        Get all the trading assets and currencies supported in hbclient.trade.
        The information of trading instrument, including base currency, quote precision, etc.

        :return: The information of trading currencies.
        """
        currencies = call_sync(self.request_impl.get_currencies())
        return currencies
Exemplo n.º 22
0
    def get_order(self, symbol: 'str', order_id: 'int') -> Order:
        """
        Get the details of an order.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param order_id: The order id. (mandatory)
        :return: The information of order.
        """
        return call_sync(self.request_impl.get_order(symbol, order_id))
Exemplo n.º 23
0
    def get_account_withdraw_quota(self, currency: 'str') -> list:
        """
        Get the withdraw quota for currencies

        :param currency: The currency, like "btc". (mandatory)
        :return:
        """
        return call_sync(
            self.request_impl.get_account_withdraw_quota(currency))
Exemplo n.º 24
0
    def repay_loan(self, load_id: 'int', amount: 'float') -> int:
        """
        Get the margin loan records.

        :param load_id: The previously returned order id when loan order was created. (mandatory)
        :param amount: The amount of currency to repay. (mandatory)
        :return: The margin order id.
        """
        return call_sync(self.request_impl.repay_loan(load_id, amount))
Exemplo n.º 25
0
    def get_order_by_client_order_id(self, client_order_id: 'str') -> Order:
        """
        Get the details of an order.

        :param client_order_id: The user defined unique order id. (mandatory)
        :return: The information of order.
        """
        return call_sync(
            self.request_impl.get_order_by_client_order_id(client_order_id))
Exemplo n.º 26
0
    def get_price_depth(self, symbol: 'str', size: 'int' = 20) -> PriceDepth:
        """
        Get the Market Depth of a symbol.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param size: The maximum number of Market Depth requested. range [1 - 150], default is 20. (optional)
        :return: Market Depth data.
        """
        return call_sync(self.request_impl.get_price_depth(symbol, size))
Exemplo n.º 27
0
    def get_historical_trade(self, symbol: 'str', size: 'int' = 1) -> list:
        """
        Get the most recent trades with their price, volume and direction.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param size: The number of historical trade requested, range [1 - 2000], default is 1 (optional)
        :return: The list of trade.
        """
        return call_sync(
            self.request_impl.get_historical_trade(symbol, None, size))
Exemplo n.º 28
0
    def get_etf_swap_config(self, etf_symbol: 'str') -> EtfSwapConfig:
        """
        Get the basic information of ETF creation and redemption, as well as ETF constituents,
        including max amount of creation, min amount of creation, max amount of redemption, min amount
        of redemption, creation fee rate, redemption fee rate, eft create/redeem status.

        :param etf_symbol: The symbol, currently only support hb10. (mandatory)
        :return: The etf configuration information.
        """
        return call_sync(self.request_impl.get_etf_swap_config(etf_symbol))
Exemplo n.º 29
0
    def get_last_trade(self, symbol: 'str') -> Trade:
        """
        Get the last trade with their price, volume and direction.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :return: The last trade with price and amount.
        """
        trade_list = call_sync(
            self.request_impl.get_historical_trade(symbol, None, 1))
        if trade_list is not None and len(trade_list) != 0:
            return trade_list[0]
Exemplo n.º 30
0
    def post_cross_margin_transfer_out(self, currency: 'str',
                                       amount: 'float') -> int:
        """
        transfer currency out from cross account.

        :param currency: currency name (mandatory)
        :param amount: transfer amount (mandatory)
        :return: return transfer id.
        """
        return call_sync(
            self.request_impl.post_cross_margin_transfer_out(currency, amount))