@christtrade/depth 0.14.1 → 0.15.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/depth.cjs +90 -56
- package/depth.css +1 -1
- package/depth.mjs +90 -56
- package/depth.nopreflight.css +1 -1
- package/package.json +1 -1
- package/types/console/Console.d.ts +190 -0
- package/types/console/builtins/cfgedit.d.ts +2 -0
- package/types/console/builtins/editor.d.ts +9 -0
- package/types/console/builtins/js.d.ts +9 -0
- package/types/console/builtins/pipes.d.ts +2 -0
- package/types/console/builtins/plot.d.ts +9 -0
- package/types/console/builtins/scripts.d.ts +2 -0
- package/types/console/builtins/watch.d.ts +2 -0
- package/types/console/chart-host.d.ts +3 -0
- package/types/console/lex.d.ts +16 -0
- package/types/console/manifest.gen.d.ts +3 -0
- package/types/console/plugin-console.d.ts +24 -0
- package/types/console/tools/book.d.ts +3 -0
- package/types/console/tools/free.d.ts +3 -0
- package/types/console/tools/look.d.ts +3 -0
- package/types/console/tools/market.d.ts +6 -0
- package/types/console/tools/net.d.ts +14 -0
- package/types/console/tools/netgraph.d.ts +3 -0
- package/types/console/tools/profile.d.ts +3 -0
- package/types/console/tools/tape.d.ts +3 -0
- package/types/console/tools/top.d.ts +10 -0
- package/types/console/tools/trace.d.ts +3 -0
- package/types/console/tools/triggers.d.ts +3 -0
- package/types/console/tools/tui.d.ts +13 -0
- package/types/console/types.d.ts +62 -0
- package/types/console/values.d.ts +46 -0
- package/types/core/DepthChart.d.ts +12 -0
- package/types/core/ExecutionEngine.d.ts +6 -1
- package/types/core/RenderEngine.d.ts +13 -0
- package/types/core/ScriptedPlugin.d.ts +10 -0
- package/types/core/TypedEventBus.d.ts +9 -0
- package/types/core/index.d.ts +5 -1
- package/types/interfaces/plugins/IChartPlugin.d.ts +10 -0
- package/types/lib/matchingEngine.d.ts +14 -0
- package/types/lib/storage.d.ts +2 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { ChartEvents } from '../core/TypedEventBus';
|
|
2
|
+
import { type ChartSettings } from '../lib/types/chart-settings';
|
|
3
|
+
import type { ArgSpec, ArgType } from './types';
|
|
4
|
+
import { type TypeParser } from './values';
|
|
5
|
+
/** What the console needs from a chart. `chart.console` wires this up for you */
|
|
6
|
+
export interface ConsoleHost {
|
|
7
|
+
on<K extends keyof ChartEvents>(event: K, fn: (data: ChartEvents[K]) => void): () => void;
|
|
8
|
+
emit<K extends keyof ChartEvents>(event: K, data: ChartEvents[K]): void;
|
|
9
|
+
settings(): Readonly<ChartSettings>;
|
|
10
|
+
focusedCell(): number;
|
|
11
|
+
playheadNs(): bigint;
|
|
12
|
+
status(): Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface ConsoleStorage {
|
|
15
|
+
read<T>(key: string, fallback: T): T;
|
|
16
|
+
write(key: string, value: unknown): void;
|
|
17
|
+
}
|
|
18
|
+
export type ScreenKey = {
|
|
19
|
+
type: 'down' | 'up';
|
|
20
|
+
key: string;
|
|
21
|
+
code: string;
|
|
22
|
+
ctrl: boolean;
|
|
23
|
+
alt: boolean;
|
|
24
|
+
shift: boolean;
|
|
25
|
+
meta: boolean;
|
|
26
|
+
repeat: boolean;
|
|
27
|
+
};
|
|
28
|
+
export interface ScreenOptions {
|
|
29
|
+
/** Cover the whole page instead of just the terminal panel */
|
|
30
|
+
maximize?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface Screen {
|
|
33
|
+
readonly cols: number;
|
|
34
|
+
readonly rows: number;
|
|
35
|
+
/** Pixel size of one cell. */
|
|
36
|
+
readonly cell: {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
};
|
|
40
|
+
/** Resolves once the terminal has drawn it */
|
|
41
|
+
write(data: string): Promise<void>;
|
|
42
|
+
/** Typed text as terminal sequences (arrows arrive as \x1b[A ...) */
|
|
43
|
+
onData(fn: (data: string) => void): () => void;
|
|
44
|
+
onKey(fn: (key: ScreenKey) => void): () => void;
|
|
45
|
+
onResize(fn: (cols: number, rows: number) => void): () => void;
|
|
46
|
+
/** Aborted when the screen closes */
|
|
47
|
+
readonly closed: AbortSignal;
|
|
48
|
+
close(): void;
|
|
49
|
+
}
|
|
50
|
+
/** What a terminal ui gives the console so commands can draw full screen */
|
|
51
|
+
export interface ConsoleDisplay {
|
|
52
|
+
readonly cols: number;
|
|
53
|
+
openScreen(opts: ScreenOptions): Screen;
|
|
54
|
+
}
|
|
55
|
+
export interface CommandContext {
|
|
56
|
+
/** Parsed against the command's `args`. Empty when it declares none. */
|
|
57
|
+
args: Record<string, unknown>;
|
|
58
|
+
/** Raw words after the command name. */
|
|
59
|
+
argv: string[];
|
|
60
|
+
/** The text after the command name. */
|
|
61
|
+
raw: string;
|
|
62
|
+
/** Lines from the command before a `|`, or null when nothing was piped in. */
|
|
63
|
+
input: string[] | null;
|
|
64
|
+
print(text: string): void;
|
|
65
|
+
error(text: string): void;
|
|
66
|
+
signal: AbortSignal;
|
|
67
|
+
console: Console;
|
|
68
|
+
/** Take over the terminal. */
|
|
69
|
+
screen(opts?: ScreenOptions): Screen;
|
|
70
|
+
}
|
|
71
|
+
export interface CommandDef {
|
|
72
|
+
name: string;
|
|
73
|
+
help?: string;
|
|
74
|
+
/** Declared args are parsed, checked, and tab completed. */
|
|
75
|
+
args?: ArgSpec[];
|
|
76
|
+
/** Hidden and refused unless `developer 1`. */
|
|
77
|
+
dev?: boolean;
|
|
78
|
+
/** Runs, but never listed, completed or found */
|
|
79
|
+
hidden?: boolean;
|
|
80
|
+
/** Takes the rest of the line as-is, `;` included for commands whose input is code. */
|
|
81
|
+
rest?: boolean;
|
|
82
|
+
run(ctx: CommandContext): void | Promise<void>;
|
|
83
|
+
/** `argv` is the words before the one being completed, `current` that word so far. */
|
|
84
|
+
complete?(argIndex: number, argv: string[], current: string): string[];
|
|
85
|
+
}
|
|
86
|
+
export interface CvarDef {
|
|
87
|
+
name: string;
|
|
88
|
+
type: ArgType;
|
|
89
|
+
nullable?: boolean;
|
|
90
|
+
help?: string;
|
|
91
|
+
group?: string;
|
|
92
|
+
dev?: boolean;
|
|
93
|
+
default: unknown;
|
|
94
|
+
get(): unknown;
|
|
95
|
+
set(value: unknown): void;
|
|
96
|
+
}
|
|
97
|
+
export declare function keyName(e: {
|
|
98
|
+
key: string;
|
|
99
|
+
ctrlKey?: boolean;
|
|
100
|
+
altKey?: boolean;
|
|
101
|
+
shiftKey?: boolean;
|
|
102
|
+
metaKey?: boolean;
|
|
103
|
+
}): string;
|
|
104
|
+
/**
|
|
105
|
+
* A console over the chart. Every command in `ChartEvents`
|
|
106
|
+
* and every field of `ChartSettings` is available without registering it;
|
|
107
|
+
* plugins and hosts add their own with `register` / `registerCvar`.
|
|
108
|
+
*/
|
|
109
|
+
export declare class Console {
|
|
110
|
+
private readonly host;
|
|
111
|
+
private readonly storage;
|
|
112
|
+
private readonly commands;
|
|
113
|
+
private readonly cvars;
|
|
114
|
+
private readonly types;
|
|
115
|
+
private readonly outputs;
|
|
116
|
+
private readonly clears;
|
|
117
|
+
private readonly listening;
|
|
118
|
+
private readonly listenPatterns;
|
|
119
|
+
private readonly rates;
|
|
120
|
+
private abortCtl;
|
|
121
|
+
private display;
|
|
122
|
+
private screenOpen;
|
|
123
|
+
private readonly builtins;
|
|
124
|
+
private readonly state;
|
|
125
|
+
readonly history: string[];
|
|
126
|
+
constructor(host: ConsoleHost, storage?: ConsoleStorage);
|
|
127
|
+
register(def: CommandDef): () => void;
|
|
128
|
+
registerCvar(def: CvarDef): () => void;
|
|
129
|
+
registerSavedCvar(def: Omit<CvarDef, 'get' | 'set'> & {
|
|
130
|
+
onChange?: (value: unknown) => void;
|
|
131
|
+
}): () => void;
|
|
132
|
+
/** teach the console to read a named type from text, so like `Timeframe` from "5m" */
|
|
133
|
+
registerType(name: string, parser: TypeParser): () => void;
|
|
134
|
+
/** The terminal's width, default 100 */
|
|
135
|
+
get cols(): number;
|
|
136
|
+
/** Attach the terminal that full-screen commands draw on. Returns a detach. */
|
|
137
|
+
setDisplay(display: ConsoleDisplay): () => void;
|
|
138
|
+
private openScreen;
|
|
139
|
+
onOutput(fn: (text: string) => void): () => void;
|
|
140
|
+
onClear(fn: () => void): () => void;
|
|
141
|
+
print(text: string): void;
|
|
142
|
+
private readonly captures;
|
|
143
|
+
/** Run a line and hand back what it printed instead of printing it. */
|
|
144
|
+
capture(line: string, signal?: AbortSignal): Promise<string[]>;
|
|
145
|
+
/** Extra names `js` can see. Hosts add their own. */
|
|
146
|
+
readonly scope: Record<string, unknown>;
|
|
147
|
+
scriptNames(): string[];
|
|
148
|
+
script(name: string): string | undefined;
|
|
149
|
+
/** Save a `js` script, or delete it with null. */
|
|
150
|
+
setScript(name: string, source: string | null): void;
|
|
151
|
+
cfgNames(): string[];
|
|
152
|
+
cfg(name: string): string | undefined;
|
|
153
|
+
/** Save a cfg, or delete it with null. */
|
|
154
|
+
setCfg(name: string, text: string | null): void;
|
|
155
|
+
error(text: string): void;
|
|
156
|
+
get developer(): boolean;
|
|
157
|
+
submit(line: string): Promise<void>;
|
|
158
|
+
exec(line: string, depth?: number, signal?: AbortSignal): Promise<void>;
|
|
159
|
+
private isRest;
|
|
160
|
+
private captured;
|
|
161
|
+
abort(): void;
|
|
162
|
+
handleKey(key: string): boolean;
|
|
163
|
+
dispose(): void;
|
|
164
|
+
start(): Promise<void>;
|
|
165
|
+
private run;
|
|
166
|
+
private listed;
|
|
167
|
+
private resolveCommand;
|
|
168
|
+
private env;
|
|
169
|
+
private timezone;
|
|
170
|
+
private parseArgs;
|
|
171
|
+
private usage;
|
|
172
|
+
private eventCommand;
|
|
173
|
+
private showCvar;
|
|
174
|
+
private findCvar;
|
|
175
|
+
private listen;
|
|
176
|
+
private unlisten;
|
|
177
|
+
private onListened;
|
|
178
|
+
private save;
|
|
179
|
+
private settingsDiff;
|
|
180
|
+
suggest(line: string): string | null;
|
|
181
|
+
highlight(line: string): string;
|
|
182
|
+
complete(line: string): {
|
|
183
|
+
from: number;
|
|
184
|
+
items: string[];
|
|
185
|
+
};
|
|
186
|
+
private names;
|
|
187
|
+
private completeArg;
|
|
188
|
+
private completeNamedArg;
|
|
189
|
+
private registerBuiltins;
|
|
190
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandContext } from '../Console';
|
|
2
|
+
export declare function editText(ctx: CommandContext, opts: {
|
|
3
|
+
title: string;
|
|
4
|
+
name: string;
|
|
5
|
+
text: string | undefined;
|
|
6
|
+
highlight: (line: string) => string;
|
|
7
|
+
save: (text: string) => void;
|
|
8
|
+
fresh: string;
|
|
9
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandDef, Console } from '../Console';
|
|
2
|
+
export declare function jsScope(con: Console, print: (t: string) => void, extra?: Record<string, unknown>): Record<string, unknown>;
|
|
3
|
+
export declare function evaluate(con: Console, raw: string, print: (t: string) => void, extra?: Record<string, unknown>): Promise<{
|
|
4
|
+
value: unknown;
|
|
5
|
+
shown: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const describeError: (err: unknown) => string;
|
|
8
|
+
export declare function completePath(con: Console, current: string): string[];
|
|
9
|
+
export declare function jsCommand(con: Console): CommandDef;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandDef, Console } from '../Console';
|
|
2
|
+
type Series = {
|
|
3
|
+
name: string;
|
|
4
|
+
values: number[];
|
|
5
|
+
};
|
|
6
|
+
export declare function toSeries(v: unknown): Series[];
|
|
7
|
+
export declare function plotLines(series: Series[], cols: number, rows: number): string[];
|
|
8
|
+
export declare function plotCommand(con: Console): CommandDef;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Token = {
|
|
2
|
+
text: string;
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
quoted: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function splitStatements(line: string): {
|
|
8
|
+
text: string;
|
|
9
|
+
start: number;
|
|
10
|
+
}[];
|
|
11
|
+
export declare function splitPipes(stmt: string): {
|
|
12
|
+
text: string;
|
|
13
|
+
start: number;
|
|
14
|
+
}[];
|
|
15
|
+
export declare function tokenize(stmt: string): Token[];
|
|
16
|
+
export declare function quote(s: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ArgSpec } from './types';
|
|
2
|
+
import type { CvarDef } from './Console';
|
|
3
|
+
export type ScriptCommandMeta = {
|
|
4
|
+
name: string;
|
|
5
|
+
help?: string;
|
|
6
|
+
args: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
export declare function slugOf(name: string): string;
|
|
9
|
+
export declare function scriptArgSpecs(args: Record<string, unknown>): ArgSpec[];
|
|
10
|
+
type ParamDefLike = {
|
|
11
|
+
type: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
options?: unknown[];
|
|
14
|
+
} & Record<string, unknown>;
|
|
15
|
+
export declare function paramCvars(opts: {
|
|
16
|
+
slug: string;
|
|
17
|
+
paramDefs: Record<string, ParamDefLike>;
|
|
18
|
+
defaults: Record<string, unknown>;
|
|
19
|
+
keysOf: (key: string, def: ParamDefLike) => string[];
|
|
20
|
+
get: (key: string) => unknown;
|
|
21
|
+
set: (key: string, value: unknown) => void;
|
|
22
|
+
group: string;
|
|
23
|
+
}): CvarDef[];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SymbolInfo } from '../../interfaces/IDataAdapter';
|
|
2
|
+
export declare function upperBound(rows: readonly {
|
|
3
|
+
ts: bigint;
|
|
4
|
+
}[], ts: bigint): number;
|
|
5
|
+
export declare function tickOf(info: SymbolInfo | null, prices: number[]): number;
|
|
6
|
+
export declare function decimalsOf(tick: number): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandDef } from '../Console';
|
|
2
|
+
type Req = PerformanceResourceTiming & {
|
|
3
|
+
responseStatus?: number;
|
|
4
|
+
deliveryType?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function netRecorder(): {
|
|
7
|
+
requests: Req[];
|
|
8
|
+
clear(): void;
|
|
9
|
+
};
|
|
10
|
+
export declare function netCommand(rec: {
|
|
11
|
+
requests: Req[];
|
|
12
|
+
clear(): void;
|
|
13
|
+
}): CommandDef;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DepthChart } from '../../core/DepthChart';
|
|
2
|
+
import type { CommandDef } from '../Console';
|
|
3
|
+
type Heap = {
|
|
4
|
+
usedJSHeapSize: number;
|
|
5
|
+
totalJSHeapSize: number;
|
|
6
|
+
jsHeapSizeLimit: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const heapInfo: () => Heap | null;
|
|
9
|
+
export declare function topCommand(chart: DepthChart): CommandDef;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Screen } from '../Console';
|
|
2
|
+
export declare const visible: (s: string) => number;
|
|
3
|
+
export declare function padEnd(s: string, w: number): string;
|
|
4
|
+
export declare function padStart(s: string, w: number): string;
|
|
5
|
+
export declare function clip(s: string, w: number): string;
|
|
6
|
+
export declare function bar(frac: number, width: number, color?: (s: string) => string): string;
|
|
7
|
+
export declare function barLeft(frac: number, width: number, color: (s: string) => string): string;
|
|
8
|
+
export declare function bytes(n: number): string;
|
|
9
|
+
export declare const ms: (n: number) => string;
|
|
10
|
+
export declare const count: (n: number) => string;
|
|
11
|
+
export declare function heat(value: number, warn: number, bad: number): (s: string) => string;
|
|
12
|
+
export declare const sleep: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
13
|
+
export declare function liveScreen(screen: Screen, interval: number, render: () => string[], onRedraw?: (redraw: () => void) => void): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ChartEvents } from '../core/TypedEventBus';
|
|
2
|
+
import type { ChartSettings } from '../lib/types/chart-settings';
|
|
3
|
+
export type ArgType = {
|
|
4
|
+
kind: 'string';
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'number';
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'boolean';
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'bigint';
|
|
11
|
+
}
|
|
12
|
+
/** A moment as epoch ns ("now"/"-1h"/"2024-01-05T09:30"/epoch s/ms/ns) */
|
|
13
|
+
| {
|
|
14
|
+
kind: 'time';
|
|
15
|
+
}
|
|
16
|
+
/** A length in ns ("1h30m"/"250ms") */
|
|
17
|
+
| {
|
|
18
|
+
kind: 'duration';
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'color';
|
|
21
|
+
}
|
|
22
|
+
/** `open` when the union also takes any string (ex plugin chart type ids) */
|
|
23
|
+
| {
|
|
24
|
+
kind: 'enum';
|
|
25
|
+
values: string[];
|
|
26
|
+
open?: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'list';
|
|
29
|
+
of: ArgType;
|
|
30
|
+
}
|
|
31
|
+
/** a named type the console needs a parser for so like `Timeframe` from "5m" */
|
|
32
|
+
| {
|
|
33
|
+
kind: 'named';
|
|
34
|
+
name: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'json';
|
|
37
|
+
};
|
|
38
|
+
export type ArgSpec = {
|
|
39
|
+
name: string;
|
|
40
|
+
type: ArgType;
|
|
41
|
+
optional?: boolean;
|
|
42
|
+
nullable?: boolean;
|
|
43
|
+
doc?: string;
|
|
44
|
+
};
|
|
45
|
+
export type EventSpec = {
|
|
46
|
+
event: keyof ChartEvents;
|
|
47
|
+
/** command can be run, event can only be listened to */
|
|
48
|
+
kind: 'command' | 'event';
|
|
49
|
+
/** Plumbing, hidden unless dev mode is on */
|
|
50
|
+
dev?: boolean;
|
|
51
|
+
/** obj payloads spread into named args, anything else is just a single `value` arg */
|
|
52
|
+
spread?: boolean;
|
|
53
|
+
args: ArgSpec[];
|
|
54
|
+
doc?: string;
|
|
55
|
+
};
|
|
56
|
+
export type CvarSpec = {
|
|
57
|
+
name: keyof ChartSettings;
|
|
58
|
+
type: ArgType;
|
|
59
|
+
nullable?: boolean;
|
|
60
|
+
group?: string;
|
|
61
|
+
doc?: string;
|
|
62
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ArgType } from './types';
|
|
2
|
+
export declare const ansi: {
|
|
3
|
+
red: (s: string) => string;
|
|
4
|
+
green: (s: string) => string;
|
|
5
|
+
yellow: (s: string) => string;
|
|
6
|
+
blue: (s: string) => string;
|
|
7
|
+
magenta: (s: string) => string;
|
|
8
|
+
cyan: (s: string) => string;
|
|
9
|
+
dim: (s: string) => string;
|
|
10
|
+
bold: (s: string) => string;
|
|
11
|
+
};
|
|
12
|
+
export declare function stripAnsi(s: string): string;
|
|
13
|
+
export declare function link(text: string, uri: string): string;
|
|
14
|
+
export declare const gotoLink: (text: string, ns: bigint) => string;
|
|
15
|
+
export declare const helpLink: (text: string, name: string) => string;
|
|
16
|
+
export declare const fillLink: (text: string, line: string) => string;
|
|
17
|
+
/** Turns console txt into a value for a named type, ex "5m" into `Timeframe` */
|
|
18
|
+
export interface TypeParser {
|
|
19
|
+
parse(text: string): unknown;
|
|
20
|
+
/** candidates for tab completion */
|
|
21
|
+
complete?(): string[];
|
|
22
|
+
}
|
|
23
|
+
export type ParseEnv = {
|
|
24
|
+
timezone: string;
|
|
25
|
+
playheadNs: () => bigint;
|
|
26
|
+
types: ReadonlyMap<string, TypeParser>;
|
|
27
|
+
};
|
|
28
|
+
export declare function parseDuration(text: string): bigint | null;
|
|
29
|
+
export declare function parseTime(text: string, env: ParseEnv): bigint;
|
|
30
|
+
export declare const isDurationArg: (name: string) => boolean;
|
|
31
|
+
export declare const isTimeArg: (name: string) => boolean;
|
|
32
|
+
export declare function parseValue(raw: string, type: ArgType, opts: {
|
|
33
|
+
nullable?: boolean;
|
|
34
|
+
name?: string;
|
|
35
|
+
}, env: ParseEnv): unknown;
|
|
36
|
+
export declare function completeValue(type: ArgType, env: ParseEnv): string[];
|
|
37
|
+
export declare function typeLabel(type: ArgType): string;
|
|
38
|
+
export type FormatEnv = {
|
|
39
|
+
timezone: string;
|
|
40
|
+
};
|
|
41
|
+
export declare function formatTime(ns: bigint, timezone: string): string;
|
|
42
|
+
export declare function formatDuration(ns: bigint): string;
|
|
43
|
+
export declare function highlightJs(code: string): string;
|
|
44
|
+
export declare function sparkline(values: readonly number[], width?: number): string;
|
|
45
|
+
export declare function inspect(v: unknown, env: FormatEnv, depth?: number): string;
|
|
46
|
+
export declare function formatValue(v: unknown, env: FormatEnv, key?: string, depth?: number): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ChartDataSnapshot } from './DataEngine';
|
|
1
2
|
import type { IDataAdapter, OhlcvBar, SymbolInfo } from '../interfaces/IDataAdapter';
|
|
2
3
|
import type { IExecutionAdapter } from '../interfaces/IExecutionAdapter';
|
|
3
4
|
import type { IAccountAdapter } from '../interfaces/IAccountAdapter';
|
|
@@ -20,6 +21,7 @@ import { AccountManager, LedgerAdjustment, LedgerFill, LedgerOrder, LedgerPositi
|
|
|
20
21
|
import { PlaybackMode, type PrefetchOptions } from '../hooks/usePlaybackEngine';
|
|
21
22
|
import { type ChartPreferences } from '../lib/storage';
|
|
22
23
|
import { type PluginCatalogEntry, type PluginStartupEntry, type PluginStartupRecord } from './plugin-startup';
|
|
24
|
+
import type { Console } from '../console/Console';
|
|
23
25
|
export interface FeaturesOptions {
|
|
24
26
|
contextMenu?: boolean;
|
|
25
27
|
plugins?: boolean | {
|
|
@@ -221,6 +223,10 @@ export declare class DepthChart {
|
|
|
221
223
|
* the candle the chart is actually drawing on the right edge.
|
|
222
224
|
*/
|
|
223
225
|
openBar(): OhlcvBar | null;
|
|
226
|
+
/** What the chart holds for the active symbol - the same snapshot a plugin's `ctx.getData()` returns. */
|
|
227
|
+
getData(): ChartDataSnapshot;
|
|
228
|
+
/** The paint loop, once a pane has mounted one. */
|
|
229
|
+
get renderEngine(): RenderEngine | null;
|
|
224
230
|
getMaxLookbackBars(): number;
|
|
225
231
|
horizon(): number;
|
|
226
232
|
fitToData(): this;
|
|
@@ -332,6 +338,12 @@ export declare class DepthChart {
|
|
|
332
338
|
getProps(): DepthProps;
|
|
333
339
|
on<K extends keyof ChartEvents>(event: K, handler: (data: ChartEvents[K]) => void): () => void;
|
|
334
340
|
off<K extends keyof ChartEvents>(event: K, handler: (data: ChartEvents[K]) => void): void;
|
|
341
|
+
private _console;
|
|
342
|
+
/**
|
|
343
|
+
* The chart's command console. Every bus command and chart setting is
|
|
344
|
+
* already in it. `register` / `registerCvar` add your own
|
|
345
|
+
*/
|
|
346
|
+
get console(): Console;
|
|
335
347
|
use(plugin: ChartPlugin): this;
|
|
336
348
|
/**
|
|
337
349
|
* Apply an installed plugin to the panes. Safe to call before the plugin's
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IExecutionAdapter } from '../interfaces/IExecutionAdapter';
|
|
2
2
|
import type { PlaceOrderRequest, FillSearchOptions, FillAmbiguity } from '../lib/matchingEngine';
|
|
3
|
-
import { L3MatchingEngine } from '../lib/matchingEngine';
|
|
3
|
+
import { L3MatchingEngine, type BookDepth } from '../lib/matchingEngine';
|
|
4
4
|
import type { TypedEventBus } from './TypedEventBus';
|
|
5
5
|
import type { BracketAmendment, Order, Position } from '../lib/types/trading-types';
|
|
6
6
|
import type { MboEvent, PriceHistory } from '../lib/types';
|
|
@@ -49,6 +49,11 @@ export declare class ExecutionEngine {
|
|
|
49
49
|
/** Whether a book can price an order right now. */
|
|
50
50
|
hasPrice(symbol?: string): boolean;
|
|
51
51
|
setCustomAdapter(adapter: IExecutionAdapter | null): void;
|
|
52
|
+
/**
|
|
53
|
+
* The resting book at the horizon, best `levels` prices each side. Null when
|
|
54
|
+
* a custom adapter executes
|
|
55
|
+
*/
|
|
56
|
+
getDepth(levels?: number, symbol?: string): BookDepth | null;
|
|
52
57
|
private builtInFor;
|
|
53
58
|
private targetFor;
|
|
54
59
|
private eachBuiltIn;
|
|
@@ -101,6 +101,19 @@ export declare class RenderEngine {
|
|
|
101
101
|
private readonly eventBus;
|
|
102
102
|
private readonly chartId;
|
|
103
103
|
private rafId;
|
|
104
|
+
/** The element the canvases sit in, for overlays that want to draw over the chart without touching it */
|
|
105
|
+
get container(): HTMLElement | null;
|
|
106
|
+
get plotSize(): {
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
};
|
|
110
|
+
/** Frames that painted something n what they cost. Read by the consoles `top` */
|
|
111
|
+
readonly paintStats: {
|
|
112
|
+
frames: number;
|
|
113
|
+
totalMs: number;
|
|
114
|
+
lastMs: number;
|
|
115
|
+
maxMs: number;
|
|
116
|
+
};
|
|
104
117
|
private dirty;
|
|
105
118
|
private beforeBaseDraw;
|
|
106
119
|
private afterBaseDraw;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { ChartPlugin } from './PluginRegistry';
|
|
2
|
+
export type ScriptStats = {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
computes: number;
|
|
6
|
+
totalMs: number;
|
|
7
|
+
lastMs: number;
|
|
8
|
+
maxMs: number;
|
|
9
|
+
};
|
|
10
|
+
/** Worker compute time per scripted plugin entry, keyed `${pluginId}:${index}` */
|
|
11
|
+
export declare const scriptStats: Map<string, ScriptStats>;
|
|
2
12
|
import type { StyleField } from '../components/drawings/drawing-settings-dialog';
|
|
3
13
|
export type ParamDef = {
|
|
4
14
|
label: string;
|
|
@@ -490,6 +490,7 @@ export interface ChartEvents {
|
|
|
490
490
|
'plugin:panel-removed': {
|
|
491
491
|
id: string;
|
|
492
492
|
};
|
|
493
|
+
/** @console command */
|
|
493
494
|
'plugin:panel-toggle-visibility': {
|
|
494
495
|
id: string;
|
|
495
496
|
visible: boolean;
|
|
@@ -593,6 +594,7 @@ export interface ChartEvents {
|
|
|
593
594
|
id: string;
|
|
594
595
|
params: Record<string, unknown>;
|
|
595
596
|
};
|
|
597
|
+
/** @console command */
|
|
596
598
|
'plugin:strategy-range': {
|
|
597
599
|
id: string;
|
|
598
600
|
range: {
|
|
@@ -617,6 +619,7 @@ export interface ChartEvents {
|
|
|
617
619
|
/** As on 'plugin:strategy-range' - go get the span, don't clip. */
|
|
618
620
|
fetch?: boolean;
|
|
619
621
|
};
|
|
622
|
+
/** @console command */
|
|
620
623
|
'plugin:strategy-mode': {
|
|
621
624
|
id: string;
|
|
622
625
|
manual: boolean;
|
|
@@ -637,6 +640,7 @@ export interface ChartEvents {
|
|
|
637
640
|
total: number;
|
|
638
641
|
error?: string;
|
|
639
642
|
};
|
|
643
|
+
/** @console command */
|
|
640
644
|
'plugin:strategy-sweep': {
|
|
641
645
|
id: string;
|
|
642
646
|
grid: Array<Record<string, unknown>>;
|
|
@@ -681,6 +685,7 @@ export interface ChartEvents {
|
|
|
681
685
|
iterations: number;
|
|
682
686
|
reason: string;
|
|
683
687
|
};
|
|
688
|
+
/** @console command */
|
|
684
689
|
'plugin:strategy-walkforward': {
|
|
685
690
|
id: string;
|
|
686
691
|
grid: Array<Record<string, unknown>>;
|
|
@@ -883,6 +888,10 @@ export declare class TypedEventBus {
|
|
|
883
888
|
hasListeners<K extends keyof ChartEvents>(event: K): boolean;
|
|
884
889
|
off<K extends keyof ChartEvents>(event: K, handler: Function): void;
|
|
885
890
|
intercept<K extends InterceptableEvent>(event: K, interceptor: Interceptor<K>): () => void;
|
|
891
|
+
/** How many times each event has been emitted. Read by the consoles `top` */
|
|
892
|
+
readonly emitCounts: Map<string, number>;
|
|
893
|
+
private readonly taps;
|
|
894
|
+
tap(fn: (event: keyof ChartEvents, data: unknown) => void): () => void;
|
|
886
895
|
emit<K extends keyof ChartEvents>(event: K, data: ChartEvents[K]): void;
|
|
887
896
|
clear(): void;
|
|
888
897
|
}
|
package/types/core/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { DepthChart } from './DepthChart';
|
|
2
|
+
export { Console, keyName } from '../console/Console';
|
|
3
|
+
export type { ConsoleHost, ConsoleStorage, ConsoleDisplay, CommandDef, CommandContext, CvarDef, Screen, ScreenKey, ScreenOptions, } from '../console/Console';
|
|
4
|
+
export type { ArgSpec, ArgType } from '../console/types';
|
|
5
|
+
export type { TypeParser } from '../console/values';
|
|
2
6
|
export type { ChartOptions } from './DepthChart';
|
|
3
7
|
export { useDepthChart } from '../react/useDepthChart';
|
|
4
8
|
export { default as Depth } from '../ChartOuter';
|
|
@@ -51,7 +55,7 @@ export type { DrawingTool } from '../lib/types/drawing-types';
|
|
|
51
55
|
export type { FootprintBar, FootprintOptions } from '../lib/types/footprint';
|
|
52
56
|
export type { ChartSettings } from '../lib/types/chart-settings';
|
|
53
57
|
export { DEFAULT_CHART_SETTINGS } from '../lib/types/chart-settings';
|
|
54
|
-
export type { PlaceOrderRequest, L3EngineOptions, FeeSchedule } from '../lib/matchingEngine';
|
|
58
|
+
export type { PlaceOrderRequest, L3EngineOptions, FeeSchedule, BookDepth, BookLevel } from '../lib/matchingEngine';
|
|
55
59
|
export { createL3MatchingEngine, feeScheduleFor, MICRO_FEE_SCHEDULE, NQ_FEE_SCHEDULE, ZERO_FEE_SCHEDULE, } from '../lib/matchingEngine';
|
|
56
60
|
export { SimulatedMarketAdapter, createSimulatedAdapter } from '../lib/createSimulatedAdapter';
|
|
57
61
|
export { AccountManager } from './AccountManager';
|