Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for hidden private endpoints #53

Open
casper-hansen opened this issue Jan 19, 2023 · 4 comments
Open

Support for hidden private endpoints #53

casper-hansen opened this issue Jan 19, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request will be realized
Milestone

Comments

@casper-hansen
Copy link

Is your feature request related to a problem? Please describe.

The problem with Binance's Futures API is that your take profit, once hit, does not cancel your stop loss, and vice versa. If you can implement the private endpoint, you would eliminate a lot of overhead like listening to the user stream to monitor if you need to cancel a take profit or stop loss.

Describe the solution you'd like.

Upon inspection of the URL Binance uses on their exchange, I found the following. You can use their URL and parameters to open a position through the private endpoint.

URL:
https://www.binance.com/bapi/futures/v1/private/future/strategy/place-order

Params:

{
    'strategyType': 'OTOCO',
    'subOrderList': [
        {
            "strategySubId": 1,
            "firstDrivenId": 0,
            "secondDrivenId": 0,
            "side": "BUY",
            "positionSide": "BOTH",
            "symbol": "BTCUSDT",
            "type": "MARKET",
            "quantity": 0.005,
            "securityType": "USDT_FUTURES",
            "reduceOnly": False
        },
        {
            "side": "SELL",
            "positionSide": "BOTH",
            "symbol": "BTCUSDT",
            "securityType": "USDT_FUTURES",
            "firstTrigger": "PLACE_ORDER",
            "firstDrivenOn": "PARTIALLY_FILLED_OR_FILLED",
            "timeInForce": "GTE_GTC",
            "reduceOnly": True,
            "quantity": 0.005,
            "strategySubId": 2,
            "firstDrivenId": 1,
            "secondDrivenId": 3,
            "secondDrivenOn": "PARTIALLY_FILLED_OR_FILLED",
            "secondTrigger": "CANCEL_ORDER",
            "stopPrice": "21248.4",
            "workingType": "MARK_PRICE",
            "type": "TAKE_PROFIT_MARKET",
            "priceProtect": True
        },
        {
            "side": "SELL",
            "positionSide": "BOTH",
            "symbol": "BTCUSDT",
            "securityType": "USDT_FUTURES",
            "firstTrigger": "PLACE_ORDER",
            "firstDrivenOn": "PARTIALLY_FILLED_OR_FILLED",
            "timeInForce": "GTE_GTC",
            "reduceOnly": True,
            "quantity": 0.005,
            "strategySubId": 3,
            "firstDrivenId": 1,
            "secondDrivenId": 2,
            "secondDrivenOn": "PARTIALLY_FILLED_OR_FILLED",
            "secondTrigger": "CANCEL_ORDER",
            "stopPrice": "20827.6",
            "workingType": "MARK_PRICE",
            "type": "STOP_MARKET",
            "priceProtect": True
        }
    ]
}

Describe alternatives you've considered

You can use LUCIT's Binance websocket repository to listen to the user stream, however, this is extremely inconvenient compared to just putting in this type of order on futures.

Additional context

Note that Binance Spot API already has this type of support in their API.

More on these types of orders:
https://www.binance.com/en-ZA/support/faq/what-are-limit-tp-sl-orders-strategy-order-and-frequently-asked-questions-e1ee1738141c49718550fa9061be4bf3

@oliver-zehentleitner
Copy link
Member

Will be done next week!

@oliver-zehentleitner
Copy link
Member

Sorry, this came in between: LUCIT-Systems-and-Development/unicorn-binance-websocket-api#319

Will continue here after finishing that...

@oliver-zehentleitner
Copy link
Member

I would like to implement this. Is that also available for Spot? I will analyze the Binance frontend myself. Since there is no documentation here, we would have to reverse engineer the paremeters and create one ourselves in the wiki.

@bernhardkimbacher
Copy link

There seem to be a lot of people waiting for this feature, is this still on the roadmap?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request will be realized
Projects
None yet
Development

No branches or pull requests

3 participants