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

Futures PlaceOrder and - set up take profit #734

Open
Adamszsz opened this issue May 11, 2021 · 10 comments
Open

Futures PlaceOrder and - set up take profit #734

Adamszsz opened this issue May 11, 2021 · 10 comments

Comments

@Adamszsz
Copy link

Adamszsz commented May 11, 2021

I try to find solution about place order.
How can i set Take profit when i place order?

var otwarte_pozycje = client.FuturesUsdt.Order.PlaceOrder("BTCUSDT", OrderSide.Sell, OrderType.Limit, 1, PositionSide.Short, TimeInForce.GoodTillCancel, price: 57000M);
How can i set take profit or stop loss?

@mkleo21
Copy link

mkleo21 commented Aug 7, 2021

Were you able to make this work? I am not able to set a Stop Loss or Take Profit while placing an order.

@mimfa
Copy link

mimfa commented Aug 24, 2021

I'm involving with this problem too... Is there anybody to answer us?

@gitaweb
Copy link

gitaweb commented Oct 28, 2021

yeah ,I'm involving with this problem too.. anybody can give us a tips ?

@KingIthra
Copy link

December 2021 - I have been trying to place orders along with stop loss and take profit since October 2020. Has anyone been able to do this successfully? I heard you may open an order first and then send two more orders as TP and SL, i have been trying to implement this, No success. Can someone show us an example in code?

@sinaptech
Copy link

Can anyone solve this problem?

@eros1453
Copy link

eros1453 commented Mar 7, 2022

#1005

@eros1453
Copy link

eros1453 commented Mar 7, 2022

This works too but you have to make a market buy order to catch the await for the other orders

@eros1453
Copy link

eros1453 commented Mar 8, 2022

You can mess with this code its for winform There is some logic you can miss, its getting the data from orderbook and winform app.

`private void BesLongLimitbutton_Click(object sender, EventArgs e)
{
Task.Run(async () =>
{
LongTradeAmount = tradeable_balance * (Convert.ToDecimal(Properties.Settings.Default.TRADEPERCENT) / 100);
decimal trade_amount = Math.Round(LongTradeAmount * Leverage / bestBid, QUANTITYPRECISION);
BesLongOrder_TP = Math.Round(bestAsk, PRICEPRECISION);
using (var bfc = new BinanceClient())
{
var BesLongorder_SellResult = await bfc.UsdFuturesApi.Trading.PlaceOrderAsync(ASSET, side: OrderSide.Buy, positionSide: PositionSide.Long, type: FuturesOrderType.Limit, quantity: trade_amount, price: bestBid, timeInForce: TimeInForce.GoodTillCrossing) ;

                if (BesLongorder_SellResult.Success)
                {
                    //var startTrail_trailing = bfc.UsdFuturesApi.Trading.PlaceOrder(ASSET, side: OrderSide.Sell, positionSide: PositionSide.Short, type: FuturesOrderType.TrailingStopMarket, quantity: BesLongorder_SellResult.Data.ExecutedQuantity, timeInForce: TimeInForce.GoodTillCanceled, callbackRate: "0.25", activationPrice: BesLongorder_SellResult.Data.Price * 1, 0025);
                    //MessageBox.Show(BesLongorder_SellResult.Data.ToString());
                    long_quantity = trade_amount;
                    long_price = BesLongorder_SellResult.Data.Price;
                    actpr = Math.Round(BesLongOrder_TP * 1.000454545M, PRICEPRECISION);
                    calbck = 0.2M;
                    var startTrail_trailing = await bfc.UsdFuturesApi.Trading.PlaceOrderAsync(ASSET, side: OrderSide.Sell, positionSide: PositionSide.Long, type: FuturesOrderType.TakeProfit, quantity: long_quantity, timeInForce: TimeInForce.GoodTillCanceled, price: long_price, stopPrice: actpr);
                    if (startTrail_trailing.Success)
                    {
                        //MessageBox.Show(startTrail_trailing.Data.ToString());
                    }
                    else
                    {
                        MessageBox.Show($"Order placing failed: {startTrail_trailing.Error.Message}", "Failed", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    //LongTrailStop();
                    OpenOrders();
                    OpenPositions();
                }
                else
                {
                    MessageBox.Show($"Order placing failed: {BesLongorder_SellResult.Error.Message}", "Failed", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        });
    }`

@eros1453
Copy link

eros1453 commented Mar 8, 2022

binance-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@sinaptech @eros1453 @mimfa @gitaweb @Adamszsz @KingIthra @mkleo21 and others