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.
@@ -42,6 +42,7 @@ function TVChartContainer(_ref) {
42
42
  fullscreen: false,
43
43
  autosize: true,
44
44
  studies_overrides: {},
45
+ symbol_search_request_delay: 1000,
45
46
  overrides: {
46
47
  volumePaneSize: "small",
47
48
  "mainSeriesProperties.barStyle.dontDrawOpen": false
@@ -45,28 +45,16 @@ class Datafeed {
45
45
  });
46
46
 
47
47
  _defineProperty(this, "searchSymbols", async (userInput, exchange, symbolType, onResultReadyCallback) => {
48
- console.log("[searchSymbols]: Method call"); // const symbols = await getAllSymbols(exchange);
49
- // const newSymbols = symbols.filter((symbol) => {
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
- // const symbols = await getAllSymbols(exchange);
63
- // const symbolItem = symbols.find(
64
- // ({ full_name }) => full_name === symbolName
65
- // );
66
- // if (!symbolItem) {
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(exchange) {
54
- const data = await makeApiRequest("data/v3/all/exchanges");
55
- let allSymbols = [];
56
- const pairs = data.Data[exchange].pairs;
51
+ async function getAllSymbols(symbol) {
52
+ let newSymbols = [];
57
53
 
58
- for (const leftPairPart of Object.keys(pairs)) {
59
- const symbols = pairs[leftPairPart].map(rightPairPart => {
60
- const symbol = generateSymbol(exchange, leftPairPart, rightPairPart);
61
- return {
62
- symbol: symbol.short,
63
- full_name: symbol.full,
64
- description: symbol.short,
65
- exchange: exchange,
66
- type: "crypto"
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
- allSymbols = [...allSymbols, ...symbols];
68
+ } catch (e) {
69
+ return newSymbols;
70
70
  }
71
71
 
72
- return allSymbols;
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.0",
2
+ "version": "0.2.1",
3
3
  "name": "binbot-charts",
4
4
  "dependencies": {
5
5
  "@babel/cli": "^7.18.10",