update
This commit is contained in:
parent
8588eb9720
commit
c01cae412f
3 changed files with 43 additions and 8 deletions
35
test.ts
35
test.ts
|
|
@ -22,8 +22,41 @@ function toTimestamp(strTime: string): number {
|
|||
|
||||
(async () => {
|
||||
// await analyzeCandlesJob("ETHUSDT", "15", toTimestamp("2025-07-08 23:59:59"));
|
||||
await analyzeCandlesJob("BTCUSDT", "15", undefined, toTimestamp("2025-07-16 22:14:59"));
|
||||
// await analyzeCandlesJob("BTCUSDT", "15", undefined, toTimestamp("2025-07-16 22:14:59"));
|
||||
|
||||
const positions = await bybitService.listPositions({
|
||||
category: "linear",
|
||||
symbol: "BTCUSDT",
|
||||
});
|
||||
console.log(positions);
|
||||
if (positions.length > 0) {
|
||||
const position = positions[0];
|
||||
console.log(position);
|
||||
if (position.side === "Buy") {
|
||||
const halfSize = (Number(position.size) / 2).toFixed(2);
|
||||
console.log(halfSize);
|
||||
const res = await bybitService.submitOrder({
|
||||
category: "linear",
|
||||
symbol: "BTCUSDT",
|
||||
side: "Sell",
|
||||
orderType: "Limit",
|
||||
price: "119310.2",
|
||||
qty: halfSize,
|
||||
});
|
||||
console.log(res);
|
||||
}
|
||||
if (position.side === "Sell") {
|
||||
const halfSize = (Number(position.size) / 2).toFixed(2);
|
||||
await bybitService.submitOrder({
|
||||
category: "linear",
|
||||
symbol: "BTCUSDT",
|
||||
side: "Buy",
|
||||
orderType: "Limit",
|
||||
price: "119310.2",
|
||||
qty: halfSize,
|
||||
});
|
||||
}
|
||||
}
|
||||
// const balance = await bybitService.getBalance();
|
||||
// console.log(balance.result.list[0].totalEquity);
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue