update
This commit is contained in:
parent
3d0079dd06
commit
66d33e7cb3
2 changed files with 38 additions and 20 deletions
|
|
@ -4,6 +4,7 @@ export interface Position {
|
|||
entry: number;
|
||||
leverage: number;
|
||||
volume: number;
|
||||
profit: number;
|
||||
profitPercentage: number;
|
||||
}
|
||||
sl: number;
|
||||
tp: number;
|
||||
status: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ const bybitService = new BybitService(
|
|||
false
|
||||
);
|
||||
|
||||
|
||||
|
||||
export const eventHandlerFuture: EventHandler = {
|
||||
onBuy: (order: Order, reason: string) => {
|
||||
sendMessage(`Future Buy ${order.symbol} ${order.interval}M
|
||||
|
|
@ -35,9 +33,10 @@ export const eventHandlerFuture: EventHandler = {
|
|||
side: "Buy",
|
||||
orderType: "Limit",
|
||||
price: Number(order.entry).toFixed(2),
|
||||
qty: '1',
|
||||
stopLoss: Number(order.stopLoss).toFixed(2),
|
||||
qty: "1",
|
||||
});
|
||||
|
||||
|
||||
console.log(
|
||||
`Buy ${order.symbol} ${order.interval}M ${reason} ${order.entry}`
|
||||
);
|
||||
|
|
@ -57,13 +56,17 @@ export const eventHandlerFuture: EventHandler = {
|
|||
side: "Sell",
|
||||
orderType: "Limit",
|
||||
price: Number(order.entry).toFixed(2),
|
||||
qty: '1',
|
||||
stopLoss: Number(order.stopLoss).toFixed(2),
|
||||
qty: "1",
|
||||
});
|
||||
console.log(
|
||||
`Sell ${order.symbol} ${order.interval}M ${reason} ${order.entry}`
|
||||
);
|
||||
},
|
||||
onEvent: async (eventType: EventType, {candle, analysis}: {candle: Candle, analysis: Analysis}) => {
|
||||
onEvent: async (
|
||||
eventType: EventType,
|
||||
{ candle, analysis }: { candle: Candle; analysis: Analysis }
|
||||
) => {
|
||||
if (eventType === "HighVolatility") {
|
||||
const positions = await bybitService.listPositions({
|
||||
category: "linear",
|
||||
|
|
@ -78,10 +81,15 @@ export const eventHandlerFuture: EventHandler = {
|
|||
symbol: analysis.symbol,
|
||||
side: "Sell",
|
||||
orderType: "Limit",
|
||||
price: candle.close > analysis.currentBB.upper ? Number(candle.close).toFixed(2) : Number(analysis.currentBB.upper).toFixed(2),
|
||||
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}`);
|
||||
sendMessage(
|
||||
`Future Căt nửa ${analysis.symbol} ${analysis.interval}M ${analysis.currentBB.upper} ${halfSize}`
|
||||
);
|
||||
}
|
||||
if (position.side === "Sell" && analysis.isUnderBbLower) {
|
||||
const halfSize = (Number(position.size) / 2).toFixed(2);
|
||||
|
|
@ -90,10 +98,15 @@ export const eventHandlerFuture: EventHandler = {
|
|||
symbol: analysis.symbol,
|
||||
side: "Buy",
|
||||
orderType: "Limit",
|
||||
price: candle.close < analysis.currentBB.lower ? Number(candle.close).toFixed(2) : Number(analysis.currentBB.lower).toFixed(2),
|
||||
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}`);
|
||||
sendMessage(
|
||||
`Future Căt nửa ${analysis.symbol} ${analysis.interval}M ${analysis.currentBB.lower} ${halfSize}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -117,9 +130,9 @@ const eventHandlerSpot: EventHandler = {
|
|||
side: "Buy",
|
||||
orderType: "Limit",
|
||||
price: Number(order.entry).toFixed(2),
|
||||
qty: '1',
|
||||
qty: "1",
|
||||
});
|
||||
|
||||
|
||||
console.log(
|
||||
`Buy ${order.symbol} ${order.interval}M ${reason} ${order.entry}`
|
||||
);
|
||||
|
|
@ -134,8 +147,10 @@ const eventHandlerSpot: EventHandler = {
|
|||
reason: ${reason}
|
||||
`);
|
||||
},
|
||||
onEvent: async (eventType: EventType, {candle, analysis}: {candle: Candle, analysis: Analysis}) => {
|
||||
},
|
||||
onEvent: async (
|
||||
eventType: EventType,
|
||||
{ candle, analysis }: { candle: Candle; analysis: Analysis }
|
||||
) => {},
|
||||
};
|
||||
|
||||
const eventHandlerNotification: EventHandler = {
|
||||
|
|
@ -148,7 +163,7 @@ const eventHandlerNotification: EventHandler = {
|
|||
volume: ${order.volume}
|
||||
reason: ${reason}
|
||||
`);
|
||||
|
||||
|
||||
console.log(
|
||||
`Buy ${order.symbol} ${order.interval}M ${reason} ${order.entry}`
|
||||
);
|
||||
|
|
@ -163,8 +178,10 @@ const eventHandlerNotification: EventHandler = {
|
|||
reason: ${reason}
|
||||
`);
|
||||
},
|
||||
onEvent: async (eventType: EventType, {candle, analysis}: {candle: Candle, analysis: Analysis}) => {
|
||||
},
|
||||
onEvent: async (
|
||||
eventType: EventType,
|
||||
{ candle, analysis }: { candle: Candle; analysis: Analysis }
|
||||
) => {},
|
||||
};
|
||||
|
||||
createCandleAnalysisSchedule("ETHUSDT", "15", eventHandlerFuture);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue