binbot-charts 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,28 +45,16 @@ class Datafeed {
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
_defineProperty(this, "searchSymbols", async (userInput, exchange, symbolType, onResultReadyCallback) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// const isExchangeValid = exchange === "" || symbol.exchange === exchange;
|
|
51
|
-
// if (symbol.replace("/", "") === userInput) {
|
|
52
|
-
// }
|
|
53
|
-
// const isFullSymbolContainsInput =
|
|
54
|
-
// symbol.full_name.toLowerCase().indexOf(userInput.toLowerCase()) !== -1;
|
|
55
|
-
// return isExchangeValid && isFullSymbolContainsInput;
|
|
56
|
-
// });
|
|
57
|
-
|
|
58
|
-
onResultReadyCallback(newSymbols);
|
|
48
|
+
const symbols = await (0, _helpers.getAllSymbols)(userInput);
|
|
49
|
+
onResultReadyCallback(symbols);
|
|
59
50
|
});
|
|
60
51
|
|
|
61
52
|
_defineProperty(this, "resolveSymbol", async (symbolName, onSymbolResolvedCallback, onResolveErrorCallback) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// onResolveErrorCallback("cannot resolve symbol");
|
|
68
|
-
// return;
|
|
69
|
-
// }
|
|
53
|
+
if (!symbolName) {
|
|
54
|
+
onResolveErrorCallback("cannot resolve symbol");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
70
58
|
const symbolInfo = {
|
|
71
59
|
ticker: symbolName,
|
|
72
60
|
name: symbolName,
|
|
@@ -129,7 +117,6 @@ class Datafeed {
|
|
|
129
117
|
}];
|
|
130
118
|
}
|
|
131
119
|
});
|
|
132
|
-
console.log("[getBars]: returned ".concat(bars.length, " bar(s)"));
|
|
133
120
|
onHistoryCallback(bars, {
|
|
134
121
|
noData: false
|
|
135
122
|
});
|
|
@@ -140,12 +127,10 @@ class Datafeed {
|
|
|
140
127
|
});
|
|
141
128
|
|
|
142
129
|
_defineProperty(this, "subscribeBars", (symbolInfo, resolution, onRealtimeCallback, subscribeUID, onResetCacheNeededCallback) => {
|
|
143
|
-
console.log('[subscribeBars]: Method call with subscribeUID:', subscribeUID);
|
|
144
130
|
(0, _streaming.subscribeOnStream)(symbolInfo, resolution, onRealtimeCallback, subscribeUID, onResetCacheNeededCallback, this.interval);
|
|
145
131
|
});
|
|
146
132
|
|
|
147
133
|
_defineProperty(this, "unsubscribeBars", subscriberUID => {
|
|
148
|
-
console.log("[unsubscribeBars]: Method call with subscriberUID:", subscriberUID);
|
|
149
134
|
(0, _streaming.unsubscribeFromStream)(subscriberUID);
|
|
150
135
|
});
|
|
151
136
|
|
|
@@ -15,8 +15,6 @@ require("core-js/modules/es.regexp.exec.js");
|
|
|
15
15
|
|
|
16
16
|
require("core-js/modules/es.string.match.js");
|
|
17
17
|
|
|
18
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
19
|
-
|
|
20
18
|
// Make requests to CryptoCompare API
|
|
21
19
|
async function makeApiRequest(path) {
|
|
22
20
|
try {
|
|
@@ -50,26 +48,28 @@ function parseFullSymbol(fullSymbol) {
|
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
async function getAllSymbols(
|
|
54
|
-
|
|
55
|
-
let allSymbols = [];
|
|
56
|
-
const pairs = data.Data[exchange].pairs;
|
|
51
|
+
async function getAllSymbols(symbol) {
|
|
52
|
+
let newSymbols = [];
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
try {
|
|
55
|
+
const data = await makeApiRequest("api/v3/exchangeInfo?symbol=".concat(symbol.toUpperCase()));
|
|
56
|
+
data.symbols.forEach(item => {
|
|
57
|
+
if (item.status === "TRADING") {
|
|
58
|
+
newSymbols.push({
|
|
59
|
+
symbol: item.symbol,
|
|
60
|
+
full_name: "".concat(item.baseAsset, "/").concat(item.quoteAsset),
|
|
61
|
+
description: "Precision: ".concat(item.quoteAssetPrecision),
|
|
62
|
+
exchange: "Binance",
|
|
63
|
+
ticker: item.symbol,
|
|
64
|
+
type: "crypto"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
68
67
|
});
|
|
69
|
-
|
|
68
|
+
} catch (e) {
|
|
69
|
+
return newSymbols;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
return
|
|
72
|
+
return newSymbols;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function getNextDailyBarTime(barTime) {
|
|
@@ -26,7 +26,6 @@ socket.onerror = error => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
socket.onmessage = e => {
|
|
29
|
-
console.log("[socket] Message:", JSON.parse(e.data));
|
|
30
29
|
const data = JSON.parse(e.data);
|
|
31
30
|
|
|
32
31
|
if (data.e == undefined) {
|
|
@@ -61,8 +60,7 @@ socket.onmessage = e => {
|
|
|
61
60
|
low: low,
|
|
62
61
|
close: close,
|
|
63
62
|
volume: volume
|
|
64
|
-
};
|
|
65
|
-
console.log("[socket] Generate new bar", bar); // send data to every subscriber of that symbol
|
|
63
|
+
}; // send data to every subscriber of that symbol
|
|
66
64
|
|
|
67
65
|
subscriptionItem.handlers.forEach(handler => handler.callback(bar));
|
|
68
66
|
};
|
|
@@ -92,7 +90,6 @@ function subscribeOnStream(symbolInfo, resolution, onRealtimeCallback, subscribe
|
|
|
92
90
|
id: 1
|
|
93
91
|
};
|
|
94
92
|
channelToSubscription.set(channelString, subscriptionItem);
|
|
95
|
-
console.log("[subscribeBars]: Subscribe to streaming. Channel:", channelString);
|
|
96
93
|
socket.send(JSON.stringify(subRequest));
|
|
97
94
|
}
|
|
98
95
|
|
package/package.json
CHANGED