-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinanceDataLoader.js
More file actions
48 lines (42 loc) · 1.48 KB
/
binanceDataLoader.js
File metadata and controls
48 lines (42 loc) · 1.48 KB
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
47
48
import "dotenv/config";
import { dbInput, newBarInput, fetchActiveSymbol } from "./Inputs/config.js";
import { loadPositions } from "./DBConnection/loadPositions.js";
import { loadSafeBalance } from "./DBConnection/loadSafeBalance.js";
import { initDB, initClient } from "./DBConnection/initPool.js";
import {
loadSettlementPrice,
loadMarkPrice,
} from "./DBConnection/loadPrice.js";
import { loadOrders } from "./DBConnection/loadOrders.js";
import { barInit } from "./utilities/isNewBar.js";
import logger from "./logger.js";
import { checkOpenOrder } from "./DBConnection/checkOpenOrder.js";
import {
initAssetBalance,
checkNewAsset,
} from "./DBConnection/checkNewAsset.js";
import { loadLedger } from "./DBConnection/loadLedger.js";
const main = async () => {
logger.info("init DB Pool ...");
const pool = initDB();
const client = initClient();
logger.info("init account balance ...");
initAssetBalance(pool);
logger.info("init isNewBar Function ...");
await barInit(newBarInput.market, newBarInput.timeframe);
logger.info("load past orders ...");
await loadOrders(pool);
logger.info("Start ...");
setInterval(async () => {
loadSafeBalance(pool, client);
// await checkNewAsset(client, pool);
// await fetchActiveSymbol(client);
loadMarkPrice(pool);
loadSettlementPrice(pool, client);
loadLedger(pool, client);
await loadPositions(pool);
await checkOpenOrder(client, pool);
logger.info("-".repeat(30));
}, dbInput.loadInterval);
};
main();