-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
30 lines (26 loc) · 1.26 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { DepthManager } from "./DepthManager";
import { cancelAll, createOrder } from "./Order";
const xaiInrMarket = new DepthManager("B-XAI_INR");
const xaiUsdtMarket = new DepthManager("B-XAI_USDT");
const usdtInrMarket = new DepthManager("B-USDT_INR");
setInterval (() => {
console.log(xaiInrMarket.getRelevantDepth());
console.log(xaiUsdtMarket.getRelevantDepth());
console.log(usdtInrMarket.getRelevantDepth());
// Strategy : sell XAI for INR, buy USDT from INR, buy XAI from INR
const canGetInr = xaiInrMarket.getRelevantDepth().lowestAsk - 0.001;
const canGetUsdt = canGetInr / usdtInrMarket.getRelevantDepth().lowestAsk;
const canGetXai = canGetUsdt / xaiUsdtMarket.getRelevantDepth().lowestAsk;
console.log(`You can convert ${1} XAI into ${canGetXai} XAI`)
},2000)
setInterval(async () => {
const highestBid = xaiInrMarket.getRelevantDepth().highestBid;
console.log(`Placing order for ${parseFloat(highestBid) + 0.01}`);
try {
await createOrder("buy", "XAIINR", (parseFloat(highestBid) + 0.01).toFixed(3), 10, Math.random().toString());
await new Promise((r) => setTimeout(r, 4000));
await cancelAll("XAIINR");
} catch (error) {
console.error("Failed to place order:", error);
}
}, 10000);