oakscriptjs 0.19.0 → 0.21.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/dist/cjs/box/index.d.ts +3 -3
- package/dist/cjs/box/index.d.ts.map +1 -1
- package/dist/cjs/box/index.js.map +2 -2
- package/dist/cjs/check/harness.d.ts.map +1 -1
- package/dist/cjs/check/harness.js +35 -1
- package/dist/cjs/check/harness.js.map +2 -2
- package/dist/cjs/drawing/output.d.ts +2 -1
- package/dist/cjs/drawing/output.d.ts.map +1 -1
- package/dist/cjs/drawing/output.js +5 -4
- package/dist/cjs/drawing/output.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/label/index.d.ts +2 -2
- package/dist/cjs/label/index.d.ts.map +1 -1
- package/dist/cjs/label/index.js.map +2 -2
- package/dist/cjs/line/index.d.ts +4 -4
- package/dist/cjs/line/index.d.ts.map +1 -1
- package/dist/cjs/line/index.js +1 -1
- package/dist/cjs/line/index.js.map +2 -2
- package/dist/cjs/polyline/index.d.ts +2 -2
- package/dist/cjs/polyline/index.d.ts.map +1 -1
- package/dist/cjs/polyline/index.js.map +2 -2
- package/dist/cjs/script/constants.d.ts +6 -1
- package/dist/cjs/script/constants.d.ts.map +1 -1
- package/dist/cjs/script/constants.js +2 -1
- package/dist/cjs/script/constants.js.map +2 -2
- package/dist/cjs/script/globals.d.ts +3 -0
- package/dist/cjs/script/globals.d.ts.map +1 -1
- package/dist/cjs/script/globals.js.map +1 -1
- package/dist/cjs/script/index.d.ts +255 -28
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +349 -34
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/security/events.d.ts +16 -0
- package/dist/cjs/security/events.d.ts.map +1 -0
- package/dist/cjs/security/events.js +84 -0
- package/dist/cjs/security/events.js.map +7 -0
- package/dist/cjs/types/index.d.ts +13 -11
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +3 -1
- package/dist/cjs/types/index.js.map +2 -2
- package/dist/cjs/types/metadata.d.ts +12 -8
- package/dist/cjs/types/metadata.d.ts.map +1 -1
- package/dist/cjs/types/metadata.js.map +1 -1
- package/dist/esm/box/index.d.ts +3 -3
- package/dist/esm/box/index.d.ts.map +1 -1
- package/dist/esm/box/index.js +1 -1
- package/dist/esm/box/index.js.map +1 -1
- package/dist/esm/check/harness.d.ts.map +1 -1
- package/dist/esm/check/harness.js +25 -0
- package/dist/esm/check/harness.js.map +1 -1
- package/dist/esm/drawing/output.d.ts +2 -1
- package/dist/esm/drawing/output.d.ts.map +1 -1
- package/dist/esm/drawing/output.js +9 -7
- package/dist/esm/drawing/output.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/label/index.d.ts +2 -2
- package/dist/esm/label/index.d.ts.map +1 -1
- package/dist/esm/label/index.js.map +1 -1
- package/dist/esm/line/index.d.ts +4 -4
- package/dist/esm/line/index.d.ts.map +1 -1
- package/dist/esm/line/index.js +3 -3
- package/dist/esm/line/index.js.map +1 -1
- package/dist/esm/polyline/index.d.ts +2 -2
- package/dist/esm/polyline/index.d.ts.map +1 -1
- package/dist/esm/polyline/index.js +1 -1
- package/dist/esm/polyline/index.js.map +1 -1
- package/dist/esm/script/constants.d.ts +6 -1
- package/dist/esm/script/constants.d.ts.map +1 -1
- package/dist/esm/script/constants.js +6 -1
- package/dist/esm/script/constants.js.map +1 -1
- package/dist/esm/script/globals.d.ts +3 -0
- package/dist/esm/script/globals.d.ts.map +1 -1
- package/dist/esm/script/globals.js.map +1 -1
- package/dist/esm/script/index.d.ts +255 -28
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +370 -38
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/security/events.d.ts +16 -0
- package/dist/esm/security/events.d.ts.map +1 -0
- package/dist/esm/security/events.js +78 -0
- package/dist/esm/security/events.js.map +1 -0
- package/dist/esm/types/index.d.ts +13 -11
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +3 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/metadata.d.ts +12 -8
- package/dist/esm/types/metadata.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/oakscript/reference/pine-differences.md +2 -0
- package/skills/oakscript/reference/plotting.md +24 -1
- package/skills/oakscript/reference/timeframes-symbols.md +27 -0
- package/src/box/index.ts +4 -4
- package/src/check/harness.ts +27 -0
- package/src/drawing/output.ts +12 -8
- package/src/index.ts +1 -1
- package/src/label/index.ts +3 -3
- package/src/line/index.ts +6 -6
- package/src/polyline/index.ts +2 -2
- package/src/script/constants.ts +6 -1
- package/src/script/globals.ts +3 -0
- package/src/script/index.ts +580 -50
- package/src/security/events.ts +85 -0
- package/src/types/index.ts +13 -11
- package/src/types/metadata.ts +12 -8
|
@@ -108,6 +108,9 @@ export interface ScriptRunResult {
|
|
|
108
108
|
/** The script called alert() during the run (PineScript `hasAlertFunction` is known at compile time: a host that
|
|
109
109
|
* needs it before any bar runs reads the source). */
|
|
110
110
|
hasAlertFunction: boolean;
|
|
111
|
+
/** The script read `chart.left_visible_bar_time` or `chart.right_visible_bar_time`: it has to be calculated again when
|
|
112
|
+
* the visible range of the chart changes. */
|
|
113
|
+
usesVisibleRange: boolean;
|
|
111
114
|
}
|
|
112
115
|
export interface AlertConditionConfig {
|
|
113
116
|
id: string;
|
|
@@ -566,7 +569,8 @@ export declare const ta: {
|
|
|
566
569
|
export declare function fixnan(source: Series): Series;
|
|
567
570
|
export declare function fixnan(source: Array<string | undefined>): Array<string | undefined>;
|
|
568
571
|
/** PineScript `na(x)`. On a Series: a Series of 1 / 0, 1 where the value is na (NaN or +/-Infinity, #187). On a
|
|
569
|
-
* single value (a number of a bar loop, a colour, a drawing): true when it is na.
|
|
572
|
+
* single value (a number of a bar loop, a colour, a drawing): true when it is na. An empty text is na, as in
|
|
573
|
+
* PineScript (`na("")`, `na(syminfo.basecurrency)` of a stock). */
|
|
570
574
|
export declare function na(x: Series): Series;
|
|
571
575
|
export declare function na(x: unknown): boolean;
|
|
572
576
|
/** PineScript `nz(source, replacement)`; replacement defaults to 0. On a Series: each na value (NaN or +/-Infinity)
|
|
@@ -892,6 +896,8 @@ export type StrategyApi = ((title: string, options?: StrategyOptions) => void) &
|
|
|
892
896
|
* ```
|
|
893
897
|
*/
|
|
894
898
|
export declare const strategy: StrategyApi;
|
|
899
|
+
/** Types of chart PineScript tells apart (`chart.is_*`); every other type is 'standard'. */
|
|
900
|
+
export type ChartType = 'standard' | 'heikinashi' | 'renko' | 'kagi' | 'linebreak' | 'pnf' | 'range';
|
|
895
901
|
/**
|
|
896
902
|
* What the caller knows about the loaded bars. PineScript reads these values from the chart and
|
|
897
903
|
* the symbol; nothing is fetched here. A script that needs a value the caller did not give throws.
|
|
@@ -937,17 +943,67 @@ export interface ChartContext {
|
|
|
937
943
|
currency?: string;
|
|
938
944
|
/**
|
|
939
945
|
* Base currency of the symbol (PineScript `syminfo.basecurrency`): "BTC" for BITSTAMP:BTCUSD, BINANCE:BTCUSDT.P and
|
|
940
|
-
* CME:BTC1!, "EUR" for FX:EURUSD, "" for a stock, an index or CME_MINI:ES1! (#180)
|
|
946
|
+
* CME:BTC1!, "EUR" for FX:EURUSD, "" for a stock, an index or CME_MINI:ES1! (#180).
|
|
947
|
+
*
|
|
948
|
+
* The symbol fields below, like this one: a value; null when the symbol has none (PineScript gives na: "" for a
|
|
949
|
+
* text, which `na()` takes as na, NaN for a number); left out when the host does not know it (reading it throws).
|
|
941
950
|
*/
|
|
942
|
-
basecurrency?: string;
|
|
943
|
-
/**
|
|
944
|
-
|
|
951
|
+
basecurrency?: string | null;
|
|
952
|
+
/**
|
|
953
|
+
* Root of the symbol (PineScript `syminfo.root`): "BTC" for CME:BTC1!, "ES" for CME_MINI:ES1!, "AAPL" for
|
|
954
|
+
* NASDAQ:AAPL (#180). Default: the ticker, without the "1!" of a continuous future or the month code and year of a
|
|
955
|
+
* contract ("ESZ2026" of a `symbolType` "futures").
|
|
956
|
+
*/
|
|
957
|
+
root?: string | null;
|
|
945
958
|
/** Description of the symbol (PineScript `syminfo.description`): "Apple Inc." for NASDAQ:AAPL, "Bitcoin / U.S. dollar" for BITSTAMP:BTCUSD (#184) */
|
|
946
|
-
description?: string;
|
|
959
|
+
description?: string | null;
|
|
960
|
+
/** Prefix of the ticker id (PineScript `syminfo.prefix`), default: the part of `tickerid` before ":" */
|
|
961
|
+
prefix?: string | null;
|
|
962
|
+
/** Ticker without its prefix (PineScript `syminfo.ticker`), default: the part of `tickerid` after ":" */
|
|
963
|
+
ticker?: string;
|
|
964
|
+
/** The chart's own symbol (PineScript `syminfo.main_tickerid`, the same inside `request.security`); default `tickerid` */
|
|
965
|
+
mainTickerid?: string;
|
|
966
|
+
/** Two-letter code of the country the symbol trades in (PineScript `syminfo.country`): "US", "IN" */
|
|
967
|
+
country?: string | null;
|
|
968
|
+
/** Contract a continuous future stands for (PineScript `syminfo.current_contract`): "ESZ2026" for CME_MINI:ES1! */
|
|
969
|
+
currentContract?: string | null;
|
|
970
|
+
/** Last trading day of a future's contract, in ms (PineScript `syminfo.expiration_date`) */
|
|
971
|
+
expirationDate?: number | null;
|
|
972
|
+
/** PineScript `syminfo.sector` and `syminfo.industry` of a company */
|
|
973
|
+
sector?: string | null;
|
|
974
|
+
industry?: string | null;
|
|
975
|
+
/** PineScript `syminfo.isin`: "US0378331005" for NASDAQ:AAPL */
|
|
976
|
+
isin?: string | null;
|
|
977
|
+
/** Unit of the volume (PineScript `syminfo.volumetype`): "base" (crypto: in the base currency), "quote", "tick", "n/a" */
|
|
978
|
+
volumetype?: string | null;
|
|
979
|
+
/** PineScript `syminfo.employees`, `syminfo.shareholders`, `syminfo.shares_outstanding_total` / `_float` */
|
|
980
|
+
employees?: number | null;
|
|
981
|
+
shareholders?: number | null;
|
|
982
|
+
sharesOutstandingTotal?: number | null;
|
|
983
|
+
sharesOutstandingFloat?: number | null;
|
|
984
|
+
/** Analysts' ratings (PineScript `syminfo.recommendations_*`; `date` in ms) */
|
|
985
|
+
recommendations?: SymbolRecommendations | null;
|
|
986
|
+
/** Analysts' price targets (PineScript `syminfo.target_price_*`; `date` in ms) */
|
|
987
|
+
targetPrice?: SymbolTargetPrice | null;
|
|
988
|
+
/**
|
|
989
|
+
* Dividends, splits and earnings of a symbol (PineScript `request.dividends`, `request.splits`, `request.earnings`,
|
|
990
|
+
* `dividends.future_*`, `earnings.future_*`). Return undefined when they are not loaded: the run then ends with a
|
|
991
|
+
* {@link MissingSymbolDataError} whose request has `events: true`. Return {} for a symbol without any.
|
|
992
|
+
*/
|
|
993
|
+
events?: (symbol: string) => SymbolEvents | undefined;
|
|
947
994
|
/** Chart foreground colour (PineScript `chart.fg_color`), e.g. "#DBDBDB" on a dark chart */
|
|
948
995
|
foregroundColor?: string;
|
|
949
996
|
/** Chart background colour (PineScript `chart.bg_color`), e.g. "#0F0F0F" on a dark chart */
|
|
950
997
|
backgroundColor?: string;
|
|
998
|
+
/**
|
|
999
|
+
* Times (ms) of the first and the last bar in view (PineScript `chart.left_visible_bar_time` and
|
|
1000
|
+
* `chart.right_visible_bar_time`); default: the first and the last bar. A script that reads them
|
|
1001
|
+
* ({@link ScriptRunResult.usesVisibleRange}) has to be calculated again when they change.
|
|
1002
|
+
*/
|
|
1003
|
+
leftVisibleBarTime?: number;
|
|
1004
|
+
rightVisibleBarTime?: number;
|
|
1005
|
+
/** Type of the chart (PineScript `chart.is_standard`, `chart.is_heikinashi`...); default 'standard' */
|
|
1006
|
+
chartType?: ChartType;
|
|
951
1007
|
/** Current time in ms (PineScript `timenow`); default: the clock of the computer at the start of the run */
|
|
952
1008
|
now?: number;
|
|
953
1009
|
/**
|
|
@@ -978,11 +1034,81 @@ export interface ChartContext {
|
|
|
978
1034
|
seedSymbol?: (source: string, symbol: string) => string;
|
|
979
1035
|
}
|
|
980
1036
|
/** Calendar and properties of a symbol, as in {@link ChartContext}. */
|
|
981
|
-
export type SymbolInfo = Pick<ChartContext, 'timezone' | 'session' | 'regularSession' | 'mintick' | 'minmove' | 'pricescale' | 'pointvalue' | 'mincontract' | 'symbolType' | 'currency' | 'basecurrency' | 'root' | 'description'>;
|
|
982
|
-
/**
|
|
1037
|
+
export type SymbolInfo = Pick<ChartContext, 'timezone' | 'session' | 'regularSession' | 'mintick' | 'minmove' | 'pricescale' | 'pointvalue' | 'mincontract' | 'symbolType' | 'currency' | 'basecurrency' | 'root' | 'description' | 'prefix' | 'ticker' | 'country' | 'currentContract' | 'expirationDate' | 'sector' | 'industry' | 'isin' | 'volumetype' | 'employees' | 'shareholders' | 'sharesOutstandingTotal' | 'sharesOutstandingFloat' | 'recommendations' | 'targetPrice'>;
|
|
1038
|
+
/** Analysts' ratings of a symbol: counts of each rating, and the date of the count (ms). */
|
|
1039
|
+
export interface SymbolRecommendations {
|
|
1040
|
+
buy: number;
|
|
1041
|
+
buy_strong: number;
|
|
1042
|
+
hold: number;
|
|
1043
|
+
sell: number;
|
|
1044
|
+
sell_strong: number;
|
|
1045
|
+
total: number;
|
|
1046
|
+
date: number;
|
|
1047
|
+
}
|
|
1048
|
+
/** Analysts' price targets of a symbol, their number and the date of the figures (ms). */
|
|
1049
|
+
export interface SymbolTargetPrice {
|
|
1050
|
+
average: number;
|
|
1051
|
+
high: number;
|
|
1052
|
+
low: number;
|
|
1053
|
+
median: number;
|
|
1054
|
+
estimates: number;
|
|
1055
|
+
date: number;
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* A dividend: `time` the ex-date (ms; 00:00 UTC of the day, as PineScript's dividends are stamped), the amount per
|
|
1059
|
+
* share as declared (not adjusted for later splits), net and gross of withholding tax (gross defaults to net).
|
|
1060
|
+
*/
|
|
1061
|
+
export interface DividendEvent {
|
|
1062
|
+
time: number;
|
|
1063
|
+
net: number;
|
|
1064
|
+
gross?: number;
|
|
1065
|
+
/** Payment date (ms) */
|
|
1066
|
+
payDate?: number | null;
|
|
1067
|
+
}
|
|
1068
|
+
/** A split from `denominator` shares to `numerator` (4 and 1 for a 4-for-1 split); `time` its date (ms, 00:00 UTC). */
|
|
1069
|
+
export interface SplitEvent {
|
|
1070
|
+
time: number;
|
|
1071
|
+
numerator: number;
|
|
1072
|
+
denominator: number;
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* An earnings release: `time` when it was published (ms; a release after the close is after the session's close). The
|
|
1076
|
+
* values per share are adjusted for later splits, as PineScript gives them. A value the host does not have is left
|
|
1077
|
+
* out; a script that asks for it then stops with an error.
|
|
1078
|
+
*/
|
|
1079
|
+
export interface EarningsEvent {
|
|
1080
|
+
time: number;
|
|
1081
|
+
/** Reported earnings per share (`earnings.actual`), the analysts' estimate (`earnings.estimate`), standardized
|
|
1082
|
+
* earnings per share (`earnings.standardized`) */
|
|
1083
|
+
actual?: number | null;
|
|
1084
|
+
estimate?: number | null;
|
|
1085
|
+
standardized?: number | null;
|
|
1086
|
+
/** Estimated revenue (`earnings.future_revenue`) and the end of the fiscal period (ms) */
|
|
1087
|
+
revenueEstimate?: number | null;
|
|
1088
|
+
periodEnd?: number | null;
|
|
1089
|
+
}
|
|
1090
|
+
/** Events of a symbol, oldest first. */
|
|
1091
|
+
export interface SymbolEvents {
|
|
1092
|
+
dividends?: DividendEvent[];
|
|
1093
|
+
splits?: SplitEvent[];
|
|
1094
|
+
earnings?: EarningsEvent[];
|
|
1095
|
+
/**
|
|
1096
|
+
* The lists hold the announced events still to come (`dividends.future_*`, `earnings.future_*` read them): without
|
|
1097
|
+
* it the future values are not known and reading them throws.
|
|
1098
|
+
*/
|
|
1099
|
+
future?: {
|
|
1100
|
+
dividends?: boolean;
|
|
1101
|
+
earnings?: boolean;
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* A request of `request.security` for another symbol whose bars the host has not given, or (`events`) of
|
|
1106
|
+
* `request.dividends` / `request.splits` / `request.earnings` for a symbol whose events it has not given.
|
|
1107
|
+
*/
|
|
983
1108
|
export interface SymbolDataRequest {
|
|
984
1109
|
symbol: string;
|
|
985
1110
|
timeframe: string;
|
|
1111
|
+
events?: boolean;
|
|
986
1112
|
}
|
|
987
1113
|
/**
|
|
988
1114
|
* Thrown by `executeScript` when `request.security` asked for bars of another symbol that `ChartContext.bars` did not
|
|
@@ -1016,9 +1142,8 @@ export declare const timeframe: {
|
|
|
1016
1142
|
info(timeframe: import("../index.js").simple_string): timeframeCore.TimeframeInfo;
|
|
1017
1143
|
};
|
|
1018
1144
|
/**
|
|
1019
|
-
* PineScript `syminfo
|
|
1020
|
-
*
|
|
1021
|
-
* `syminfo.currency`, `syminfo.basecurrency`, `syminfo.root` and `syminfo.description`, from the chart context.
|
|
1145
|
+
* PineScript `syminfo.*`, from the chart context (inside `request.security`, the requested symbol's). A field the
|
|
1146
|
+
* symbol has none of is na ("" for a text); a field the host did not give throws.
|
|
1022
1147
|
*/
|
|
1023
1148
|
export declare const syminfo: {
|
|
1024
1149
|
readonly mintick: number;
|
|
@@ -1028,12 +1153,39 @@ export declare const syminfo: {
|
|
|
1028
1153
|
readonly mincontract: number;
|
|
1029
1154
|
readonly timezone: string;
|
|
1030
1155
|
readonly tickerid: string;
|
|
1156
|
+
readonly main_tickerid: string;
|
|
1157
|
+
readonly ticker: string;
|
|
1158
|
+
readonly prefix: string;
|
|
1031
1159
|
readonly session: string;
|
|
1032
1160
|
readonly type: string;
|
|
1033
1161
|
readonly currency: string;
|
|
1034
1162
|
readonly basecurrency: string;
|
|
1035
1163
|
readonly root: string;
|
|
1036
1164
|
readonly description: string;
|
|
1165
|
+
readonly country: string;
|
|
1166
|
+
readonly current_contract: string;
|
|
1167
|
+
readonly expiration_date: number;
|
|
1168
|
+
readonly sector: string;
|
|
1169
|
+
readonly industry: string;
|
|
1170
|
+
readonly isin: string;
|
|
1171
|
+
readonly volumetype: string;
|
|
1172
|
+
readonly employees: number;
|
|
1173
|
+
readonly shareholders: number;
|
|
1174
|
+
readonly shares_outstanding_total: number;
|
|
1175
|
+
readonly shares_outstanding_float: number;
|
|
1176
|
+
readonly recommendations_buy: number;
|
|
1177
|
+
readonly recommendations_buy_strong: number;
|
|
1178
|
+
readonly recommendations_hold: number;
|
|
1179
|
+
readonly recommendations_sell: number;
|
|
1180
|
+
readonly recommendations_sell_strong: number;
|
|
1181
|
+
readonly recommendations_total: number;
|
|
1182
|
+
readonly recommendations_date: number;
|
|
1183
|
+
readonly target_price_average: number;
|
|
1184
|
+
readonly target_price_high: number;
|
|
1185
|
+
readonly target_price_low: number;
|
|
1186
|
+
readonly target_price_median: number;
|
|
1187
|
+
readonly target_price_estimates: number;
|
|
1188
|
+
readonly target_price_date: number;
|
|
1037
1189
|
};
|
|
1038
1190
|
/** A calendar function: `(time, timezone?)` on a UNIX time or on a Series of times. */
|
|
1039
1191
|
interface CalendarFunction {
|
|
@@ -1203,10 +1355,72 @@ declare function seedCall<T extends SecurityValue>(...args: [source: string, sym
|
|
|
1203
1355
|
symbol: string;
|
|
1204
1356
|
expression: () => T;
|
|
1205
1357
|
}]): T extends unknown[] ? Series[] : Series;
|
|
1358
|
+
/** PineScript `dividends.*`: the fields of `request.dividends` and the next announced dividend of the chart symbol. */
|
|
1359
|
+
export declare const dividends: {
|
|
1360
|
+
readonly net: "net";
|
|
1361
|
+
readonly gross: "gross";
|
|
1362
|
+
/** Amount of the next dividend (net), na when none is announced */
|
|
1363
|
+
readonly future_amount: number;
|
|
1364
|
+
/** Ex-date of the next dividend (ms) */
|
|
1365
|
+
readonly future_ex_date: number;
|
|
1366
|
+
/** Payment date of the next dividend (ms) */
|
|
1367
|
+
readonly future_pay_date: number;
|
|
1368
|
+
};
|
|
1369
|
+
/** PineScript `splits.*`: the fields of `request.splits`. */
|
|
1370
|
+
export declare const splits: {
|
|
1371
|
+
readonly numerator: "numerator";
|
|
1372
|
+
readonly denominator: "denominator";
|
|
1373
|
+
};
|
|
1374
|
+
/** PineScript `earnings.*`: the fields of `request.earnings` and the next earnings release of the chart symbol. */
|
|
1375
|
+
export declare const earnings: {
|
|
1376
|
+
readonly actual: "actual";
|
|
1377
|
+
readonly estimate: "estimate";
|
|
1378
|
+
readonly standardized: "standardized";
|
|
1379
|
+
/** Estimated earnings per share of the next release */
|
|
1380
|
+
readonly future_eps: number;
|
|
1381
|
+
/** Estimated revenue of the next release */
|
|
1382
|
+
readonly future_revenue: number;
|
|
1383
|
+
/** Time of the next release (ms) */
|
|
1384
|
+
readonly future_time: number;
|
|
1385
|
+
/** End of the fiscal period of the next release (ms) */
|
|
1386
|
+
readonly future_period_end_time: number;
|
|
1387
|
+
};
|
|
1388
|
+
/** Named arguments of `request.dividends` / `request.earnings` (`request.splits` has no `currency`). */
|
|
1389
|
+
export interface EventRequestArgs {
|
|
1390
|
+
ticker?: string;
|
|
1391
|
+
field?: string;
|
|
1392
|
+
gaps?: string;
|
|
1393
|
+
lookahead?: string;
|
|
1394
|
+
ignore_invalid_symbol?: boolean;
|
|
1395
|
+
currency?: string;
|
|
1396
|
+
}
|
|
1397
|
+
type EventRequestCall = [ticker: string, field?: string, gaps?: string, lookahead?: string, ignore_invalid_symbol?: boolean, currency?: string] | [ticker: string, field: string, args: EventRequestArgs] | [ticker: string, args: EventRequestArgs] | [args: EventRequestArgs & {
|
|
1398
|
+
ticker: string;
|
|
1399
|
+
}];
|
|
1400
|
+
/**
|
|
1401
|
+
* PineScript `request.dividends(ticker, field, gaps, lookahead, ignore_invalid_symbol, currency)`: the dividend per
|
|
1402
|
+
* share (`dividends.net`, default, or `dividends.gross`) as declared, from the bar after its ex-date's day (see
|
|
1403
|
+
* `security/events`). na before the first dividend. The events come from `ChartContext.events`.
|
|
1404
|
+
*/
|
|
1405
|
+
declare function dividendsCall(...args: EventRequestCall): Series;
|
|
1406
|
+
/**
|
|
1407
|
+
* PineScript `request.splits(ticker, field, gaps, lookahead, ignore_invalid_symbol)`: the numerator
|
|
1408
|
+
* (`splits.numerator`) or the denominator (`splits.denominator`) of the last split, from the bar after its day.
|
|
1409
|
+
*/
|
|
1410
|
+
declare function splitsCall(...args: EventRequestCall): Series;
|
|
1411
|
+
/**
|
|
1412
|
+
* PineScript `request.earnings(ticker, field, gaps, lookahead, ignore_invalid_symbol, currency)`: earnings per share of
|
|
1413
|
+
* the last release (`earnings.actual`, default, `earnings.estimate` or `earnings.standardized`), from the bar after the
|
|
1414
|
+
* period of the chart timeframe it was published in (the next day on a daily chart).
|
|
1415
|
+
*/
|
|
1416
|
+
declare function earningsCall(...args: EventRequestCall): Series;
|
|
1206
1417
|
export declare const request: {
|
|
1207
1418
|
security: typeof securityCall;
|
|
1208
1419
|
security_lower_tf: typeof securityLowerTfCall;
|
|
1209
1420
|
seed: typeof seedCall;
|
|
1421
|
+
dividends: typeof dividendsCall;
|
|
1422
|
+
splits: typeof splitsCall;
|
|
1423
|
+
earnings: typeof earningsCall;
|
|
1210
1424
|
};
|
|
1211
1425
|
/** PineScript `line.*`; `line.all` lists the live lines in creation order. */
|
|
1212
1426
|
type Numeric = number | Series;
|
|
@@ -1224,7 +1438,7 @@ export interface LabelNewArgs {
|
|
|
1224
1438
|
y?: Numeric;
|
|
1225
1439
|
point?: ChartPoint;
|
|
1226
1440
|
text?: string;
|
|
1227
|
-
xloc?: 'bar_index' | 'bar_time';
|
|
1441
|
+
xloc?: 'bar_index' | 'bar_time' | 'pane';
|
|
1228
1442
|
yloc?: 'price' | 'abovebar' | 'belowbar';
|
|
1229
1443
|
color?: Colour;
|
|
1230
1444
|
style?: NonNullable<Label['style']>;
|
|
@@ -1244,7 +1458,7 @@ export interface LineNewArgs {
|
|
|
1244
1458
|
y2?: Numeric;
|
|
1245
1459
|
first_point?: ChartPoint;
|
|
1246
1460
|
second_point?: ChartPoint;
|
|
1247
|
-
xloc?: 'bar_index' | 'bar_time';
|
|
1461
|
+
xloc?: 'bar_index' | 'bar_time' | 'pane';
|
|
1248
1462
|
extend?: 'none' | 'left' | 'right' | 'both';
|
|
1249
1463
|
color?: Colour;
|
|
1250
1464
|
style?: 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both';
|
|
@@ -1263,7 +1477,7 @@ export interface BoxNewArgs {
|
|
|
1263
1477
|
border_width?: Numeric;
|
|
1264
1478
|
border_style?: 'solid' | 'dotted' | 'dashed';
|
|
1265
1479
|
extend?: 'none' | 'left' | 'right' | 'both';
|
|
1266
|
-
xloc?: 'bar_index' | 'bar_time';
|
|
1480
|
+
xloc?: 'bar_index' | 'bar_time' | 'pane';
|
|
1267
1481
|
bgcolor?: Colour;
|
|
1268
1482
|
text?: string;
|
|
1269
1483
|
text_size?: string | number;
|
|
@@ -1309,7 +1523,7 @@ export interface PolylineNewArgs {
|
|
|
1309
1523
|
points?: ChartPoint[];
|
|
1310
1524
|
curved?: boolean;
|
|
1311
1525
|
closed?: boolean;
|
|
1312
|
-
xloc?: 'bar_index' | 'bar_time';
|
|
1526
|
+
xloc?: 'bar_index' | 'bar_time' | 'pane';
|
|
1313
1527
|
line_color?: Colour;
|
|
1314
1528
|
fill_color?: Colour | null;
|
|
1315
1529
|
line_style?: 'solid' | 'dotted' | 'dashed';
|
|
@@ -1329,8 +1543,8 @@ declare const lineNs: Omit<ScriptDrawing<{
|
|
|
1329
1543
|
style_arrow_left: "arrow_left";
|
|
1330
1544
|
style_arrow_right: "arrow_right";
|
|
1331
1545
|
style_arrow_both: "arrow_both";
|
|
1332
|
-
new_line(first_point: ChartPoint, second_point: ChartPoint, xloc?: "bar_index" | "bar_time", extend?: "none" | "left" | "right" | "both", lineColor?: import("../types/index.js").color, style?: "solid" | "dotted" | "dashed" | "arrow_left" | "arrow_right" | "arrow_both", width?: number, force_overlay?: boolean): Line;
|
|
1333
|
-
new_line(x1: number, y1: number, x2: number, y2: number, xloc?: "bar_index" | "bar_time", extend?: "none" | "left" | "right" | "both", lineColor?: import("../types/index.js").color, style?: "solid" | "dotted" | "dashed" | "arrow_left" | "arrow_right" | "arrow_both", width?: number, force_overlay?: boolean): Line;
|
|
1546
|
+
new_line(first_point: ChartPoint, second_point: ChartPoint, xloc?: "bar_index" | "bar_time" | "pane", extend?: "none" | "left" | "right" | "both", lineColor?: import("../types/index.js").color, style?: "solid" | "dotted" | "dashed" | "arrow_left" | "arrow_right" | "arrow_both", width?: number, force_overlay?: boolean): Line;
|
|
1547
|
+
new_line(x1: number, y1: number, x2: number, y2: number, xloc?: "bar_index" | "bar_time" | "pane", extend?: "none" | "left" | "right" | "both", lineColor?: import("../types/index.js").color, style?: "solid" | "dotted" | "dashed" | "arrow_left" | "arrow_right" | "arrow_both", width?: number, force_overlay?: boolean): Line;
|
|
1334
1548
|
get_price(id: Line, x: number): number;
|
|
1335
1549
|
get_x1(id: Line): number;
|
|
1336
1550
|
get_x2(id: Line): number;
|
|
@@ -1343,7 +1557,7 @@ declare const lineNs: Omit<ScriptDrawing<{
|
|
|
1343
1557
|
set_y2(id: Line, y: number): Line;
|
|
1344
1558
|
set_xy1(id: Line, x: number, y: number): Line;
|
|
1345
1559
|
set_xy2(id: Line, x: number, y: number): Line;
|
|
1346
|
-
set_xloc(id: Line, x1: number, x2: number, xloc: "bar_index" | "bar_time"): Line;
|
|
1560
|
+
set_xloc(id: Line, x1: number, x2: number, xloc: "bar_index" | "bar_time" | "pane"): Line;
|
|
1347
1561
|
set_extend(id: Line, extend: "none" | "left" | "right" | "both"): Line;
|
|
1348
1562
|
set_color(id: Line, lineColor: import("../types/index.js").color): Line;
|
|
1349
1563
|
set_style(id: Line, style: "solid" | "dotted" | "dashed" | "arrow_left" | "arrow_right" | "arrow_both"): Line;
|
|
@@ -1383,8 +1597,8 @@ declare const labelNs: Omit<ScriptDrawing<{
|
|
|
1383
1597
|
style_square: "square";
|
|
1384
1598
|
style_diamond: "diamond";
|
|
1385
1599
|
style_text_outline: "text_outline";
|
|
1386
|
-
new_label(point: ChartPoint, text?: string, xloc?: "bar_index" | "bar_time", yloc?: "price" | "abovebar" | "belowbar", labelColor?: import("../types/index.js").color, style?: "none" | "xcross" | "cross" | "triangleup" | "triangledown" | "flag" | "circle" | "arrowup" | "arrowdown" | "label_up" | "label_down" | "label_left" | "label_right" | "label_lower_left" | "label_lower_right" | "label_upper_left" | "label_upper_right" | "label_center" | "square" | "diamond" | "text_outline", textcolor?: import("../types/index.js").color, size?: string | number, textalign?: "left" | "center" | "right", tooltip?: string, text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Label;
|
|
1387
|
-
new_label(x: number, y: number, text?: string, xloc?: "bar_index" | "bar_time", yloc?: "price" | "abovebar" | "belowbar", labelColor?: import("../types/index.js").color, style?: "none" | "xcross" | "cross" | "triangleup" | "triangledown" | "flag" | "circle" | "arrowup" | "arrowdown" | "label_up" | "label_down" | "label_left" | "label_right" | "label_lower_left" | "label_lower_right" | "label_upper_left" | "label_upper_right" | "label_center" | "square" | "diamond" | "text_outline", textcolor?: import("../types/index.js").color, size?: string | number, textalign?: "left" | "center" | "right", tooltip?: string, text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Label;
|
|
1600
|
+
new_label(point: ChartPoint, text?: string, xloc?: "bar_index" | "bar_time" | "pane", yloc?: "price" | "abovebar" | "belowbar", labelColor?: import("../types/index.js").color, style?: "none" | "xcross" | "cross" | "triangleup" | "triangledown" | "flag" | "circle" | "arrowup" | "arrowdown" | "label_up" | "label_down" | "label_left" | "label_right" | "label_lower_left" | "label_lower_right" | "label_upper_left" | "label_upper_right" | "label_center" | "square" | "diamond" | "text_outline", textcolor?: import("../types/index.js").color, size?: string | number, textalign?: "left" | "center" | "right", tooltip?: string, text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Label;
|
|
1601
|
+
new_label(x: number, y: number, text?: string, xloc?: "bar_index" | "bar_time" | "pane", yloc?: "price" | "abovebar" | "belowbar", labelColor?: import("../types/index.js").color, style?: "none" | "xcross" | "cross" | "triangleup" | "triangledown" | "flag" | "circle" | "arrowup" | "arrowdown" | "label_up" | "label_down" | "label_left" | "label_right" | "label_lower_left" | "label_lower_right" | "label_upper_left" | "label_upper_right" | "label_center" | "square" | "diamond" | "text_outline", textcolor?: import("../types/index.js").color, size?: string | number, textalign?: "left" | "center" | "right", tooltip?: string, text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Label;
|
|
1388
1602
|
get_x(id: Label): number;
|
|
1389
1603
|
get_y(id: Label): number;
|
|
1390
1604
|
get_text(id: Label): string | undefined;
|
|
@@ -1392,7 +1606,7 @@ declare const labelNs: Omit<ScriptDrawing<{
|
|
|
1392
1606
|
set_x(id: Label, x: number): Label;
|
|
1393
1607
|
set_y(id: Label, y: number): Label;
|
|
1394
1608
|
set_xy(id: Label, x: number, y: number): Label;
|
|
1395
|
-
set_xloc(id: Label, x: number, xloc: "bar_index" | "bar_time"): Label;
|
|
1609
|
+
set_xloc(id: Label, x: number, xloc: "bar_index" | "bar_time" | "pane"): Label;
|
|
1396
1610
|
set_yloc(id: Label, yloc: "price" | "abovebar" | "belowbar"): Label;
|
|
1397
1611
|
set_text(id: Label, text: string): Label;
|
|
1398
1612
|
set_tooltip(id: Label, tooltip: string): Label;
|
|
@@ -1416,8 +1630,8 @@ export declare const label: typeof labelNs & {
|
|
|
1416
1630
|
new: ((args: LabelNewArgs) => Label) & ((x: Numeric, y: Numeric, args: LabelNewArgs) => Label) & ((x: Numeric, y: Numeric, text: string, args: LabelNewArgs) => Label) & ((point: ChartPoint, args: LabelNewArgs) => Label) & ((point: ChartPoint, text: string, args: LabelNewArgs) => Label);
|
|
1417
1631
|
};
|
|
1418
1632
|
declare const boxNs: Omit<ScriptDrawing<{
|
|
1419
|
-
new_box(top_left: ChartPoint, bottom_right: ChartPoint, border_color?: import("../types/index.js").color, border_width?: number, border_style?: "solid" | "dotted" | "dashed", extend?: "none" | "left" | "right" | "both", xloc?: "bar_index" | "bar_time", bgcolor?: import("../types/index.js").color, text?: string, text_size?: string | number, text_color?: import("../types/index.js").color, text_halign?: "left" | "center" | "right", text_valign?: "top" | "center" | "bottom", text_wrap?: "none" | "auto", text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Box;
|
|
1420
|
-
new_box(left: number, top: number, right: number, bottom: number, border_color?: import("../types/index.js").color, border_width?: number, border_style?: "solid" | "dotted" | "dashed", extend?: "none" | "left" | "right" | "both", xloc?: "bar_index" | "bar_time", bgcolor?: import("../types/index.js").color, text?: string, text_size?: string | number, text_color?: import("../types/index.js").color, text_halign?: "left" | "center" | "right", text_valign?: "top" | "center" | "bottom", text_wrap?: "none" | "auto", text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Box;
|
|
1633
|
+
new_box(top_left: ChartPoint, bottom_right: ChartPoint, border_color?: import("../types/index.js").color, border_width?: number, border_style?: "solid" | "dotted" | "dashed", extend?: "none" | "left" | "right" | "both", xloc?: "bar_index" | "bar_time" | "pane", bgcolor?: import("../types/index.js").color, text?: string, text_size?: string | number, text_color?: import("../types/index.js").color, text_halign?: "left" | "center" | "right", text_valign?: "top" | "center" | "bottom", text_wrap?: "none" | "auto", text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Box;
|
|
1634
|
+
new_box(left: number, top: number, right: number, bottom: number, border_color?: import("../types/index.js").color, border_width?: number, border_style?: "solid" | "dotted" | "dashed", extend?: "none" | "left" | "right" | "both", xloc?: "bar_index" | "bar_time" | "pane", bgcolor?: import("../types/index.js").color, text?: string, text_size?: string | number, text_color?: import("../types/index.js").color, text_halign?: "left" | "center" | "right", text_valign?: "top" | "center" | "bottom", text_wrap?: "none" | "auto", text_font_family?: "default" | "monospace", force_overlay?: boolean, text_formatting?: number): Box;
|
|
1421
1635
|
get_left(id: Box): number;
|
|
1422
1636
|
get_right(id: Box): number;
|
|
1423
1637
|
get_top(id: Box): number;
|
|
@@ -1429,7 +1643,7 @@ declare const boxNs: Omit<ScriptDrawing<{
|
|
|
1429
1643
|
set_bottom(id: Box, bottom: number): Box;
|
|
1430
1644
|
set_lefttop(id: Box, left: number, top: number): Box;
|
|
1431
1645
|
set_rightbottom(id: Box, right: number, bottom: number): Box;
|
|
1432
|
-
set_xloc(id: Box, left: number, right: number, xloc: "bar_index" | "bar_time"): Box;
|
|
1646
|
+
set_xloc(id: Box, left: number, right: number, xloc: "bar_index" | "bar_time" | "pane"): Box;
|
|
1433
1647
|
set_extend(id: Box, extend: "none" | "left" | "right" | "both"): Box;
|
|
1434
1648
|
set_border_color(id: Box, borderColor: import("../types/index.js").color): Box;
|
|
1435
1649
|
set_border_width(id: Box, width: number): Box;
|
|
@@ -1473,7 +1687,7 @@ export declare const linefill: typeof linefillNs & {
|
|
|
1473
1687
|
new: ((args: LinefillNewArgs) => Linefill) & ((line1: Line, line2: Line, args: LinefillNewArgs) => Linefill);
|
|
1474
1688
|
};
|
|
1475
1689
|
declare const polylineNs: Omit<ScriptDrawing<{
|
|
1476
|
-
new_polyline(points: ChartPoint[], curved?: boolean, closed?: boolean, xloc?: "bar_index" | "bar_time", line_color?: import("../types/index.js").color, fill_color?: import("../types/index.js").color | null, line_style?: "solid" | "dotted" | "dashed", line_width?: number, force_overlay?: boolean): Polyline;
|
|
1690
|
+
new_polyline(points: ChartPoint[], curved?: boolean, closed?: boolean, xloc?: "bar_index" | "bar_time" | "pane", line_color?: import("../types/index.js").color, fill_color?: import("../types/index.js").color | null, line_style?: "solid" | "dotted" | "dashed", line_width?: number, force_overlay?: boolean): Polyline;
|
|
1477
1691
|
delete_polyline(id: Polyline): void;
|
|
1478
1692
|
get_all(): readonly Polyline[];
|
|
1479
1693
|
all(): Polyline[];
|
|
@@ -1570,6 +1784,7 @@ export declare const shape: {
|
|
|
1570
1784
|
}, xloc: {
|
|
1571
1785
|
readonly bar_index: "bar_index";
|
|
1572
1786
|
readonly bar_time: "bar_time";
|
|
1787
|
+
readonly pane: "pane";
|
|
1573
1788
|
}, yloc: {
|
|
1574
1789
|
readonly price: "price";
|
|
1575
1790
|
readonly abovebar: "abovebar";
|
|
@@ -1673,6 +1888,20 @@ export declare const chart: {
|
|
|
1673
1888
|
readonly fg_color: string;
|
|
1674
1889
|
/** Chart background colour (PineScript `chart.bg_color`), from the chart context. */
|
|
1675
1890
|
readonly bg_color: string;
|
|
1891
|
+
/** Time (ms) of the first bar in view (PineScript `chart.left_visible_bar_time`), from the chart context; without it,
|
|
1892
|
+
* of the first bar. */
|
|
1893
|
+
readonly left_visible_bar_time: number;
|
|
1894
|
+
/** Time (ms) of the last bar in view (PineScript `chart.right_visible_bar_time`), from the chart context; without it,
|
|
1895
|
+
* of the last bar. */
|
|
1896
|
+
readonly right_visible_bar_time: number;
|
|
1897
|
+
/** The chart is not one of the types below (PineScript `chart.is_standard`). */
|
|
1898
|
+
readonly is_standard: boolean;
|
|
1899
|
+
readonly is_heikinashi: boolean;
|
|
1900
|
+
readonly is_renko: boolean;
|
|
1901
|
+
readonly is_kagi: boolean;
|
|
1902
|
+
readonly is_linebreak: boolean;
|
|
1903
|
+
readonly is_pnf: boolean;
|
|
1904
|
+
readonly is_range: boolean;
|
|
1676
1905
|
point: {
|
|
1677
1906
|
now(price?: number): ChartPoint;
|
|
1678
1907
|
new_point(time: number | null, index: number | null, price: number): ChartPoint;
|
|
@@ -1779,9 +2008,7 @@ export declare const math: {
|
|
|
1779
2008
|
toradians(degrees: import("../index.js").float): import("../index.js").float;
|
|
1780
2009
|
todegrees(radians: Series): Series;
|
|
1781
2010
|
todegrees(radians: import("../index.js").float): import("../index.js").float;
|
|
1782
|
-
seededRandom(seed: import("../index.js").int): (min?: import("../index.js").float, max
|
|
1783
|
-
/** The first `count` bars of `b` have the values of `copy`. */
|
|
1784
|
-
?: import("../index.js").float) => import("../index.js").float;
|
|
2011
|
+
seededRandom(seed: import("../index.js").int): (min?: import("../index.js").float, max?: import("../index.js").float) => import("../index.js").float;
|
|
1785
2012
|
resetRandom(): void;
|
|
1786
2013
|
sign(value: Series): Series;
|
|
1787
2014
|
sign(value: import("../index.js").float): import("../index.js").int;
|