update
This commit is contained in:
parent
8588eb9720
commit
c01cae412f
3 changed files with 43 additions and 8 deletions
|
|
@ -4,6 +4,7 @@ import { Order } from "../dao/order";
|
|||
import { sendLarkMessage } from "../services/messageService";
|
||||
import { BybitService } from "../services/bybitService";
|
||||
import { Analysis } from "../dao/analysis";
|
||||
import { Candle } from "../dao/candles";
|
||||
|
||||
function sendMessage(message: string) {
|
||||
sendLarkMessage("oc_f9b2e8f0309ecab0c94e3e134b0ddd29", message);
|
||||
|
|
@ -62,9 +63,10 @@ export const eventHandlerFuture: EventHandler = {
|
|||
`Sell ${order.symbol} ${order.interval}M ${reason} ${order.entry}`
|
||||
);
|
||||
},
|
||||
onEvent: async (eventType: EventType, analysis: Analysis) => {
|
||||
onEvent: async (eventType: EventType, {candle, analysis}: {candle: Candle, analysis: Analysis}) => {
|
||||
if (eventType === "HighVolatility") {
|
||||
const positions = await bybitService.listPositions({
|
||||
category: "linear",
|
||||
symbol: analysis.symbol,
|
||||
});
|
||||
if (positions.length > 0) {
|
||||
|
|
@ -76,7 +78,7 @@ export const eventHandlerFuture: EventHandler = {
|
|||
symbol: analysis.symbol,
|
||||
side: "Sell",
|
||||
orderType: "Limit",
|
||||
price: 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}`);
|
||||
|
|
@ -88,7 +90,7 @@ export const eventHandlerFuture: EventHandler = {
|
|||
symbol: analysis.symbol,
|
||||
side: "Buy",
|
||||
orderType: "Limit",
|
||||
price: 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}`);
|
||||
|
|
@ -132,7 +134,7 @@ const eventHandlerSpot: EventHandler = {
|
|||
reason: ${reason}
|
||||
`);
|
||||
},
|
||||
onEvent: async (eventType: EventType, analysis: Analysis) => {
|
||||
onEvent: async (eventType: EventType, {candle, analysis}: {candle: Candle, analysis: Analysis}) => {
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -161,7 +163,7 @@ const eventHandlerNotification: EventHandler = {
|
|||
reason: ${reason}
|
||||
`);
|
||||
},
|
||||
onEvent: async (eventType: EventType, analysis: Analysis) => {
|
||||
onEvent: async (eventType: EventType, {candle, analysis}: {candle: Candle, analysis: Analysis}) => {
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export type EventType = "HighVolatility" | "PinBar" | "EmaCross" | "MacdCross" |
|
|||
export interface EventHandler {
|
||||
onBuy: (candle: Order, reason: string) => void;
|
||||
onSell: (candle: Order, reason: string) => void;
|
||||
onEvent: (eventType: EventType, analysis: Analysis) => void;
|
||||
onEvent: (eventType: EventType, {candle, analysis}: {candle: Candle, analysis: Analysis}) => void;
|
||||
}
|
||||
|
||||
export class IndicatorService {
|
||||
|
|
@ -302,7 +302,7 @@ export class IndicatorService {
|
|||
}
|
||||
|
||||
if (analysis.isHighVolatility) {
|
||||
eventHandler.onEvent("HighVolatility", analysis);
|
||||
eventHandler.onEvent("HighVolatility", {candle: candles[0], analysis});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue