Ejemplo n.º 1
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))
Ejemplo 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))
Ejemplo n.º 3
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))
Ejemplo n.º 4
0
    def get_exchange_info(self) -> ExchangeInfo:
        """
        Get all the trading assets and currencies supported in huobi.
        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
Ejemplo n.º 5
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
Ejemplo n.º 6
0
    def get_account_balance(self) -> list:
        """
        Get the balance of future account.

        :return: The information of all account balance.
        """
        return call_sync(self.request_impl.get_accounts())
Ejemplo n.º 7
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())
Ejemplo n.º 8
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))
Ejemplo n.º 9
0
    def get_margin_balance_detail(self, symbol: 'str') -> list:
        """
        Get the Balance of the Margin Loan Account.

        :param symbol: The currency, like "btc". (mandatory)
        :return: The margin loan account detail list.
        """
        return call_sync(self.request_impl.get_margin_balance_detail(symbol))
Ejemplo n.º 10
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))
Ejemplo n.º 11
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))
Ejemplo n.º 12
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))
Ejemplo n.º 13
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))
Ejemplo n.º 14
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())
Ejemplo n.º 15
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))
Ejemplo n.º 16
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))
Ejemplo n.º 17
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))
Ejemplo n.º 18
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]
Ejemplo n.º 19
0
    def get_match_results_by_order_id(self, symbol: 'str',
                                      order_id: 'int') -> list:
        """
        Get detail match results of an order.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :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(symbol, order_id))
Ejemplo n.º 20
0
    def etf_swap(self, etf_symbol: 'str', amount: 'int',
                 swap_type: 'EtfSwapType') -> None:
        """
        Order creation or redemption of ETF.

        :param etf_symbol: The symbol, currently only support hb10. (mandatory)
        :param amount: The amount to create or redemption. (mandatory)
        :param swap_type: The swap type to indicate creation or redemption. (mandatory)
        :return: No return
        """
        return call_sync(
            self.request_impl.etf_swap(etf_symbol, amount, swap_type))
Ejemplo n.º 21
0
    def get_withdraw_history(self, currency: 'str', from_id: 'int',
                             size: 'int') -> list:
        """
        Get the withdraw records of an account.

        :param currency: The currency, like "btc". (mandatory)
        :param from_id: The beginning withdraw record id. (mandatory)
        :param size: The size of record. (mandatory)
        :return: The list of withdraw records.
        """
        return call_sync(
            self.request_impl.get_withdraw_history(currency, from_id, size))
Ejemplo n.º 22
0
    def get_etf_swap_history(self, etf_symbol: 'str', offset: 'int',
                             size: 'int') -> list:
        """
        Get past creation and redemption.(up to 100 records)

        :param etf_symbol: The symbol, currently only support hb10. (mandatory)
        :param offset: The offset of the records, set to 0 for the latest records. (mandatory)
        :param size: The number of records to return, the range is [1, 100]. (mandatory)
        :return: The swap history.
        """
        return call_sync(
            self.request_impl.get_etf_swap_config(etf_symbol, offset, size))
Ejemplo n.º 23
0
    def apply_loan(self, symbol: 'str', currency: 'str',
                   amount: 'float') -> int:
        """
        Submit a request to borrow with margin account.

        :param symbol: The trading symbol to borrow margin, e.g. "btcusdt", "bccbtc". (mandatory)
        :param currency: The currency to borrow,like "btc". (mandatory)
        :param amount: The amount of currency to borrow. (mandatory)
        :return: The margin order id.
        """
        return call_sync(self.request_impl.apply_loan(symbol, currency,
                                                      amount))
Ejemplo n.º 24
0
    def get_etf_candlestick(self,
                            etf_symbol: 'str',
                            interval: 'CandlestickInterval',
                            size: 'int' = None) -> list:
        """
        Get the latest candlestick/kline for the etf.

        :param etf_symbol: The symbol, currently only support hb10. (mandatory)
        :param interval: The candlestick/kline interval, MIN1, MIN5, DAY1 etc. (mandatory)
        :param size: The maximum number of candlestick/kline requested. Range [1 - 2000] (optional)
        :return: The list of candlestick/kline data.
        """
        return call_sync(
            self.request_impl.get_etf_candlestick(etf_symbol, interval, size))
