-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
46 lines (34 loc) · 1.65 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { DepthManager } from "./DepthManager";
import { cancelAll, createOrder } from "./order";
const solINRMarket = new DepthManager('B-XAI_INR')
const usdtINRMarket = new DepthManager('B-USDT_INR')
const solUSDTMarket = new DepthManager('B-XAI_USDT')
setInterval(() => {
console.log('SOL-INR', solINRMarket.getRelevantDepth())
console.log('USDT-INR', usdtINRMarket.getRelevantDepth())
console.log('SOL-USDT', solUSDTMarket.getRelevantDepth())
// there are two sides you can trade on
// sell SOL for INR, buy USDT from INR , buy SOL from INR
// let's start with 1 SOL
const canGetINR = solINRMarket.getRelevantDepth().lowestAsk - 0.001;
const canGetUSDT = canGetINR / usdtINRMarket.getRelevantDepth().lowestAsk;
const canGetSol = canGetUSDT / solUSDTMarket.getRelevantDepth().lowestAsk;
console.log(`you can convert ${1} SOL to ${canGetSol} SOLS`)
// second strategy
// buy sol for inr , sell sol for usdt , sell usdt for inr
const initialINR = solINRMarket.getRelevantDepth().highestBid + 0.001;
const canGetUSDT2 = solUSDTMarket.getRelevantDepth().highestBid ;
const canGetINR2 = canGetUSDT2 * usdtINRMarket.getRelevantDepth().highestBid;
console.log(`you can convert ${initialINR} INR to ${canGetINR2} INR`)
}, 2000)
async function main(){
const highestBid = solINRMarket.getRelevantDepth().highestBid;
await createOrder('buy', 'XAIINR', parseFloat((highestBid + 0.01).toFixed(3)), 10, Math.random().toString());
await new Promise((r) => setTimeout(r, 10000));
await cancelAll('XAIINR')
await new Promise((r) => setTimeout(r, 1000));
main();
}
setTimeout(() => {
main();
}, 2000);