예제 #1
0
    def post_account_transfer(self, from_user: '******', from_account_type: 'str',
                              from_account: 'int', to_user: '******',
                              to_account_type: 'str', to_account: 'int',
                              currency: 'str', amount: 'str'):
        check_should_not_none(from_user, "from-user")
        check_should_not_none(from_account_type, "from-account-type")
        check_should_not_none(from_account, "from_account")
        check_should_not_none(to_user, "to-user")
        check_should_not_none(to_account, "to-account")
        check_should_not_none(to_account_type, "to-account")
        check_should_not_none(currency, "currency")

        check_in_list(from_account_type, [AccountType.SPOT],
                      "from_account_type")
        check_in_list(to_account_type, [AccountType.SPOT], "to_account_type")

        params = {
            "from-user": from_user,
            "from-account-type": from_account_type,
            "from-account": from_account,
            "to-user": to_user,
            "to-account-type": to_account_type,
            "to-account": to_account,
            "currency": currency,
            "amount": amount
        }
        from huobi.service.account.post_account_transfer import PostAccountTransferService
        return PostAccountTransferService(params).request(**self.__kwargs)
예제 #2
0
    def sub_mbp_full(self,
                     symbols: 'str',
                     levels: 'int',
                     callback,
                     error_handler=None):
        """
        Subscribe full mbp event. If the mbp is updated, server will send the data to client and onReceive in callback will be called.

        :param symbols: The symbols, like "btcusdt". Use comma to separate multi symbols, like "btcusdt,ethusdt".
        :param levels: level, 5,10,20
        :param callback: The implementation is required. onReceive will be called if receive server's update.
            example: def callback(price_depth_event: 'PriceDepthEvent'):
                        pass
        :param error_handler: The error handler will be called if subscription failed or error happen between client and Huobi server
            example: def error_handler(exception: 'HuobiApiException')
                        pass

        :return:  No return
        """
        check_should_not_none(symbols, "symbol")
        symbol_list = symbols.split(",")
        check_symbol_list(symbol_list)
        check_should_not_none(levels, "levels")
        check_in_list(levels, [MbpLevel.MBP5, MbpLevel.MBP10, MbpLevel.MBP20],
                      "levels")
        check_should_not_none(callback, "callback")

        params = {"symbol_list": symbol_list, "levels": levels}

        from huobi.service.market.sub_mbp_full import SubMbpFullService
        SubMbpFullService(params).subscribe(callback, error_handler,
                                            **self.__kwargs)
예제 #3
0
    def get_pricedepth(self, symbol: 'str', depth_type: 'str', depth_size: 'int' = None) -> PriceDepth:
        """
        Get the Market Depth of a symbol.

        :param symbol: The symbol, like "btcusdt". (mandatory)
        :param depth_type: The tpye, like "step0" to "step5". (mandatory)
        :param depth_size(optional): The maximum number of Market Depth step0 requested. range [1 - 150], default is 150
                           The maximum number of Market Depth step1,step2,step3,step4,step5 requested. size is in [5, 10, 20], default is 20.
        :return: Market Depth data.
        """

        check_symbol(symbol)
        check_in_list(depth_type, [DepthStep.STEP0, DepthStep.STEP1, DepthStep.STEP2, DepthStep.STEP3, DepthStep.STEP4, DepthStep.STEP5], "depth_type")
        params = {
            "symbol": symbol,
            "type": depth_type,
            # "depth": depth_size
        }

        from huobi.service.market.get_pricedepth import GetPriceDepthService
        ret_data = GetPriceDepthService(params).request(**self.__kwargs)

        if depth_size is not None:
            if (ret_data.bids is not None) and (len(ret_data.bids) > depth_size):
                ret_data.bids = ret_data.bids[0:depth_size]

            if (ret_data.asks is not None) and (len(ret_data.asks) > depth_size):
                ret_data.asks = ret_data.asks[0:depth_size]

        return ret_data
예제 #4
0
    def post_set_subuser_transferability(
            self,
            sub_uids: 'str',
            transferrable: 'bool',
            account_type: 'AccountType' = AccountType.SPOT):
        check_should_not_none(sub_uids, 'subUids')
        check_should_not_none(transferrable, 'transferrable')
        check_in_list(account_type, [AccountType.SPOT], 'accountType')

        params = {
            "subUids": sub_uids,
            "accountType": account_type,
            "transferrable": transferrable
        }
        from huobi.service.subuser.post_set_transferability import PostSetSubuserTransferability
        return PostSetSubuserTransferability(params).request(**self.__kwargs)
예제 #5
0
    def post_set_tradable_market(self, sub_uids,
                                 account_type: 'SubuserTradePrivilegeType',
                                 activation: 'SubUserTradeStatus'):
        check_should_not_none(sub_uids, 'subUids')
        check_should_not_none(account_type, 'accountType')
        check_should_not_none(activation, 'activation')

        check_in_list(account_type, [
            SubuserTradePrivilegeType.MARGIN,
            SubuserTradePrivilegeType.SUPER_MARGIN
        ], "accountType")
        check_in_list(
            activation,
            [SubUserTradeStatus.ACTIVATED, SubUserTradeStatus.DEACTIVATED],
            "activation")

        params = {
            'subUids': sub_uids,
            'accountType': account_type,
            'activation': activation
        }
        from huobi.service.subuser.post_tradable_market import PostTradableMarketService
        return PostTradableMarketService(params).request(**self.__kwargs)