@christtrade/depth 0.14.1 → 0.15.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.
Files changed (46) hide show
  1. package/depth.cjs +90 -56
  2. package/depth.css +1 -1
  3. package/depth.mjs +90 -56
  4. package/depth.nopreflight.css +1 -1
  5. package/package.json +1 -1
  6. package/script-runtime.cjs +2 -2
  7. package/script-runtime.mjs +2 -2
  8. package/types/components/multi-chart/GridDividers.d.ts +3 -2
  9. package/types/components/ui/animated-panel.d.ts +5 -1
  10. package/types/components/ui/scroll-strip.d.ts +6 -0
  11. package/types/console/Console.d.ts +190 -0
  12. package/types/console/builtins/cfgedit.d.ts +2 -0
  13. package/types/console/builtins/editor.d.ts +9 -0
  14. package/types/console/builtins/js.d.ts +9 -0
  15. package/types/console/builtins/pipes.d.ts +2 -0
  16. package/types/console/builtins/plot.d.ts +9 -0
  17. package/types/console/builtins/scripts.d.ts +2 -0
  18. package/types/console/builtins/watch.d.ts +2 -0
  19. package/types/console/chart-host.d.ts +3 -0
  20. package/types/console/lex.d.ts +16 -0
  21. package/types/console/manifest.gen.d.ts +3 -0
  22. package/types/console/plugin-console.d.ts +24 -0
  23. package/types/console/tools/book.d.ts +3 -0
  24. package/types/console/tools/free.d.ts +3 -0
  25. package/types/console/tools/look.d.ts +3 -0
  26. package/types/console/tools/market.d.ts +6 -0
  27. package/types/console/tools/net.d.ts +14 -0
  28. package/types/console/tools/netgraph.d.ts +3 -0
  29. package/types/console/tools/profile.d.ts +3 -0
  30. package/types/console/tools/tape.d.ts +3 -0
  31. package/types/console/tools/top.d.ts +10 -0
  32. package/types/console/tools/trace.d.ts +3 -0
  33. package/types/console/tools/triggers.d.ts +3 -0
  34. package/types/console/tools/tui.d.ts +13 -0
  35. package/types/console/types.d.ts +62 -0
  36. package/types/console/values.d.ts +46 -0
  37. package/types/core/DepthChart.d.ts +12 -0
  38. package/types/core/ExecutionEngine.d.ts +6 -1
  39. package/types/core/RenderEngine.d.ts +13 -0
  40. package/types/core/ScriptedPlugin.d.ts +10 -0
  41. package/types/core/TypedEventBus.d.ts +9 -0
  42. package/types/core/index.d.ts +5 -1
  43. package/types/interfaces/plugins/IChartPlugin.d.ts +10 -0
  44. package/types/lib/indicator-stdlib.d.ts +17 -0
  45. package/types/lib/matchingEngine.d.ts +14 -0
  46. package/types/lib/storage.d.ts +2 -0
@@ -13,6 +13,7 @@ import type { SerialTrade, PriceHistory } from '../../lib/types';
13
13
  import type { FootprintBar } from '../../lib/types/footprint';
14
14
  import type { BracketAmendment } from '../../lib/types/trading-types';
15
15
  import type { PlaceOrderRequest } from '../../lib/matchingEngine';
16
+ import type { CommandDef, CvarDef } from '../../console/Console';
16
17
  export type PluginType = 'indicator' | 'drawing' | 'chart-type' | 'data-source' | 'extension' | 'strategy';
17
18
  export type Permission = 'data:read' | 'data:write' | 'eventbus:emit' | 'eventbus:intercept' | 'ui:pane' | 'ui:panel' | 'ui:toolbar' | 'ui:context-menu' | 'render:overlay' | 'render:shader' | 'drawing:register' | 'chart-type:register' | 'theme:register' | 'audio' | 'network' | 'storage' | 'intercept' | 'execution:read' | 'execution:write';
18
19
  export interface ToolbarItem {
@@ -228,6 +229,15 @@ export interface PluginContext {
228
229
  playback: {
229
230
  registerState(snapshot: PluginStateSnapshot): () => void;
230
231
  };
232
+ /**
233
+ * add cmds and cvarsto the charts console. name them 'yourplugin:thing'
234
+ * so 'thing' alone still finds them. everything registered here goes away when the plugin
235
+ * uninstalls. the returned fn removes one sooner
236
+ */
237
+ console: {
238
+ register(def: CommandDef): () => void;
239
+ registerCvar(def: CvarDef): () => void;
240
+ };
231
241
  }
232
242
  export interface ChartPlugin {
233
243
  readonly id: string;
@@ -224,6 +224,15 @@ export type DrawCommand = {
224
224
  padding?: number;
225
225
  radius?: number;
226
226
  anchored?: boolean;
227
+ } | {
228
+ /** Round-trip trade - entry and exit markers joined by a connector */
229
+ type: 'trade';
230
+ side: 'long' | 'short';
231
+ entryTs: bigint;
232
+ entryPrice: number;
233
+ exitTs: bigint;
234
+ exitPrice: number;
235
+ pnl: number;
227
236
  };
228
237
  /**
229
238
  * drawLine(pts, color, width, dash?, connect?)
@@ -382,6 +391,14 @@ export declare function drawBadge(t: bigint, price: number, text: string, textCo
382
391
  radius?: number;
383
392
  anchored?: boolean;
384
393
  }): DrawCommand;
394
+ /**
395
+ * drawTrade(side, entryTs, entryPrice, exitTs, exitPrice, pnl)
396
+ *
397
+ * Draws a closed trade the way the default strategy view does: an entry arrow
398
+ * coloured by side, an exit arrow and dashed connector coloured by outcome, and
399
+ * a P&L tag once zoomed in far enough to read it.
400
+ */
401
+ export declare function drawTrade(side: 'long' | 'short', entryTs: bigint, entryPrice: number, exitTs: bigint, exitPrice: number, pnl: number): DrawCommand;
385
402
  export declare function executeDrawCommands(commands: DrawCommand[], renderCtx: RenderContext): void;
386
403
  export declare function obv(bars: OhlcvBar[]): number[];
387
404
  export declare function mfi(bars: OhlcvBar[], period?: number): number[];
@@ -19,6 +19,15 @@ export declare const NQ_FEE_SCHEDULE: FeeSchedule;
19
19
  export declare const MICRO_FEE_SCHEDULE: FeeSchedule;
20
20
  export declare const ZERO_FEE_SCHEDULE: FeeSchedule;
21
21
  export declare function feeScheduleFor(symbolInfo?: SymbolInfo | null): FeeSchedule;
22
+ export type BookLevel = {
23
+ price: number;
24
+ size: number;
25
+ orders: number;
26
+ };
27
+ export type BookDepth = {
28
+ bids: BookLevel[];
29
+ asks: BookLevel[];
30
+ };
22
31
  export interface L3EngineOptions {
23
32
  symbolInfo?: SymbolInfo;
24
33
  tickSize?: number;
@@ -128,6 +137,11 @@ export interface L3MatchingEngine {
128
137
  getFillSearch: () => FillSearchOptions;
129
138
  /** Cheap gate: is there any resting order / untriggered bracket that could fill? */
130
139
  hasPendingTriggers: () => boolean;
140
+ /**
141
+ * Resting size at the best `levels` prices each side (best first). Only an
142
+ * order by order feed builds a book, anything coarser returns empty sides
143
+ */
144
+ getDepth: (levels: number) => BookDepth;
131
145
  /**
132
146
  * Replay a skipped span's bars (fetched at fillSearch.maxResolution) to apply
133
147
  * fills the jump would otherwise have skipped. Bars must be time-ascending.
@@ -14,6 +14,8 @@ export declare const StorageKey: {
14
14
  readonly colorSwatches: "christtrade:chart:color-swatches";
15
15
  readonly pluginStartup: "christtrade:chart:plugin-startup";
16
16
  readonly pluginPanels: "christtrade:chart:plugin-panels";
17
+ readonly console: "christtrade:chart:console";
18
+ readonly consoleHistory: "christtrade:chart:console-history";
17
19
  };
18
20
  /** sdklaföfkdslfk:Settings blob a plugin owns via `ctx.getSettings()` / `ctx.saveSettings()`. */
19
21
  export declare function pluginSettingsKey(pluginId: string): string;