This commit is contained in:
KienVT9 2025-07-20 20:23:25 +07:00
parent 272ba19977
commit 2c432b3fd3

View file

@ -68,47 +68,47 @@ export const eventHandlerFuture: EventHandler = {
{ candle, analysis }: { candle: Candle; analysis: Analysis } { candle, analysis }: { candle: Candle; analysis: Analysis }
) => { ) => {
if (eventType === "HighVolatility") { if (eventType === "HighVolatility") {
const positions = await bybitService.listPositions({ // const positions = await bybitService.listPositions({
category: "linear", // category: "linear",
symbol: analysis.symbol, // symbol: analysis.symbol,
}); // });
if (positions.length > 0) { // if (positions.length > 0) {
const position = positions[0]; // const position = positions[0];
if (position.side === "Buy" && analysis.isOverBbUpper && candle.close > candle.open) { // if (position.side === "Buy" && analysis.isOverBbUpper && candle.close > candle.open) {
const halfSize = (Number(position.size) / 2).toFixed(2); // const halfSize = (Number(position.size) / 2).toFixed(2);
await bybitService.submitOrder({ // await bybitService.submitOrder({
category: "linear", // category: "linear",
symbol: analysis.symbol, // symbol: analysis.symbol,
side: "Sell", // side: "Sell",
orderType: "Limit", // orderType: "Limit",
price: // price:
candle.close > analysis.currentBB.upper // candle.close > analysis.currentBB.upper
? Number(candle.close).toFixed(2) // ? Number(candle.close).toFixed(2)
: Number(analysis.currentBB.upper).toFixed(2), // : Number(analysis.currentBB.upper).toFixed(2),
qty: halfSize, // qty: halfSize,
}); // });
sendMessage( // sendMessage(
`Future Căt nửa ${analysis.symbol} ${analysis.interval}M ${analysis.currentBB.upper} ${halfSize}` // `Future Căt nửa ${analysis.symbol} ${analysis.interval}M ${analysis.currentBB.upper} ${halfSize}`
); // );
} // }
if (position.side === "Sell" && analysis.isUnderBbLower && candle.close < candle.open) { // if (position.side === "Sell" && analysis.isUnderBbLower && candle.close < candle.open) {
const halfSize = (Number(position.size) / 2).toFixed(2); // const halfSize = (Number(position.size) / 2).toFixed(2);
await bybitService.submitOrder({ // await bybitService.submitOrder({
category: "linear", // category: "linear",
symbol: analysis.symbol, // symbol: analysis.symbol,
side: "Buy", // side: "Buy",
orderType: "Limit", // orderType: "Limit",
price: // price:
candle.close < analysis.currentBB.lower // candle.close < analysis.currentBB.lower
? Number(candle.close).toFixed(2) // ? Number(candle.close).toFixed(2)
: Number(analysis.currentBB.lower).toFixed(2), // : Number(analysis.currentBB.lower).toFixed(2),
qty: halfSize, // qty: halfSize,
}); // });
sendMessage( // sendMessage(
`Future Căt nửa ${analysis.symbol} ${analysis.interval}M ${analysis.currentBB.lower} ${halfSize}` // `Future Căt nửa ${analysis.symbol} ${analysis.interval}M ${analysis.currentBB.lower} ${halfSize}`
); // );
} // }
} // }
} }
}, },
}; };