-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
73 lines (62 loc) · 1.63 KB
/
index.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const ccxt = require("ccxt");
async function getCcxtTradingRules(exchangeId, symbol, finalOpts) {
let allMarkets;
const exchange = new ccxt[exchangeId](finalOpts);
exchange.loadMarkets();
if (!exchange.has["fetchMarkets"]) {
console.log(
exchange.id +
" does not have fetchMarkets() yet, make sure your version of CCXT is up to date."
);
} else {
allMarkets = await exchange.fetchMarkets();
}
let i = 0;
const tradingRule = {
exchangeId,
symbol,
minTradeAmount: "",
minPriceMovement: "",
minOrderSize: "",
maximumMarketOrderAmount: "",
};
while (allMarkets) {
const market = allMarkets[i];
i++;
if (market && symbol === market["symbol"] && market["limits"]) {
tradingRule.minTradeAmount = market["limits"]["amount"]["min"];
tradingRule.minPriceMovement = market["limits"]["price"]["min"];
tradingRule.minOrderSize = market["limits"]["cost"]["min"];
if (market["limits"]["market"]) {
tradingRule.maximumMarketOrderAmount =
market["limits"]["market"]["max"];
}
break;
}
}
console.log(tradingRule);
return tradingRule;
}
const exchangeIds = ["binance", "bitfinex"]; // huobipro
const symbols = ["FTT/BTC"];
const finalOpts = {
binance: {
apiKey: "---",
secret: "---",
uid: "",
password: "",
timeout: 30000,
enableRateLimit: true,
verbose: false,
},
bitfinex: {
apiKey: "----",
secret: "----",
uid: "",
password: "",
timeout: 30000,
enableRateLimit: true,
verbose: false,
},
};
getCcxtTradingRules(exchangeIds[0], symbols[0], finalOpts[exchangeIds[0]]);