binbot-charts 0.2.11 → 0.2.14
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.
|
@@ -39,6 +39,7 @@ function TVChartContainer(_ref) {
|
|
|
39
39
|
const containerRef = (0, _react.useRef)(null);
|
|
40
40
|
const [chartOrderLines, setChartOrderLines] = (0, _useImmer.useImmer)([]);
|
|
41
41
|
const [widgetState, setWidgetState] = (0, _react.useState)(null);
|
|
42
|
+
const [symbolState, setSymbolState] = (0, _react.useState)(symbol);
|
|
42
43
|
(0, _react.useEffect)(() => {
|
|
43
44
|
if (!widgetState) {
|
|
44
45
|
initializeChart();
|
|
@@ -46,7 +47,10 @@ function TVChartContainer(_ref) {
|
|
|
46
47
|
|
|
47
48
|
if (orderLines && orderLines.length > 0) {
|
|
48
49
|
updateOrderLines(orderLines);
|
|
49
|
-
}
|
|
50
|
+
} // if (symbol !== symbolState) {
|
|
51
|
+
// widgetState.setSymbol(symbol, interval);
|
|
52
|
+
// }
|
|
53
|
+
|
|
50
54
|
}, [orderLines]);
|
|
51
55
|
|
|
52
56
|
const initializeChart = () => {
|
|
@@ -96,9 +100,8 @@ function TVChartContainer(_ref) {
|
|
|
96
100
|
} else {
|
|
97
101
|
if (orderLines && orderLines.length > 0) {
|
|
98
102
|
orderLines.forEach(order => {
|
|
99
|
-
|
|
100
|
-
const chartOrderLine = widgetState.chart().createOrderLine().setText(order.text).setTooltip(order.tooltip).setQuantity(order.quantity).setQuantityFont("inherit 14px Arial").setQuantityBackgroundColor(order.color).setQuantityBorderColor(order.color)
|
|
101
|
-
.setLineLength(25).setLineColor(order.color).setBodyFont("inherit 14px Arial").setBodyBorderColor(order.color).setBodyTextColor(order.color).setPrice(order.price);
|
|
103
|
+
const lineStyle = order.lineStyle || 0;
|
|
104
|
+
const chartOrderLine = widgetState.chart().createOrderLine().setText(order.text).setTooltip(order.tooltip).setQuantity(order.quantity).setQuantityFont("inherit 14px Arial").setQuantityBackgroundColor(order.color).setQuantityBorderColor(order.color).setLineStyle(lineStyle).setLineLength(25).setLineColor(order.color).setBodyFont("inherit 14px Arial").setBodyBorderColor(order.color).setBodyTextColor(order.color).setPrice(order.price);
|
|
102
105
|
setChartOrderLines(draft => {
|
|
103
106
|
draft.push(chartOrderLine);
|
|
104
107
|
return draft;
|
|
@@ -3,18 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.generateSymbol = generateSymbol;
|
|
7
6
|
exports.getAllSymbols = getAllSymbols;
|
|
8
7
|
exports.makeApiRequest = makeApiRequest;
|
|
9
|
-
exports.parseFullSymbol = parseFullSymbol;
|
|
10
8
|
|
|
11
9
|
require("core-js/modules/es.promise.js");
|
|
12
10
|
|
|
13
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.string.match.js");
|
|
16
|
-
|
|
17
|
-
// Make requests to CryptoCompare API
|
|
18
11
|
async function makeApiRequest(path) {
|
|
19
12
|
try {
|
|
20
13
|
const response = await fetch("https://api.binance.com/".concat(path));
|
|
@@ -22,29 +15,6 @@ async function makeApiRequest(path) {
|
|
|
22
15
|
} catch (error) {
|
|
23
16
|
throw new Error("Binance request error: ".concat(error.status));
|
|
24
17
|
}
|
|
25
|
-
} // Generate a symbol ID from a pair of the coins
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function generateSymbol(exchange, fromSymbol, toSymbol) {
|
|
29
|
-
const short = "".concat(fromSymbol, "/").concat(toSymbol);
|
|
30
|
-
return {
|
|
31
|
-
short,
|
|
32
|
-
full: "".concat(exchange, ":").concat(short)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function parseFullSymbol(fullSymbol) {
|
|
37
|
-
const match = fullSymbol.match(/^(\w+):(\w+)\/(\w+)$/);
|
|
38
|
-
|
|
39
|
-
if (!match) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
exchange: match[1],
|
|
45
|
-
fromSymbol: match[2],
|
|
46
|
-
toSymbol: match[3]
|
|
47
|
-
};
|
|
48
18
|
}
|
|
49
19
|
|
|
50
20
|
async function getAllSymbols(symbol) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
2
|
+
"version": "0.2.14",
|
|
3
3
|
"name": "binbot-charts",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"react": "^17.0.1",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"start": "react-scripts start",
|
|
19
|
-
"build": "rm -rf dist && NODE_ENV=production babel -d dist/components src/components --extensions \".
|
|
19
|
+
"build": "rm -rf dist && NODE_ENV=production babel -d dist/components src/components --extensions \".js,.jsx\" && cp -r src/charting_library dist/charting_library",
|
|
20
20
|
"release": "yarn build && yarn publish"
|
|
21
21
|
},
|
|
22
22
|
"description": "Binbot charts is the default candlestick bars chart used in terminal.binbot.com to render bots graphically.",
|