def create_order_param_check(symbol, account_id, order_side, order_type, stop_price, order_price, order_size, order_value, time_in_force, trailing_rate, client_order_id): check_symbol(symbol) check_should_not_none(account_id, "accountId") check_should_not_none(order_type, "orderType") check_should_not_none(order_side, "orderSide") if order_type == OrderType.SELL_LIMIT \ or order_type == OrderType.BUY_LIMIT \ or order_type == OrderType.BUY_LIMIT_MAKER \ or order_type == OrderType.SELL_LIMIT_MAKER: check_should_not_none(order_price, "orderPrice") if time_in_force is not None: check_time_in_force(time_in_force) if order_type in [OrderType.SELL_MARKET, OrderType.BUY_MARKET]: order_price = None params = { "accountId": account_id, "symbol": symbol, "orderPrice": order_price, "orderSide": order_side, "orderSize": order_size, "orderValue": order_value, "timeInForce": time_in_force, "orderType": order_type, "clientOrderId": client_order_id, "stopPrice": stop_price, "trailingRate": trailing_rate } return params
def get_history_trade(self, symbol: str, size: 'int' = None) -> 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] (optional) :return: The list of trade. """ channel = "/market/history/trade" check_symbol(symbol) check_range(size, 1, 2000, "size") params = {"symbol": symbol, "size": size} return self.market_service.request_process(HttpMethod.GET, channel, params)
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. """ channel = "/market/trade" check_symbol(symbol) params = { "symbol": symbol, } return self.market_service.request_process(HttpMethod.GET, channel, params)
def get_market_detail(self, symbol: str): """ Get trade statistics in 24 hours. :param symbol: The symbol, like "btcusdt". (mandatory) :return: Trade statistics. """ channel = "/market/detail" check_symbol(symbol) params = { "symbol": symbol, } return self.market_service.request_process(HttpMethod.GET, channel, params)
def get_candlestick(self, symbol, period, size=200): """ Get the candlestick/kline for the specified symbol. The data number is 150 as default. :param symbol: The symbol, like "btcusdt". To query hb10, put "hb10" at here. (mandatory) :param period: The candlestick/kline interval, MIN1, MIN5, DAY1 etc. (mandatory) :param size: The start time of of requested candlestick/kline data. (optional) :return: The list of candlestick/kline data. """ check_symbol(symbol) check_should_not_none(period, "period") check_range(size, 1, 2000, "size") params = {"symbol": symbol, "period": period, "size": size} channel = "/market/history/kline" return self.market_service.request_process(HttpMethod.GET, channel, params)
def get_price_depth(self, symbol: str, depth_type: str, depth_size: int = None): """ 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. """ channel = "/market/depth" 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 } ret_data = self.market_service.request_process(HttpMethod.GET, channel, params) 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
def get_market_detail_merged(self, symbol): check_symbol(symbol) params = {"symbol": symbol} channel = "/market/detail/merged" return self.market_service.request_process(HttpMethod.GET, channel, params)