-
-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
Hey guys,
i am setting a Order like that:
const contract: Contract = {
symbol: tranche.stockName,
secType: SecType.STK,
exchange: tranche.exchange,
currency: tranche.currency,
};
// 2️⃣ Parent BUY Order
const parentOrder: Order = {
orderId: parentOrderId,
action: OrderAction.BUY,
totalQuantity: tranche.buyQuantity,
orderType: OrderType.MKT,
account: tranche.twsUnderAccount.capTraderSubAccountId,
tif: 'GTC',
transmit: false,
};
// 3️⃣ Take-Profit Order // Teilverkauf
const investTenPercent = getInvestSum(historicalData, tranche) * 0.1;
let sellQuantity = investTenPercent / tranche.takeProfit.toNumber();
// **MUSS** ganzzahlig sein und mindestens 1
sellQuantity = Math.max(1, Math.round(sellQuantity));
console.log(
`🔔 Calculated sell quantity for take-profit: ${sellQuantity} shares.`,
);
const takeProfit: Order = {
orderId: takeProfitOrderId,
action: OrderAction.SELL,
parentId: parentOrderId,
totalQuantity: sellQuantity,
orderType: OrderType.LMT,
// Limit-Preis leicht unter dem Take-Profit, um Ausführung zu erhöhen - 0.05%
lmtPrice: tranche.takeProfit.toNumber() * (1 - 0.0005),
account: tranche.twsUnderAccount.capTraderSubAccountId,
tif: 'GTC',
transmit: true,
};
// 5️⃣ Orders senden
ib.placeOrder(parentOrderId, contract, parentOrder);
ib.placeOrder(takeProfitOrderId, contract, takeProfit);
the Take Profit Order got a totalQuantity of 1 value...
But in the TWS it says 10 like my whole position (Buy Parent Order), when i remove the parentId its the one...
but i need a parent relation for that or is there any better approach?
thanks in advance....
Metadata
Metadata
Assignees
Labels
No labels