Ejemplo n.º 25
0
    def get_latest_candlestick(self,
                               symbol: 'str',
                               interval: 'CandlestickInterval',
                               size: 'int' = 150) -> list:
        """
        Get the latest candlestick/kline for the specified symbol.

        :param symbol: The symbol, like "btcusdt". To query hb10, put "hb10" at here. (mandatory)
        :param interval: The candlestick/kline interval, MIN1, MIN5, DAY1 etc. (mandatory)
        :param size: The maximum number of candlestick/kline requested. Range [1 - 2000] (mandatory)
        :return: The list of candlestick/kline data.
        """
        return call_sync(
            self.request_impl.get_candlestick(symbol, interval, size, None,
                                              None))
Ejemplo n.º 26
0
    def transfer_between_parent_and_sub(self, sub_uid: 'int', currency: 'str',
                                        amount: 'float',
                                        transfer_type: 'TransferMasterType'):
        """
        Transfer Asset between Parent and Sub Account.

        :param sub_uid: The target sub account uid to transfer to or from. (mandatory)
        :param currency: The crypto currency to transfer. (mandatory)
        :param amount: The amount of asset to transfer. (mandatory)
        :param transfer_type: The type of transfer, see {@link TransferMasterType} (mandatory)
        :return: The order id.
        """
        return call_sync(
            self.request_impl.transfer_between_parent_and_sub(
                sub_uid, currency, amount, transfer_type))
Ejemplo n.º 27
0
    def transfer(self, symbol: 'str', from_account: 'AccountType',
                 to_account: 'AccountType', currency: 'str',
                 amount: 'float') -> int:
        """
        Transfer asset from specified account to another account.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param from_account: The type, transfer from which account, could be SPOT or MARGIN. (mandatory)
        :param to_account: The type, transfer to which account, could be SPOT or MARGIN. (mandatory)
        :param currency: The currency of transfer. (mandatory)
        :param amount: The amount of transfer. (mandatory)
        :return:
        """
        return call_sync(
            self.request_impl.transfer(symbol, from_account, to_account,
                                       currency, amount))
Ejemplo n.º 28
0
    def create_order(self, symbol: 'str', account_type: 'AccountType',
                     order_type: 'OrderType', amount: 'float',
                     price: 'float') -> int:
        """
        Make an order in huobi.

        :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)
        :return: The order id.
        """
        return call_sync(
            self.request_impl.create_order(symbol, account_type, order_type,
                                           amount, price))
Ejemplo n.º 29
0
    def get_open_orders(self,
                        symbol: 'str',
                        account_type: 'AccountType',
                        side: 'OrderSide' = None,
                        size: 'int' = 10) -> list:
        """
        The request of get open orders.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param account_type: The order side, buy or sell. If no side defined, will return all open orders of the account. (mandatory)
        :param side: The order side, buy or sell. If no side defined, will return all open orders of the account. (optional)
        :param size: The number of orders to return. Range is [1, 500]. Default is 10. (optional)
        :return: The orders information.
        """
        return call_sync(
            self.request_impl.get_open_orders(symbol, account_type, size,
                                              side))
Ejemplo n.º 30
0
    def cancel_open_orders(self,
                           symbol: 'str',
                           account_type: 'AccountType',
                           side: 'OrderSide' = None,
                           size: 'int' = None) -> BatchCancelResult:
        """
        Request to cancel open orders.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param account_type: Account type. (mandatory)
        :param side: The order side, buy or sell. If no side defined, will cancel all open orders of the account. (optional)
        :param size: The number of orders to cancel. Range is [1, 100]. Default is 100. (optional)
        :return: Status of batch cancel result.
        """
        return call_sync(
            self.request_impl.cancel_open_orders(symbol, account_type, side,
                                                 size))