pinets 0.1.1 → 0.1.31

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.
@@ -2,14 +2,20 @@ import { Input } from '@pinets/namespaces/Input';
2
2
  import PineMath from '@pinets/namespaces/PineMath';
3
3
  import { PineRequest } from '@pinets/namespaces/PineRequest';
4
4
  import TechnicalAnalysis from '@pinets/namespaces/TechnicalAnalysis';
5
+ import { PineArray } from './namespaces/PineArray';
6
+ import { IProvider } from './marketData/IProvider';
5
7
  export declare class Context {
6
- marketData: any;
7
8
  data: any;
9
+ cache: any;
10
+ useTACache: boolean;
11
+ NA: any;
8
12
  math: PineMath;
9
13
  ta: TechnicalAnalysis;
10
14
  input: Input;
11
15
  request: PineRequest;
16
+ array: PineArray;
12
17
  core: any;
18
+ lang: any;
13
19
  idx: number;
14
20
  params: any;
15
21
  const: any;
@@ -17,8 +23,23 @@ export declare class Context {
17
23
  let: any;
18
24
  result: any;
19
25
  plots: any;
26
+ marketData: any;
27
+ source: IProvider | any[];
28
+ tickerId: string;
20
29
  timeframe: string;
21
- constructor(marketData: any);
30
+ limit: number;
31
+ sDate: number;
32
+ eDate: number;
33
+ pineTSCode: Function | String;
34
+ constructor({ marketData, source, tickerId, timeframe, limit, sDate, eDate, }: {
35
+ marketData: any;
36
+ source: IProvider | any[];
37
+ tickerId?: string;
38
+ timeframe?: string;
39
+ limit?: number;
40
+ sDate?: number;
41
+ eDate?: number;
42
+ });
22
43
  /**
23
44
  * this function is used to initialize the target variable with the source array
24
45
  * this array will represent a time series and its values will be shifted at runtime in order to mimic Pine script behavior
@@ -33,6 +54,7 @@ export declare class Context {
33
54
  * by default it is set to 10 decimals which is the same as pine script
34
55
  * @param n - the number to be precision
35
56
  * @param decimals - the number of decimals to precision to
57
+
36
58
  * @returns the precision number
37
59
  */
38
60
  precision(n: number, decimals?: number): number;
@@ -28,6 +28,6 @@ export declare class PineTS {
28
28
  constructor(source: IProvider | any[], tickerId?: string, timeframe?: string, limit?: number, sDate?: number, eDate?: number);
29
29
  private loadMarketData;
30
30
  ready(): Promise<any>;
31
- run(fn: Function | String, n?: number): Promise<Context>;
31
+ run(pineTSCode: Function | String, n?: number, useTACache?: boolean): Promise<Context>;
32
32
  }
33
33
  export default PineTS;
@@ -1,4 +1,7 @@
1
1
  import { IProvider } from '@pinets/marketData/IProvider';
2
2
  export declare class BinanceProvider implements IProvider {
3
+ private cacheManager;
4
+ constructor();
5
+ getMarketDataInterval(tickerId: string, timeframe: string, sDate: number, eDate: number): Promise<any>;
3
6
  getMarketData(tickerId: string, timeframe: string, limit?: number, sDate?: number, eDate?: number): Promise<any>;
4
7
  }
@@ -1,6 +1,9 @@
1
1
  export declare class Core {
2
2
  private context;
3
3
  color: {
4
+ param: (source: any, index?: number) => any;
5
+ rgb: (r: number, g: number, b: number, a?: number) => string;
6
+ new: (color: string, a?: number) => string;
4
7
  white: string;
5
8
  lime: string;
6
9
  green: string;
@@ -0,0 +1,62 @@
1
+ declare class PineArrayObject {
2
+ array: any;
3
+ constructor(array: any);
4
+ }
5
+ /**
6
+ * This class implements an array port of PineScript's array functions.
7
+ */
8
+ export declare class PineArray {
9
+ private context;
10
+ private _cache;
11
+ constructor(context: any);
12
+ param(source: any, index?: number): any;
13
+ /**
14
+ * This function simulates PineScript's array.get() function
15
+ * @param id - the array object to get the value from
16
+ * @param index - the index of the value to get
17
+ * @returns the value at the given index
18
+ */
19
+ get(id: PineArrayObject, index: number): any;
20
+ set(id: PineArrayObject, index: number, value: any): void;
21
+ push(id: PineArrayObject, value: any): void;
22
+ sum(id: PineArrayObject): number;
23
+ avg(id: PineArrayObject): number;
24
+ min(id: PineArrayObject, nth?: number): number;
25
+ max(id: PineArrayObject, nth?: number): number;
26
+ size(id: PineArrayObject): number;
27
+ new_bool(size: number, initial_value?: boolean): PineArrayObject;
28
+ new_float(size: number, initial_value?: number): PineArrayObject;
29
+ new_int(size: number, initial_value?: number): PineArrayObject;
30
+ new_string(size: number, initial_value?: string): PineArrayObject;
31
+ new<T>(size: number, initial_value: T): PineArrayObject;
32
+ slice(id: PineArrayObject, start: number, end?: number): PineArrayObject;
33
+ reverse(id: PineArrayObject): void;
34
+ includes(id: PineArrayObject, value: any): boolean;
35
+ indexof(id: PineArrayObject, value: any): number;
36
+ lastindexof(id: PineArrayObject, value: any): number;
37
+ stdev(id: PineArrayObject, biased?: boolean): number;
38
+ variance(id: PineArrayObject, biased?: boolean): number;
39
+ covariance(arr1: PineArrayObject, arr2: PineArrayObject, biased?: boolean): number;
40
+ first(id: PineArrayObject): any;
41
+ last(id: PineArrayObject): any;
42
+ clear(id: PineArrayObject): void;
43
+ join(id: PineArrayObject, separator?: string): string;
44
+ /** Array Manipulation Functions */
45
+ abs(id: PineArrayObject): PineArrayObject;
46
+ concat(id: PineArrayObject, other: PineArrayObject): PineArrayObject;
47
+ copy(id: PineArrayObject): PineArrayObject;
48
+ every(id: PineArrayObject, callback: (val: any) => boolean): boolean;
49
+ fill(id: PineArrayObject, value: any, start?: number, end?: number): void;
50
+ from(source: any[]): PineArrayObject;
51
+ insert(id: PineArrayObject, index: number, value: any): void;
52
+ pop(id: PineArrayObject): any;
53
+ range(id: PineArrayObject): number;
54
+ remove(id: PineArrayObject, index: number): any;
55
+ shift(id: PineArrayObject): any;
56
+ sort(id: PineArrayObject, order?: 'asc' | 'desc'): void;
57
+ sort_indices(id: PineArrayObject, comparator?: (a: any, b: any) => number): PineArrayObject;
58
+ standardize(id: PineArrayObject): PineArrayObject;
59
+ unshift(id: PineArrayObject, value: any): void;
60
+ some(id: PineArrayObject, callback: (val: any) => boolean): boolean;
61
+ }
62
+ export {};
File without changes
@@ -2,25 +2,26 @@ export declare class PineMath {
2
2
  private context;
3
3
  private _cache;
4
4
  constructor(context: any);
5
- param(source: any, index?: number): any;
6
- abs(n: number): number;
7
- pow(a: number, b: number): number;
8
- sqrt(a: number): number;
9
- log(a: number): number;
10
- ln(a: number): number;
11
- exp(a: number): number;
12
- floor(a: number): number;
13
- ceil(a: number): number;
14
- round(a: number): number;
5
+ param(source: any, index: any, name?: string): any;
6
+ abs(source: number[]): number;
7
+ pow(source: number[], power: number[]): number;
8
+ sqrt(source: number[]): number;
9
+ log(source: number[]): number;
10
+ ln(source: number[]): number;
11
+ exp(source: number[]): number;
12
+ floor(source: number[]): number;
13
+ ceil(source: number[]): number;
14
+ round(source: number[]): number;
15
15
  random(): number;
16
- max(...args: any[]): number;
17
- min(...args: any[]): number;
18
- sin(a: number): number;
19
- cos(a: number): number;
20
- tan(a: number): number;
21
- asin(a: number): number;
22
- acos(a: number): number;
23
- atan(a: number): number;
24
- avg(...args: any[]): number;
16
+ max(...source: number[]): number;
17
+ min(...source: number[]): number;
18
+ sum(source: number[], length: number): number;
19
+ sin(source: number[]): number;
20
+ cos(source: number[]): number;
21
+ tan(source: number[]): number;
22
+ acos(source: number[]): number;
23
+ asin(source: number[]): number;
24
+ atan(source: number[]): number;
25
+ avg(...sources: number[][]): number;
25
26
  }
26
27
  export default PineMath;
@@ -3,5 +3,6 @@ export declare class PineRequest {
3
3
  private _cache;
4
4
  constructor(context: any);
5
5
  param(source: any, index: any, name?: string): any[];
6
- security(symbol: any, timeframe: any, expression: any): Promise<void>;
6
+ security(symbol: any, timeframe: any, expression: any, gaps?: boolean, lookahead?: boolean, ignore_invalid_symbol?: boolean, currency?: any, calc_bars_count?: any): Promise<any>;
7
+ private _findSecContextIdx;
7
8
  }
@@ -4,7 +4,7 @@ export declare class TechnicalAnalysis {
4
4
  get tr(): any;
5
5
  param(source: any, index: any, name?: string): any;
6
6
  ema(source: any, _period: any): any;
7
- sma(source: any, _period: any): any;
7
+ sma(source: any, _period: any, _cacheId?: any): any;
8
8
  vwma(source: any, _period: any): any;
9
9
  wma(source: any, _period: any): any;
10
10
  hma(source: any, _period: any): any;
@@ -9,8 +9,10 @@ export declare class ScopeManager {
9
9
  private loopVars;
10
10
  private loopVarNames;
11
11
  private paramIdCounter;
12
+ private cacheIdCounter;
12
13
  private tempVarCounter;
13
14
  get nextParamIdArg(): any;
15
+ get nextCacheIdArg(): any;
14
16
  constructor();
15
17
  pushScope(type: string): void;
16
18
  popScope(): void;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "pinets",
3
- "version": "0.1.1",
3
+ "version": "0.1.31",
4
4
  "description": "",
5
- "main": "dist/pinets.min.es.js",
5
+ "main": "dist/pinets.dev.es.js",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "files": [
8
8
  "dist"