pinets 0.1.0
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.
- package/LICENSE +661 -0
- package/README.md +158 -0
- package/dist/pinets.dev.cjs +10125 -0
- package/dist/pinets.dev.cjs.map +1 -0
- package/dist/pinets.dev.es.js +2338 -0
- package/dist/pinets.dev.es.js.map +1 -0
- package/dist/pinets.min.browser.js +33 -0
- package/dist/pinets.min.cjs +32 -0
- package/dist/pinets.min.es.js +19 -0
- package/dist/types/Context.class.d.ts +48 -0
- package/dist/types/PineTS.class.d.ts +33 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/marketData/Binance/BinanceProvider.class.d.ts +4 -0
- package/dist/types/marketData/IProvider.d.ts +3 -0
- package/dist/types/marketData/Provider.class.d.ts +4 -0
- package/dist/types/namespaces/Core.d.ts +20 -0
- package/dist/types/namespaces/Input.d.ts +24 -0
- package/dist/types/namespaces/PineMath.d.ts +26 -0
- package/dist/types/namespaces/PineRequest.d.ts +7 -0
- package/dist/types/namespaces/Syminfo.d.ts +0 -0
- package/dist/types/namespaces/TechnicalAnalysis.d.ts +26 -0
- package/dist/types/transpiler/ScopeManager.class.d.ts +31 -0
- package/dist/types/transpiler/index.d.ts +1 -0
- package/dist/types/types/PineTypes.d.ts +48 -0
- package/package.json +48 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Input } from '@pinets/namespaces/Input';
|
|
2
|
+
import PineMath from '@pinets/namespaces/PineMath';
|
|
3
|
+
import { PineRequest } from '@pinets/namespaces/PineRequest';
|
|
4
|
+
import TechnicalAnalysis from '@pinets/namespaces/TechnicalAnalysis';
|
|
5
|
+
export declare class Context {
|
|
6
|
+
marketData: any;
|
|
7
|
+
data: any;
|
|
8
|
+
math: PineMath;
|
|
9
|
+
ta: TechnicalAnalysis;
|
|
10
|
+
input: Input;
|
|
11
|
+
request: PineRequest;
|
|
12
|
+
core: any;
|
|
13
|
+
idx: number;
|
|
14
|
+
params: any;
|
|
15
|
+
const: any;
|
|
16
|
+
var: any;
|
|
17
|
+
let: any;
|
|
18
|
+
result: any;
|
|
19
|
+
plots: any;
|
|
20
|
+
timeframe: string;
|
|
21
|
+
constructor(marketData: any);
|
|
22
|
+
/**
|
|
23
|
+
* this function is used to initialize the target variable with the source array
|
|
24
|
+
* this array will represent a time series and its values will be shifted at runtime in order to mimic Pine script behavior
|
|
25
|
+
* @param trg - the target variable name : used internally to maintain the series in the execution context
|
|
26
|
+
* @param src - the source data, can be an array or a single value
|
|
27
|
+
* @param idx - the index of the source array, used to get a sub-series of the source data
|
|
28
|
+
* @returns the target array
|
|
29
|
+
*/
|
|
30
|
+
init(trg: any, src: any, idx?: number): any;
|
|
31
|
+
/**
|
|
32
|
+
* this function is used to set the floating point precision of a number
|
|
33
|
+
* by default it is set to 10 decimals which is the same as pine script
|
|
34
|
+
* @param n - the number to be precision
|
|
35
|
+
* @param decimals - the number of decimals to precision to
|
|
36
|
+
* @returns the precision number
|
|
37
|
+
*/
|
|
38
|
+
precision(n: number, decimals?: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* This function is used to apply special transformation to internal PineTS parameters and handle them as time-series
|
|
41
|
+
* @param source - the source data, can be an array or a single value
|
|
42
|
+
* @param index - the index of the source array, used to get a sub-series of the source data
|
|
43
|
+
* @param name - the name of the parameter, used as a unique identifier in the current execution context, this allows us to properly handle the param as a series
|
|
44
|
+
* @returns the current value of the param
|
|
45
|
+
*/
|
|
46
|
+
param(source: any, index: any, name?: string): any;
|
|
47
|
+
}
|
|
48
|
+
export default Context;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Context } from '@pinets/index';
|
|
2
|
+
import { IProvider } from '@pinets/marketData/IProvider';
|
|
3
|
+
/**
|
|
4
|
+
* This class is a wrapper for the Pine Script language, it allows to run Pine Script code in a JavaScript environment
|
|
5
|
+
*/
|
|
6
|
+
export declare class PineTS {
|
|
7
|
+
private source;
|
|
8
|
+
private tickerId?;
|
|
9
|
+
private timeframe?;
|
|
10
|
+
private limit?;
|
|
11
|
+
private sDate?;
|
|
12
|
+
private eDate?;
|
|
13
|
+
data: any;
|
|
14
|
+
open: any;
|
|
15
|
+
high: any;
|
|
16
|
+
low: any;
|
|
17
|
+
close: any;
|
|
18
|
+
volume: any;
|
|
19
|
+
hl2: any;
|
|
20
|
+
hlc3: any;
|
|
21
|
+
ohlc4: any;
|
|
22
|
+
openTime: any;
|
|
23
|
+
closeTime: any;
|
|
24
|
+
private _periods;
|
|
25
|
+
get periods(): number;
|
|
26
|
+
private _readyPromise;
|
|
27
|
+
private _ready;
|
|
28
|
+
constructor(source: IProvider | any[], tickerId?: string, timeframe?: string, limit?: number, sDate?: number, eDate?: number);
|
|
29
|
+
private loadMarketData;
|
|
30
|
+
ready(): Promise<any>;
|
|
31
|
+
run(fn: Function | String, n?: number): Promise<Context>;
|
|
32
|
+
}
|
|
33
|
+
export default PineTS;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class Core {
|
|
2
|
+
private context;
|
|
3
|
+
color: {
|
|
4
|
+
white: string;
|
|
5
|
+
lime: string;
|
|
6
|
+
green: string;
|
|
7
|
+
red: string;
|
|
8
|
+
maroon: string;
|
|
9
|
+
black: string;
|
|
10
|
+
gray: string;
|
|
11
|
+
blue: string;
|
|
12
|
+
};
|
|
13
|
+
constructor(context: any);
|
|
14
|
+
private extractPlotOptions;
|
|
15
|
+
indicator(title: string, shorttitle?: string, options?: IndicatorOptions): void;
|
|
16
|
+
plotchar(series: number[], title: string, options: PlotCharOptions): void;
|
|
17
|
+
plot(series: any, title: string, options: PlotOptions): void;
|
|
18
|
+
na(series: any): boolean;
|
|
19
|
+
nz(series: any, replacement?: number): any;
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type InputOptions = {
|
|
2
|
+
title?: string;
|
|
3
|
+
group?: string;
|
|
4
|
+
} | any;
|
|
5
|
+
export declare class Input {
|
|
6
|
+
private context;
|
|
7
|
+
constructor(context: any);
|
|
8
|
+
param(source: any, index?: number): any[];
|
|
9
|
+
any(value: any, { title, group }?: InputOptions): any;
|
|
10
|
+
int(value: number, { title, group }?: InputOptions): any;
|
|
11
|
+
float(value: number, { title, group }?: InputOptions): any;
|
|
12
|
+
bool(value: boolean, { title, group }?: InputOptions): any;
|
|
13
|
+
string(value: string, { title, group }?: InputOptions): any;
|
|
14
|
+
timeframe(value: string, { title, group }?: InputOptions): any;
|
|
15
|
+
time(value: number, { title, group }?: InputOptions): any;
|
|
16
|
+
price(value: number, { title, group }?: InputOptions): any;
|
|
17
|
+
session(value: string, { title, group }?: InputOptions): any;
|
|
18
|
+
source(value: any, { title, group }?: InputOptions): any;
|
|
19
|
+
symbol(value: string, { title, group }?: InputOptions): any;
|
|
20
|
+
text_area(value: string, { title, group }?: InputOptions): any;
|
|
21
|
+
enum(value: string, { title, group }?: InputOptions): any;
|
|
22
|
+
color(value: string, { title, group }?: InputOptions): any;
|
|
23
|
+
}
|
|
24
|
+
export default Input;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare class PineMath {
|
|
2
|
+
private context;
|
|
3
|
+
private _cache;
|
|
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;
|
|
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;
|
|
25
|
+
}
|
|
26
|
+
export default PineMath;
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare class TechnicalAnalysis {
|
|
2
|
+
private context;
|
|
3
|
+
constructor(context: any);
|
|
4
|
+
get tr(): any;
|
|
5
|
+
param(source: any, index: any, name?: string): any;
|
|
6
|
+
ema(source: any, _period: any): any;
|
|
7
|
+
sma(source: any, _period: any): any;
|
|
8
|
+
vwma(source: any, _period: any): any;
|
|
9
|
+
wma(source: any, _period: any): any;
|
|
10
|
+
hma(source: any, _period: any): any;
|
|
11
|
+
rma(source: any, _period: any): any;
|
|
12
|
+
change(source: any, _length?: number): any;
|
|
13
|
+
rsi(source: any, _period: any): any;
|
|
14
|
+
atr(_period: any): any;
|
|
15
|
+
mom(source: any, _length: any): any;
|
|
16
|
+
roc(source: any, _length: any): any;
|
|
17
|
+
dev(source: any, _length: any): any;
|
|
18
|
+
variance(source: any, _length: any): any;
|
|
19
|
+
highest(source: any, _length: any): any;
|
|
20
|
+
lowest(source: any, _length: any): any;
|
|
21
|
+
median(source: any, _length: any): any;
|
|
22
|
+
stdev(source: any, _length: any, _bias?: boolean): any;
|
|
23
|
+
linreg(source: any, _length: any, _offset: any): any;
|
|
24
|
+
supertrend(_factor: any, _atrPeriod: any): any[][];
|
|
25
|
+
}
|
|
26
|
+
export default TechnicalAnalysis;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare class ScopeManager {
|
|
2
|
+
private scopes;
|
|
3
|
+
private scopeTypes;
|
|
4
|
+
private scopeCounts;
|
|
5
|
+
private contextBoundVars;
|
|
6
|
+
private arrayPatternElements;
|
|
7
|
+
private rootParams;
|
|
8
|
+
private varKinds;
|
|
9
|
+
private loopVars;
|
|
10
|
+
private loopVarNames;
|
|
11
|
+
private paramIdCounter;
|
|
12
|
+
private tempVarCounter;
|
|
13
|
+
get nextParamIdArg(): any;
|
|
14
|
+
constructor();
|
|
15
|
+
pushScope(type: string): void;
|
|
16
|
+
popScope(): void;
|
|
17
|
+
getCurrentScopeType(): string;
|
|
18
|
+
getCurrentScopeCount(): number;
|
|
19
|
+
addContextBoundVar(name: string, isRootParam?: boolean): void;
|
|
20
|
+
addArrayPatternElement(name: string): void;
|
|
21
|
+
isContextBound(name: string): boolean;
|
|
22
|
+
isArrayPatternElement(name: string): boolean;
|
|
23
|
+
isRootParam(name: string): boolean;
|
|
24
|
+
addLoopVariable(originalName: string, transformedName: string): void;
|
|
25
|
+
getLoopVariableName(name: string): string | undefined;
|
|
26
|
+
isLoopVariable(name: string): boolean;
|
|
27
|
+
addVariable(name: string, kind: string): string;
|
|
28
|
+
getVariable(name: string): [string, string];
|
|
29
|
+
generateTempVar(): string;
|
|
30
|
+
}
|
|
31
|
+
export default ScopeManager;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function transpile(fn: string | Function): Function;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
type PlotCharOptions = {
|
|
2
|
+
title?: string;
|
|
3
|
+
char?: string;
|
|
4
|
+
location?: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
offset?: number;
|
|
7
|
+
text?: string;
|
|
8
|
+
textcolor?: string;
|
|
9
|
+
editable?: boolean;
|
|
10
|
+
size?: number;
|
|
11
|
+
show_last?: boolean;
|
|
12
|
+
display?: boolean;
|
|
13
|
+
format?: string;
|
|
14
|
+
precision?: number;
|
|
15
|
+
force_overlay?: boolean;
|
|
16
|
+
};
|
|
17
|
+
type PlotOptions = {
|
|
18
|
+
color?: string;
|
|
19
|
+
linewidth?: number;
|
|
20
|
+
style?: string;
|
|
21
|
+
trackprice?: boolean;
|
|
22
|
+
histbase?: boolean;
|
|
23
|
+
offset?: number;
|
|
24
|
+
join?: boolean;
|
|
25
|
+
editable?: boolean;
|
|
26
|
+
show_last?: boolean;
|
|
27
|
+
display?: boolean;
|
|
28
|
+
format?: string;
|
|
29
|
+
precision?: number;
|
|
30
|
+
force_overlay?: boolean;
|
|
31
|
+
};
|
|
32
|
+
type IndicatorOptions = {
|
|
33
|
+
overlay?: boolean;
|
|
34
|
+
format?: string;
|
|
35
|
+
precision?: number;
|
|
36
|
+
scale?: number;
|
|
37
|
+
max_bars_back?: number;
|
|
38
|
+
timeframe?: string;
|
|
39
|
+
timeframe_gaps?: boolean;
|
|
40
|
+
explicit_plot_zorder?: number;
|
|
41
|
+
max_lines_count?: number;
|
|
42
|
+
max_labels_count?: number;
|
|
43
|
+
max_boxes_count?: number;
|
|
44
|
+
calc_bars_count?: number;
|
|
45
|
+
max_polylines_count?: number;
|
|
46
|
+
dynamic_requests?: boolean;
|
|
47
|
+
behind_chart?: boolean;
|
|
48
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pinets",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/pinets.min.es.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "cross-env TEST_ENV=true vitest --reporter verbose",
|
|
13
|
+
"build:dev:all": "npm run build:dev:browser && npm run build:dev:cjs && npm run build:dev:es && tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
|
|
14
|
+
"build:dev:cjs": "cross-env BUILD=dev FORMAT=cjs rollup -c ./rollup.config.js",
|
|
15
|
+
"build:dev:browser": "cross-env BUILD=dev FORMAT=browser rollup -c ./rollup.config.js",
|
|
16
|
+
"build:dev:es": "cross-env BUILD=dev rollup -c ./rollup.config.js",
|
|
17
|
+
"build:prod:all": "npm run build:prod:browser && npm run build:prod:cjs && npm run build:prod:es && tsc --emitDeclarationOnly --declaration --outDir dist/types -p tsconfig.dts.json",
|
|
18
|
+
"build:prod:cjs": "cross-env BUILD=prod FORMAT=cjs rollup -c ./rollup.config.js",
|
|
19
|
+
"build:prod:browser": "cross-env BUILD=prod FORMAT=browser rollup -c ./rollup.config.js",
|
|
20
|
+
"build:prod:es": "cross-env BUILD=prod rollup -c ./rollup.config.js",
|
|
21
|
+
"knip": "knip"
|
|
22
|
+
},
|
|
23
|
+
"author": "Alaa-eddine KADDOURI",
|
|
24
|
+
"license": "AGPL-3.0",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"acorn": "^8.14.0",
|
|
27
|
+
"acorn-walk": "^8.3.4",
|
|
28
|
+
"astring": "^1.9.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
32
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
34
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
35
|
+
"cross-env": "^7.0.3",
|
|
36
|
+
"knip": "^5.43.6",
|
|
37
|
+
"rollup": "^2.79.2",
|
|
38
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
39
|
+
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
40
|
+
"rollup-plugin-typescript-paths": "^1.5.0",
|
|
41
|
+
"vite-tsconfig-paths": "^4.3.2",
|
|
42
|
+
"vitest": "^2.0.0"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/alaa-eddine/PineTS.git"
|
|
47
|
+
}
|
|
48
|
+
}
|