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