Ejemplo n.º 1
0
    def post_order(
            self,
            symbol: 'str',
            side: 'OrderSide',
            ordertype: 'OrderType',
            timeInForce: 'TimeInForce' = TimeInForce.INVALID,
            quantity: 'float' = None,
            reduceOnly: 'boolean' = None,
            price: 'float' = None,
            newClientOrderId: 'str' = None,
            stopPrice: 'float' = None,
            workingType: 'WorkingType' = WorkingType.INVALID,
            closePosition: 'boolean' = None,
            positionSide: 'PositionSide' = PositionSide.INVALID,
            callbackRate: 'float' = None,
            activationPrice: 'float' = None,
            newOrderRespType: 'OrderRespType' = OrderRespType.INVALID) -> any:
        """
        New Order (TRADE)

        POST /dapi/v1/order (HMAC SHA256)

        Send in a new order.
        """
        response = call_sync(
            self.request_impl.post_order(symbol, side, ordertype, timeInForce,
                                         quantity, reduceOnly, price,
                                         newClientOrderId, stopPrice,
                                         workingType, closePosition,
                                         positionSide, callbackRate,
                                         activationPrice, newOrderRespType))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 2
0
    def cancel_all_orders(self, symbol: 'str') -> any:
        """
        Cancel All Open Orders (TRADE)

        DELETE /dapi/v1/allOpenOrders (HMAC SHA256)
        """
        response = call_sync(self.request_impl.cancel_all_orders(symbol))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 3
0
    def get_balance(self) -> any:
        """
        Future Account Balance (USER_DATA)

        Get /dapi/v1/balance (HMAC SHA256)
        """
        response = call_sync(self.request_impl.get_balance())
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 4
0
    def change_position_margin(self, symbol: 'str', amount: 'float', type: 'int') -> any:
        """
        Modify Isolated Position Margin (TRADE)

        POST /dapi/v1/positionMargin (HMAC SHA256)
        """
        response = call_sync(self.request_impl.change_position_margin(symbol, amount, type))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 5
0
    def change_margin_type(self, symbol: 'str', marginType: 'FuturesMarginType') -> any:
        """
        Change Margin Type (TRADE)

        POST /dapi/v1/marginType (HMAC SHA256)
        """
        response = call_sync(self.request_impl.change_margin_type(symbol, marginType))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 6
