コード例 #1
0
    async def get_position_margin_change_history(
            self,
            pair: Pair,
            limit: int = None,
            type: int = None,
            start_tmstmp_ms: int = None,
            end_tmstmp_ms: int = None,
            recv_window_ms: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol":
            map_pair(pair),
            "limit":
            limit,
            "type":
            type,
            "startTime":
            start_tmstmp_ms,
            "endTime":
            end_tmstmp_ms,
            "recvWindow":
            recv_window_ms,
            "timestamp":
            self._get_current_timestamp_ms()
        })

        return await self._create_get(
            "positionMargin/history",
            params=params,
            headers=self._get_header(),
            signed=True,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #2
0
    async def get_account_trades(self,
                                 pair: Pair,
                                 limit: int = None,
                                 from_id: int = None,
                                 start_tmstmp_ms: int = None,
                                 end_tmstmp_ms: int = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol":
            map_pair(pair),
            "limit":
            limit,
            "fromId":
            from_id,
            "startTime":
            start_tmstmp_ms,
            "endTime":
            end_tmstmp_ms,
            "timestamp":
            self._get_current_timestamp_ms()
        })

        return await self._create_get("myTrades",
                                      params=params,
                                      headers=self._get_header(),
                                      signed=True,
                                      api_variable_path=BinanceClient.API_V3)
コード例 #3
0
    async def create_test_order(self, pair: Pair, side: enums.OrderSide, type: enums.OrderType,
                                quantity: str,
                                price: str = None,
                                stop_price: str = None,
                                quote_order_quantity: str = None,
                                time_in_force: enums.TimeInForce = None,
                                new_client_order_id: str = None,
                                iceberg_quantity: str = None,
                                new_order_response_type: enums.OrderResponseType = None,
                                recv_window_ms: int = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol": map_pair(pair),
            "side": side.value,
            "type": type.value,
            "quantity": quantity,
            "quoteOrderQty": quote_order_quantity,
            "price": price,
            "stopPrice": stop_price,
            "newClientOrderId": new_client_order_id,
            "icebergQty": iceberg_quantity,
            "recvWindow": recv_window_ms,
            "timestamp": self._get_current_timestamp_ms()
        })

        if time_in_force:
            params['timeInForce'] = time_in_force.value

        if new_order_response_type:
            params['newOrderRespType'] = new_order_response_type.value

        return await self._create_post("order/test", params = params, headers = self._get_header(),
                                       signed = True)
コード例 #4
0
    async def get_trades(self, pair: Pair, limit: int = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol": map_pair(pair),
            "limit": limit
        })

        return await self._create_get("trades", params = params)
コード例 #5
0
    async def update_isolated_position_margin(
            self,
            pair: Pair,
            quantity: str,
            type: int,
            position_side: enums.PositionSide = None,
            recv_window_ms: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol":
            map_pair(pair),
            "amount":
            quantity,
            "type":
            type,
            "recvWindow":
            recv_window_ms,
            "timestamp":
            self._get_current_timestamp_ms()
        })

        if position_side is not None:
            params['positionSide'] = position_side.value

        return await self._create_post(
            "positionMargin",
            params=params,
            headers=self._get_header(),
            signed=True,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #6
0
    async def get_all_orders(self,
                             pair: Pair,
                             order_id: int = None,
                             limit: int = None,
                             start_tmstmp_ms: int = None,
                             end_tmstmp_ms: int = None,
                             recv_window_ms: int = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol":
            map_pair(pair),
            "orderId":
            order_id,
            "startTime":
            start_tmstmp_ms,
            "endTime":
            end_tmstmp_ms,
            "limit":
            limit,
            "recvWindow":
            recv_window_ms,
            "timestamp":
            self._get_current_timestamp_ms()
        })

        return await self._create_get("allOrders",
                                      params=params,
                                      headers=self._get_header(),
                                      signed=True,
                                      api_variable_path=BinanceClient.API_V3)
コード例 #7
0
    async def get_global_long_short_account_ratio(
            self,
            pair: Pair,
            interval: enums.Interval,
            limit: int = None,
            start_tmstmp_ms: int = None,
            end_tmstmp_ms: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol":
            map_pair(pair),
            "period":
            interval.value,
            "limit":
            limit,
            "startTime":
            start_tmstmp_ms,
            "endTime":
            end_tmstmp_ms
        })

        return await self._create_get(
            "globalLongShortAccountRatio",
            headers=self._get_header(),
            params=params,
            api_variable_path=BinanceUSDSMFuturesClient.FUTURES)
コード例 #8
0
    async def get_average_price(self, pair: Pair) -> dict:
        params = BinanceClient._clean_request_params(
            {"symbol": map_pair(pair)})

        return await self._create_get("avgPrice",
                                      params=params,
                                      api_variable_path=BinanceClient.API_V3)
コード例 #9
0
    async def cancel_oco_order(self,
                               pair: Pair,
                               order_list_id: str = None,
                               list_client_order_id: str = None,
                               new_client_order_id: str = None,
                               recv_window_ms: int = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol":
            map_pair(pair),
            "orderListId":
            order_list_id,
            "listClientOrderId":
            list_client_order_id,
            "newClientOrderId":
            new_client_order_id,
            "recvWindow":
            recv_window_ms,
            "timestamp":
            self._get_current_timestamp_ms()
        })

        return await self._create_delete(
            "orderList",
            params=params,
            headers=self._get_header(),
            signed=True,
            api_variable_path=BinanceClient.API_V3)
コード例 #10
0
    async def get_cont_contract_candlesticks(
            self,
            pair: Pair,
            interval: enums.Interval,
            contract_type: enums.ContractType,
            limit: int = None,
            start_tmstmp_ms: int = None,
            end_tmstmp_ms: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "pair":
            map_pair(pair),
            "contractType":
            contract_type.value,
            "limit":
            limit,
            "startTime":
            start_tmstmp_ms,
            "endTime":
            end_tmstmp_ms
        })

        if interval:
            params['interval'] = interval.value

        return await self._create_get(
            "continuousKlines",
            params=params,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #11
0
    async def get_trades(self, pair: Pair, limit: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol": map_pair(pair),
            "limit": limit
        })

        return await self._create_get("trades", params = params, api_variable_path = BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #12
0
    async def get_income_history(self,
                                 pair: Pair = None,
                                 limit: int = None,
                                 income_type: enums.IncomeType = None,
                                 start_tmstmp_ms: int = None,
                                 end_tmstmp_ms: int = None,
                                 recv_window_ms: Optional[int] = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "limit":
            limit,
            "startTime":
            start_tmstmp_ms,
            "endTime":
            end_tmstmp_ms,
            "timestamp":
            self._get_current_timestamp_ms(),
            "recvWindow":
            recv_window_ms
        })

        if pair is not None:
            params['symbol'] = map_pair(pair)

        if income_type is not None:
            params['incomeType'] = income_type.value

        return await self._create_get(
            "income",
            params=params,
            headers=self._get_header(),
            signed=True,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #13
0
    async def get_account_trades(self,
                                 pair: Pair,
                                 limit: int = None,
                                 from_id: int = None,
                                 start_tmstmp_ms: int = None,
                                 end_tmstmp_ms: int = None,
                                 recv_window_ms: Optional[int] = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol":
            map_pair(pair),
            "limit":
            limit,
            "fromId":
            from_id,
            "startTime":
            start_tmstmp_ms,
            "endTime":
            end_tmstmp_ms,
            "timestamp":
            self._get_current_timestamp_ms(),
            "recvWindow":
            recv_window_ms
        })

        return await self._create_get(
            "userTrades",
            params=params,
            headers=self._get_header(),
            signed=True,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #14
0
    async def get_open_interest(self, pair: Pair) -> dict:
        params = {"symbol": map_pair(pair)}

        return await self._create_get(
            "openInterest",
            headers=self._get_header(),
            params=params,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #15
0
    async def get_historical_trades(self, pair: Pair, limit: int = None, from_id: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol": map_pair(pair),
            "limit": limit,
            "fromId": from_id
        })

        return await self._create_get("historicalTrades", params = params, headers = self._get_header(), api_variable_path = BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #16
0
    async def get_commission_rate(self, pair: Pair, recv_window_ms: Optional[int] = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol": map_pair(pair),
            "timestamp": self._get_current_timestamp_ms(),
            "recvWindow": recv_window_ms
        })

        return await self._create_get("commissionRate", params = params, headers = self._get_header(), signed = True, api_variable_path = BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #17
0
    async def get_all_open_orders(self, pair: Pair, recv_window_ms: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol": map_pair(pair),
            "recvWindow": recv_window_ms,
            "timestamp": self._get_current_timestamp_ms()
        })

        return await self._create_get("openOrders", params = params, headers = self._get_header(), signed = True, api_variable_path = BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #18
0
    async def get_price_ticker(self, pair: Pair = None) -> dict:
        params = {}
        if pair is not None:
            params['symbol'] = map_pair(pair)

        return await self._create_get("ticker/price",
                                      params=params,
                                      api_variable_path=BinanceClient.API_V3)
コード例 #19
0
    async def get_historical_trades(self, pair: Pair, limit: int = None, from_id: int = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol": map_pair(pair),
            "limit": limit,
            "fromId": from_id
        })

        return await self._create_get("historicalTrades", params = params, headers = self._get_header())
コード例 #20
0
    async def auto_cancel_orders(self, pair: Pair, countdown_time_ms: int, recv_window_ms: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol": map_pair(pair),
            "countdownTime": countdown_time_ms,
            "recvWindow": recv_window_ms,
            "timestamp": self._get_current_timestamp_ms()
        })

        return await self._create_delete("countdownCancelAll", params = params, headers = self._get_header(), signed = True, api_variable_path = BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #21
0
    async def get_mark_price(self, pair: Pair = None) -> dict:
        params = {}
        if pair is not None:
            params['symbol'] = map_pair(pair)

        return await self._create_get(
            "premiumIndex",
            params=params,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #22
0
    async def get_orderbook(self, pair: Pair, limit: enums.DepthLimit = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol": map_pair(pair),
        })

        if limit:
            params['limit'] = limit.value

        return await self._create_get("depth", params = params)
コード例 #23
0
    async def get_orderbook(self, pair: Pair, limit: enums.DepthLimit = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol": map_pair(pair),
        })

        if limit:
            params['limit'] = limit.value

        return await self._create_get("depth", params = params, api_variable_path = BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #24
0
    async def change_margin_type(self, pair: Pair, margin_type: enums.MarginType, recv_window_ms: int = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "symbol": map_pair(pair),
            "marginType": margin_type.value,
            "recvWindow": recv_window_ms,
            "timestamp": self._get_current_timestamp_ms()
        })

        return await self._create_post("marginType", params = params, headers = self._get_header(), signed = True, api_variable_path = BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #25
0
    async def create_oco_order(
            self,
            pair: Pair,
            side: enums.OrderSide,
            quantity: str,
            price: str,
            stop_price: str,
            limit_client_order_id: str = None,
            list_client_order_id: str = None,
            limit_iceberg_quantity: str = None,
            stop_client_order_id: str = None,
            stop_limit_price: str = None,
            stop_iceberg_quantity: str = None,
            stop_limit_time_in_force: enums.TimeInForce = None,
            new_order_response_type: enums.OrderResponseType = None,
            recv_window_ms: int = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol":
            map_pair(pair),
            "side":
            side.value,
            "quantity":
            quantity,
            "listClientOrderId":
            list_client_order_id,
            "limitClientOrderId":
            limit_client_order_id,
            "price":
            price,
            "stopClientOrderId":
            stop_client_order_id,
            "stopPrice":
            stop_price,
            "stopLimitPrice":
            stop_limit_price,
            "stopIcebergQty":
            stop_iceberg_quantity,
            "limitIcebergQty":
            limit_iceberg_quantity,
            "recvWindow":
            recv_window_ms,
            "timestamp":
            self._get_current_timestamp_ms()
        })

        if stop_limit_time_in_force:
            params['stopLimitTimeInForce'] = stop_limit_time_in_force.value

        if new_order_response_type:
            params['newOrderRespType'] = new_order_response_type.value

        return await self._create_post("order/oco",
                                       params=params,
                                       headers=self._get_header(),
                                       signed=True,
                                       api_variable_path=BinanceClient.API_V3)
コード例 #26
0
    async def get_api_trading_status(self, pair: Pair = None, recv_window_ms: Optional[int] = None) -> dict:
        params = CryptoXLibClient._clean_request_params({
            "timestamp": self._get_current_timestamp_ms(),
            "recvWindow": recv_window_ms
        })

        if pair is not None:
            params['symbol'] = map_pair(pair)

        return await self._create_get("apiTradingStatus", params = params, headers = self._get_header(), signed = True, api_variable_path = BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #27
0
    async def get_best_orderbook_ticker(self,
                                        pair: Optional[Pair] = None) -> dict:
        params = {}
        if pair is not None:
            params['symbol'] = map_pair(pair)

        return await self._create_get("ticker/bookTicker",
                                      headers=self._get_header(),
                                      params=params,
                                      api_variable_path=BinanceClient.API_V3)
コード例 #28
0
    async def get_orderbook_ticker(self, pair: Pair = None) -> dict:
        params = {}
        if pair is not None:
            params['symbol'] = map_pair(pair)

        return await self._create_get(
            "ticker/bookTicker",
            headers=self._get_header(),
            params=params,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #29
0
    async def get_index_info(self, pair: Pair = None) -> dict:
        params = {}
        if pair is not None:
            params['symbol'] = map_pair(pair)

        return await self._create_get(
            "indexInfo",
            headers=self._get_header(),
            params=params,
            api_variable_path=BinanceUSDSMFuturesClient.FAPI_V1)
コード例 #30
0
    async def get_aggregate_trades(self, pair: Pair, limit: int = None, from_id: int = None,
                                   start_tmstmp_ms: int = None, end_tmstmp_ms: int = None) -> dict:
        params = BinanceClient._clean_request_params({
            "symbol": map_pair(pair),
            "limit": limit,
            "fromId": from_id,
            "startTime": start_tmstmp_ms,
            "endTime": end_tmstmp_ms
        })

        return await self._create_get("aggTrades", params = params)