binbot-charts 0.2.0 → 0.2.3
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.
|
@@ -23,6 +23,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
23
|
|
|
24
24
|
function TVChartContainer(_ref) {
|
|
25
25
|
let {
|
|
26
|
+
ohlcTick,
|
|
26
27
|
symbol = "APEUSDT",
|
|
27
28
|
interval = "1h",
|
|
28
29
|
libraryPath = "/charting_library/",
|
|
@@ -42,6 +43,7 @@ function TVChartContainer(_ref) {
|
|
|
42
43
|
fullscreen: false,
|
|
43
44
|
autosize: true,
|
|
44
45
|
studies_overrides: {},
|
|
46
|
+
symbol_search_request_delay: 1000,
|
|
45
47
|
overrides: {
|
|
46
48
|
volumePaneSize: "small",
|
|
47
49
|
"mainSeriesProperties.barStyle.dontDrawOpen": false
|
|
@@ -54,6 +56,8 @@ function TVChartContainer(_ref) {
|
|
|
54
56
|
tvWidget.chart().createPositionLine().setText(order.text).setTooltip(order.tooltip).setQuantity(order.quantity).setQuantityBackgroundColor(order.color).setQuantityBorderColor(order.color).setLineStyle(0).setLineLength(25).setLineColor(order.color).setBodyBorderColor(order.color).setBodyTextColor(order.color).setPrice(order.price);
|
|
55
57
|
});
|
|
56
58
|
}
|
|
59
|
+
|
|
60
|
+
tvWidget.subscribe("onTick", event => ohlcTick(event));
|
|
57
61
|
}); // returned function will be called on component unmount
|
|
58
62
|
|
|
59
63
|
return () => {
|
|
@@ -78,5 +82,6 @@ TVChartContainer.propTypes = {
|
|
|
78
82
|
libraryPath: _propTypes.default.string,
|
|
79
83
|
timescaleMarks: _propTypes.default.array,
|
|
80
84
|
orderLines: _propTypes.default.array,
|
|
81
|
-
height: _propTypes.default.string
|
|
85
|
+
height: _propTypes.default.string,
|
|
86
|
+
ohlcTick: _propTypes.default.func.isRequired
|
|
82
87
|
};
|
|
@@ -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,
|
|
@@ -95,7 +83,6 @@ class Datafeed {
|
|
|
95
83
|
to,
|
|
96
84
|
firstDataRequest
|
|
97
85
|
} = periodParams;
|
|
98
|
-
console.log("[getBars]: Method call");
|
|
99
86
|
let urlParameters = {
|
|
100
87
|
symbol: symbolInfo.name,
|
|
101
88
|
interval: this.interval,
|
|
@@ -129,7 +116,6 @@ class Datafeed {
|
|
|
129
116
|
}];
|
|
130
117
|
}
|
|
131
118
|
});
|
|
132
|
-
console.log("[getBars]: returned ".concat(bars.length, " bar(s)"));
|
|
133
119
|
onHistoryCallback(bars, {
|
|
134
120
|
noData: false
|
|
135
121
|
});
|
|
@@ -140,12 +126,10 @@ class Datafeed {
|
|
|
140
126
|
});
|
|
141
127
|
|
|
142
128
|
_defineProperty(this, "subscribeBars", (symbolInfo, resolution, onRealtimeCallback, subscribeUID, onResetCacheNeededCallback) => {
|
|
143
|
-
console.log('[subscribeBars]: Method call with subscribeUID:', subscribeUID);
|
|
144
129
|
(0, _streaming.subscribeOnStream)(symbolInfo, resolution, onRealtimeCallback, subscribeUID, onResetCacheNeededCallback, this.interval);
|
|
145
130
|
});
|
|
146
131
|
|
|
147
132
|
_defineProperty(this, "unsubscribeBars", subscriberUID => {
|
|
148
|
-
console.log("[unsubscribeBars]: Method call with subscriberUID:", subscriberUID);
|
|
149
133
|
(0, _streaming.unsubscribeFromStream)(subscriberUID);
|
|
150
134
|
});
|
|
151
135
|
|
|
@@ -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
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
2
|
+
"version": "0.2.3",
|
|
3
3
|
"name": "binbot-charts",
|
|
4
4
|
"dependencies": {
|
|
5
|
+
"react": "^17.0.1",
|
|
6
|
+
"react-dom": "^17.0.1",
|
|
7
|
+
"react-scripts": "^5.0.1"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
5
10
|
"@babel/cli": "^7.18.10",
|
|
6
11
|
"@babel/core": "^7.18.13",
|
|
7
12
|
"@babel/polyfill": "^7.12.1",
|
|
8
13
|
"@babel/preset-env": "^7.18.10",
|
|
9
|
-
"@babel/preset-typescript": "^7.18.6"
|
|
10
|
-
"react": "^17.0.1",
|
|
11
|
-
"react-dom": "^17.0.1",
|
|
12
|
-
"react-scripts": "^5.0.1",
|
|
13
|
-
"socket.io": "1.7.2",
|
|
14
|
-
"use-immer": "^0.7.0"
|
|
14
|
+
"@babel/preset-typescript": "^7.18.6"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"start": "react-scripts start",
|