binbot-charts 0.2.3 → 0.2.4

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");
@@ -23,16 +25,17 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
25
 
24
26
  function TVChartContainer(_ref) {
25
27
  let {
26
- ohlcTick,
27
28
  symbol = "APEUSDT",
28
29
  interval = "1h",
29
30
  libraryPath = "/charting_library/",
30
31
  timescaleMarks = [],
31
32
  orderLines = [],
32
- height = "calc(100vh - 80px)"
33
+ height = "calc(100vh - 80px)",
34
+ onTick,
35
+ getLatestBar
33
36
  } = _ref;
34
37
  const containerRef = (0, _react.useRef)(null);
35
- (0, _react.useEffect)(() => {
38
+ (0, _react.useEffect)(async () => {
36
39
  const widgetOptions = {
37
40
  symbol: symbol,
38
41
  datafeed: new _datafeed.default(timescaleMarks),
@@ -53,11 +56,22 @@ function TVChartContainer(_ref) {
53
56
  tvWidget.onChartReady(() => {
54
57
  if (orderLines.length > 0) {
55
58
  orderLines.forEach(order => {
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);
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);
57
61
  });
58
- }
62
+ tvWidget.subscribe("onTick", event => onTick(event)); // get latest bar for last price
59
63
 
60
- tvWidget.subscribe("onTick", event => ohlcTick(event));
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();
74
+ }
61
75
  }); // returned function will be called on component unmount
62
76
 
63
77
  return () => {
@@ -83,5 +97,6 @@ TVChartContainer.propTypes = {
83
97
  timescaleMarks: _propTypes.default.array,
84
98
  orderLines: _propTypes.default.array,
85
99
  height: _propTypes.default.string,
86
- ohlcTick: _propTypes.default.func.isRequired
100
+ onTick: _propTypes.default.func,
101
+ getLatestBar: _propTypes.default.func
87
102
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.3",
2
+ "version": "0.2.4",
3
3
  "name": "binbot-charts",
4
4
  "dependencies": {
5
5
  "react": "^17.0.1",