Buy at market, then sell or close a specific futures order.
See original GitHub issueI am trying to make an extremely simple bot that just buys with a % of my money in futures, then sells the full contract based on some signals from a webhook.
My current buy states is something like:
let maxBuyIn = await futuresBusdBalance();
maxBuyIn = maxBuyIn * 0.85;
console.info( await binance.futuresMarketBuy( 'ADABUSD', maxBuyIn ) );
I think this should work fine, although I’d be happy to hear suggestions if there is a better way, or maybe a function for a max buy in already.
For my sell order on the other hand, I am getting a bit stuck. I can’t find anywhere in the API where I can simply close the full order at market. I will admit I am not amazing javascript. So far my only thoughts might be to use await binance.futuresBalance() and somehow find the object containing my order, then selling the quantity from it? Am I on the right track? Am I completely off? Maybe people have suggestions.
A simple full market buy and full market sell in futures would suffice for me.
Thanks for any help, and I apologize if this isn’t the place to ask this.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top GitHub Comments
It just means that the order will only be reduced, it will not add anything to your order or it will fail. Just leave it in unless you have a very specific case where this isn’t what you want.
Sure!
// side should be long/short async function sellPosition(side) { // coinPair example: ‘ADAUSDT’ let position = await binance.futuresPositionRisk({ symbol: coinPair });
}