binbot-charts 0.2.2 → 0.2.5

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.
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = TVChartContainer;
9
9
 
10
+ require("core-js/modules/es.promise.js");
11
+
10
12
  var _react = _interopRequireWildcard(require("react"));
11
13
 
12
14
  var _charting_library = require("../charting_library");
@@ -28,10 +30,12 @@ function TVChartContainer(_ref) {
28
30
  libraryPath = "/charting_library/",
29
31
  timescaleMarks = [],
30
32
  orderLines = [],
31
- height = "calc(100vh - 80px)"
33
+ height = "calc(100vh - 80px)",
34
+ onTick,
35
+ getLatestBar
32
36
  } = _ref;
33
37
  const containerRef = (0, _react.useRef)(null);
34
- (0, _react.useEffect)(() => {
38
+ (0, _react.useEffect)(async () => {
35
39
  const widgetOptions = {
36
40
  symbol: symbol,
37
41
  datafeed: new _datafeed.default(timescaleMarks),
@@ -52,8 +56,21 @@ function TVChartContainer(_ref) {
52
56
  tvWidget.onChartReady(() => {
53
57
  if (orderLines.length > 0) {
54
58
  orderLines.forEach(order => {
55
- 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);
59
+ const lineStyle = order.lineStyle || 0;
60
+ tvWidget.chart().createPositionLine().setText(order.text).setTooltip(order.tooltip).setQuantity(order.quantity).setQuantityFont("bold 12pt Verdana").setQuantityBackgroundColor(order.color).setQuantityBorderColor(order.color).setLineStyle(lineStyle).setLineLength(25).setLineColor(order.color).setBodyFont("bold 12pt Verdana").setBodyBorderColor(order.color).setBodyTextColor(order.color).setPrice(order.price);
56
61
  });
62
+ tvWidget.subscribe("onTick", event => onTick(event)); // get latest bar for last price
63
+
64
+ const prices = async () => {
65
+ const data = await tvWidget.activeChart().exportData({
66
+ includeTime: false,
67
+ includeSeries: true,
68
+ includedStudies: []
69
+ });
70
+ getLatestBar(data.data[data.data.length - 1]);
71
+ };
72
+
73
+ prices();
57
74
  }
58
75
  }); // returned function will be called on component unmount
59
76
 
@@ -79,5 +96,7 @@ TVChartContainer.propTypes = {
79
96
  libraryPath: _propTypes.default.string,
80
97
  timescaleMarks: _propTypes.default.array,
81
98
  orderLines: _propTypes.default.array,
82
- height: _propTypes.default.string
99
+ height: _propTypes.default.string,
100
+ onTick: _propTypes.default.func,
101
+ getLatestBar: _propTypes.default.func
83
102
  };
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "version": "0.2.2",
2
+ "version": "0.2.5",
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",