pinets 0.2.0 → 0.2.1

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.
@@ -1535,7 +1535,7 @@ function transformEqualityChecks(ast) {
1535
1535
  type: "MemberExpression",
1536
1536
  object: {
1537
1537
  type: "Identifier",
1538
- name: "math"
1538
+ name: "$.math"
1539
1539
  },
1540
1540
  property: {
1541
1541
  type: "Identifier",
@@ -1584,7 +1584,7 @@ class PineTS {
1584
1584
  __publicField$6(this, "_ready", false);
1585
1585
  this._readyPromise = new Promise((resolve) => {
1586
1586
  this.loadMarketData(source, tickerId, timeframe, limit, sDate, eDate).then((data) => {
1587
- const marketData = data.reverse().slice(0, MAX_PERIODS);
1587
+ const marketData = data.slice(0, MAX_PERIODS);
1588
1588
  this._periods = marketData.length;
1589
1589
  this.data = marketData;
1590
1590
  const _open = marketData.map((d) => d.open);
@@ -1643,19 +1643,28 @@ class PineTS {
1643
1643
  context.useTACache = useTACache;
1644
1644
  const transformer = transpile.bind(this);
1645
1645
  let transpiledFn = transformer(pineTSCode);
1646
+ context.data.close = [];
1647
+ context.data.open = [];
1648
+ context.data.high = [];
1649
+ context.data.low = [];
1650
+ context.data.volume = [];
1651
+ context.data.hl2 = [];
1652
+ context.data.hlc3 = [];
1653
+ context.data.ohlc4 = [];
1654
+ context.data.openTime = [];
1655
+ context.data.closeTime = [];
1646
1656
  const contextVarNames = ["const", "var", "let", "params"];
1647
- for (let i = this._periods - n, idx = n - 1; i < this._periods; i++, idx--) {
1657
+ for (let i = this._periods - n; i < this._periods; i++) {
1648
1658
  context.idx = i;
1649
- context.data.close = this.close.slice(idx);
1650
- context.data.open = this.open.slice(idx);
1651
- context.data.high = this.high.slice(idx);
1652
- context.data.low = this.low.slice(idx);
1653
- context.data.volume = this.volume.slice(idx);
1654
- context.data.hl2 = this.hl2.slice(idx);
1655
- context.data.hlc3 = this.hlc3.slice(idx);
1656
- context.data.ohlc4 = this.ohlc4.slice(idx);
1657
- context.data.openTime = this.openTime.slice(idx);
1658
- context.data.closeTime = this.closeTime.slice(idx);
1659
+ context.data.close.unshift(this.close[i]);
1660
+ context.data.open.unshift(this.open[i]);
1661
+ context.data.high.unshift(this.high[i]);
1662
+ context.data.low.unshift(this.low[i]);
1663
+ context.data.volume.unshift(this.volume[i]);
1664
+ context.data.hl2.unshift(this.hl2[i]);
1665
+ context.data.hlc3.unshift(this.hlc3[i]);
1666
+ context.data.ohlc4.unshift(this.ohlc4[i]);
1667
+ context.data.openTime.unshift(this.openTime[i]);
1659
1668
  const result = await transpiledFn(context);
1660
1669
  if (typeof result === "object") {
1661
1670
  if (typeof context.result !== "object") {