0
    def get_position(self) -> any:
        """
        Position Information (USER_DATA)

        GET /dapi/v1/positionRisk (HMAC SHA256) Get current account information.
        """
        response = call_sync(self.request_impl.get_position())
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 7
0
    def get_position_margin_change_history(self, symbol: 'str', type: 'int' = None, startTime: 'int' = None, endTime: 'int' = None, limit :'int' = None) -> any:
        """
        Get Position Margin Change History (TRADE)

        GET /dapi/v1/positionMargin/history (HMAC SHA256)
        """
        response = call_sync(self.request_impl.get_position_margin_change_history(symbol, type, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 8
0
    def get_funding_rate(self, symbol: 'str', startTime: 'long' = None, endTime: 'str' = None, limit: 'int' = None) -> any:
        """
        Get Funding Rate History (MARKET_DATA)

        GET /dapi/v1/fundingRate
        """
        response = call_sync(self.request_impl.get_funding_rate(symbol, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 9
0
    def get_leverage_bracket(self, pair: 'str' = None) -> any:
        """
        Notional and Leverage Brackets (USER_DATA)

        GET /dapi/v1/leverageBracket
        """
        response = call_sync(self.request_impl.get_leverage_bracket(pair))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 10
0
    def get_adl_quantile(self, symbol: 'str' = None) -> any:
        """
        Position ADL Quantile Estimation (USER_DATA)

        GET /dapi/v1/adlQuantile
        """
        response = call_sync(self.request_impl.get_adl_quantile(symbol))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 11
0
    def cancel_list_orders(self, symbol: 'str', orderIdList: 'list' = None, origClientOrderIdList: 'list' = None) -> any:
        """
        Cancel Multiple Orders (TRADE)

        DELETE /dapi/v1/batchOrders (HMAC SHA256)
        """
        response = call_sync(self.request_impl.cancel_list_orders(symbol, orderIdList, origClientOrderIdList))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 12
0
    def get_liquidation_orders(self, symbol: 'str' = None, startTime: 'long' = None, endTime: 'str' = None, 
                                limit: 'int' = None) -> any:
        """
        Get all Liquidation Orders (MARKET_DATA)

        GET /dapi/v1/allForceOrders
        """
        response = call_sync(self.request_impl.get_liquidation_orders(symbol, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 13
0
    def get_basis(self, pair: 'str', contractType: 'str', period: 'str', startTime: 'str' = None, endTime: 'str' = None, limit: 'int' = 30) -> any:
        """
        Basis (MARKET DATA)

        GET /futures/data/basis

        """
        response = call_sync(self.request_impl.get_basis(pair, contractType, period, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 14
0
    def get_taker_buy_sell_vol(self, pair: 'str', contractType: 'str', period: 'str', startTime: 'str' = None, endTime: 'str' = None, limit: 'int' = 30) -> any:
        """
        Taker Buy/Sell Volume (MARKET_DATA)

        GET /futures/data/takerBuySellVol

        """
        response = call_sync(self.request_impl.get_taker_buy_sell_vol(pair, contractType, period, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 15
0
    def get_global_long_short_accounts(self, pair: 'str', period: 'str', startTime: 'str' = None, endTime: 'str' = None, limit: 'int' = 30) -> any:
        """
        Long/Short Ratio (MARKET_DATA)

        GET /futures/data/globalLongShortAccountRatio

        """
        response = call_sync(self.request_impl.get_global_long_short_accounts(pair, period, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 16
0
    def get_top_long_short_positions(self, pair: 'str', period: 'str', startTime: 'str' = None, endTime: 'str' = None, limit: 'int' = 30) -> any:
        """
        Top Trader Long/Short Ratio (Positions)

        GET /futures/data/topLongShortPositionRatio

        """
        response = call_sync(self.request_impl.get_top_long_short_positions(pair, period, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 17
0
    def get_open_interest_stats(self, pair: 'str', contractType: 'str', period: 'str', startTime: 'str' = None, endTime: 'str' = None, limit: 'int' = 30) -> any:
        """
        Open Interest Statistics (MARKET_DATA)

        GET /futures/data/openInterestHist

        """
        response = call_sync(self.request_impl.get_open_interest_stats(pair, contractType, period, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 18
0
    def get_income_history(self, symbol: 'str' = None, incomeType: 'IncomeType' = IncomeType.INVALID, 
                        startTime: 'long' = None, endTime: 'long' = None, limit: 'int' = None) -> any:
        """
        Get Income History(USER_DATA)

        GET /dapi/v1/income (HMAC SHA256)
        """
        response = call_sync(self.request_impl.get_income_history(symbol, incomeType, startTime, endTime, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 19
0
    def get_old_trade_lookup(self, symbol: 'str', limit: 'int' = None, fromId: 'long' = None) -> any:
        """
        Old Trades Lookup (MARKET_DATA)

        GET /dapi/v1/historicalTrades

        Get older market historical trades.
        """
        response = call_sync(self.request_impl.get_old_trade_lookup(symbol, limit, fromId))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 20
0
    def get_recent_trades_list(self, symbol: 'str', limit: 'int' = None) -> any:
        """
        Recent Trades List (MARKET_DATA)

        GET /dapi/v1/trades

        Get recent trades (up to last 500).
        """
        response = call_sync(self.request_impl.get_recent_trades_list(symbol, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 21
0
    def get_order_book(self, symbol: 'str', limit: 'int' = None) -> any:
        """
        Order Book (MARKET_DATA)

        GET /dapi/v1/depth

        Adjusted based on the limit:
        """
        response = call_sync(self.request_impl.get_order_book(symbol, limit))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 22
0
    def close_user_data_stream(self) -> any:
        """
        Close User Data Stream (USER_STREAM)

        DELETE /dapi/v1/listenKey (HMAC SHA256)

        Close out a user data stream.
        """
        response = call_sync(self.request_impl.close_user_data_stream())
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 23
0
    def get_exchange_information(self) -> any:
        """
        Exchange Information (MARKET_DATA)

        GET /dapi/v1/exchangeInfo

        Current exchange trading rules and symbol information
        """
        response = call_sync(self.request_impl.get_exchange_information())
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 24
0
    def get_position_mode(self) -> any:
        """
        Get Current Position Mode (USER_DATA)

        GET /dapi/v1/positionSide/dual (HMAC SHA256)

        Get user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol
        """
        response = call_sync(self.request_impl.get_position_mode())
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 25
0
    def change_position_mode(self, dualSidePosition: 'boolean' = None) -> any:
        """
        Change Current Position Mode (TRADE)

        POST /dapi/v1/positionSide/dual (HMAC SHA256)

        Change user's position mode (Hedge Mode or One-way Mode ) on EVERY symbol
        """
        response = call_sync(self.request_impl.change_position_mode(dualSidePosition))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 26
0
    def get_order(self, symbol: 'str', orderId: 'long' = None, origClientOrderId: 'str' = None) -> any:
        """
        Query Order (USER_DATA)

        GET /dapi/v1/order (HMAC SHA256)

        Check an order's status.
        """
        response = call_sync(self.request_impl.get_order(symbol, orderId, origClientOrderId))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 27
0
    def cancel_order(self, symbol: 'str', orderId: 'long' = None, origClientOrderId: 'str' = None) -> any:
        """
        Cancel Order (TRADE)

        DELETE /dapi/v1/order (HMAC SHA256)

        Cancel an active order.
        """
        response = call_sync(self.request_impl.cancel_order(symbol, orderId, origClientOrderId))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 28
0
    def change_initial_leverage(self, symbol: 'str', leverage: 'int') -> any:
        """
        Change Initial Leverage (TRADE)

        POST /dapi/v1/leverage (HMAC SHA256)

        Change user's initial leverage of specific symbol market.
        """
        response = call_sync(self.request_impl.change_initial_leverage(symbol, leverage))
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 29
0
    def get_servertime(self) -> any:
        """
        Check Server Time

        GET /dapi/v1/time

        Test connectivity to the Rest API and get the current server time.
        """
        response = call_sync(self.request_impl.get_servertime())
        self.refresh_limits(response[1])
        return response[0]
Ejemplo n.º 30
0
    def get_open_orders(self, symbol: 'str' = None) -> any:
        """
        Current Open Orders (USER_DATA)

        GET /dapi/v1/openOrders (HMAC SHA256)

        Get all open orders on a symbol. Careful when accessing this with no symbol.
        """
        response = call_sync(self.request_impl.get_open_orders(symbol))
        self.refresh_limits(response[1])
        return response[0]