binbot-charts 0.2.10 → 0.2.13

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,21 +47,12 @@ function TVChartContainer(_ref) {
46
47
 
47
48
  if (orderLines && orderLines.length > 0) {
48
49
  updateOrderLines(orderLines);
49
- } // returned function will be called on component unmount
50
+ } // if (symbol !== symbolState) {
51
+ // widgetState.setSymbol(symbol, interval);
52
+ // }
50
53
 
51
-
52
- return () => {
53
- componentUnMount();
54
- };
55
54
  }, [orderLines]);
56
55
 
57
- const componentUnMount = () => {
58
- if (widgetState !== null) {
59
- widgetState.remove();
60
- setWidgetState(null);
61
- }
62
- };
63
-
64
56
  const initializeChart = () => {
65
57
  const widgetOptions = {
66
58
  symbol: symbol,
@@ -108,9 +100,8 @@ function TVChartContainer(_ref) {
108
100
  } else {
109
101
  if (orderLines && orderLines.length > 0) {
110
102
  orderLines.forEach(order => {
111
- // const lineStyle = order.lineStyle || 0;
112
- 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)
113
- .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);
114
105
  setChartOrderLines(draft => {
115
106
  draft.push(chartOrderLine);
116
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.10",
2
+ "version": "0.2.13",
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 \".ts,.js,.jsx\" && cp -r src/charting_library dist/charting_library",
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.",
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });