@tony01/astroneum 0.4.1-beta.2

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 (59) hide show
  1. package/CHANGELOG.md +237 -0
  2. package/LICENSE +21 -0
  3. package/README.md +198 -0
  4. package/dist/Indicator-BBI3L_lx.d.ts +1181 -0
  5. package/dist/ar-SA-AEPUSRMF.js +2 -0
  6. package/dist/astroneum.css +1 -0
  7. package/dist/chunk-2SN3RH42.js +2 -0
  8. package/dist/chunk-2YYGUSVX.js +3 -0
  9. package/dist/chunk-3GJSZFLM.js +2 -0
  10. package/dist/chunk-4YOLQ5DC.js +2 -0
  11. package/dist/chunk-I4YQBP2M.js +3 -0
  12. package/dist/chunk-OOMZRONH.js +35 -0
  13. package/dist/chunk-PV2GAINM.js +2 -0
  14. package/dist/chunk-SDXH2WAI.js +3 -0
  15. package/dist/chunk-YFPXTHZX.js +2 -0
  16. package/dist/chunk-YW3STIPY.js +653 -0
  17. package/dist/de-DE-4PR3NRQ7.js +2 -0
  18. package/dist/entries/alerts.d.ts +93 -0
  19. package/dist/entries/alerts.js +2 -0
  20. package/dist/entries/datafeeds/crypto.d.ts +65 -0
  21. package/dist/entries/datafeeds/crypto.js +2 -0
  22. package/dist/entries/datafeeds/polygon.d.ts +113 -0
  23. package/dist/entries/datafeeds/polygon.js +2 -0
  24. package/dist/entries/multichart.d.ts +96 -0
  25. package/dist/entries/multichart.js +2 -0
  26. package/dist/entries/portfolio.d.ts +55 -0
  27. package/dist/entries/portfolio.js +2 -0
  28. package/dist/entries/replay.d.ts +141 -0
  29. package/dist/entries/replay.js +2 -0
  30. package/dist/entries/script.d.ts +68 -0
  31. package/dist/entries/script.js +2 -0
  32. package/dist/entries/watchlist.d.ts +43 -0
  33. package/dist/entries/watchlist.js +2 -0
  34. package/dist/es-ES-HNDVPSLW.js +2 -0
  35. package/dist/fr-FR-Y7XWRGF2.js +2 -0
  36. package/dist/hi-IN-KEGIKIMV.js +2 -0
  37. package/dist/id-ID-QXDIUQUZ.js +2 -0
  38. package/dist/index.d.ts +1434 -0
  39. package/dist/index.js +2 -0
  40. package/dist/it-IT-UDTDFSRB.js +2 -0
  41. package/dist/ja-JP-NIODTBW3.js +2 -0
  42. package/dist/ko-KR-DQHPXKBA.js +2 -0
  43. package/dist/nl-NL-BB3ZHCXS.js +2 -0
  44. package/dist/pl-PL-I5MZDLFD.js +2 -0
  45. package/dist/pt-BR-MAMRTOYR.js +2 -0
  46. package/dist/ru-RU-F43D6B7G.js +2 -0
  47. package/dist/th-TH-KTFIUAD6.js +2 -0
  48. package/dist/tr-TR-WFTKJ22Y.js +2 -0
  49. package/dist/vi-VN-CD3WI2FQ.js +2 -0
  50. package/dist/zh-CN-Y2C6RSOI.js +3 -0
  51. package/docs/STRUCTURE.md +231 -0
  52. package/docs/TODO-DESIGN.md +261 -0
  53. package/docs/TODO.md +222 -0
  54. package/docs/api.md +528 -0
  55. package/docs/datafeed-guide.md +311 -0
  56. package/docs/design-astroneum.md +479 -0
  57. package/docs/plugin-development.md +565 -0
  58. package/docs/tv-functions-skill.md +706 -0
  59. package/package.json +147 -0
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ var i="Indikator",a="Haupt-Indikator",r="Sub-Indikator",t="Einstellungen",l="Zeitzone",o="Screenshot",s="Vollbild",c="Beenden",_="Speichern",h="Best\xE4tigen",g="Abbrechen",d="MA(Gleitender Durchschnitt)",m="EMA(Exponentieller gleitender Durchschnitt)",u="SMA",b="BOLL(Bollinger B\xE4nder)",k="BBI(Bulle und B\xE4r Index)",p="SAR(Stopp und Umkehr)",C="VOL(Volumen)",S="MACD(Gleitender Durchschnitt Konvergenz/Divergenz)",T="KDJ",f="RSI(Relativer St\xE4rke-Index)",w="BIAS(Abweichungsrate)",z="BRAR(Bullen- und B\xE4ren-Stimmung)",B="CCI(Commodity Channel Index)",y="DMI(Richtungsbewegungsindex)",U="CR(Energie-Index)",A="PSY(Psychologische Linie)",v="DMA(Differenz gleitender Durchschnitt)",P="TRIX(Dreifach gegl\xE4tteter gleitender Durchschnitt)",L="OBV(On-Balance-Volumen)",D="VR(Volatilit\xE4ts-Volumen-Verh\xE4ltnis)",x="WR(Williams %R)",I="MTM(Momentum-Index)",V="EMV(Bewegungsleichtigkeit)",M="ROC(Preis\xE4nderungsrate)",R="PVT(Preis-Volumen-Trend)",F="AO(Awesome Oszillator)",K="UTC",O="(UTC-10) Honolulu",H="(UTC-8) Juneau",E="(UTC-7) Los Angeles",W="(UTC-5) Chicago",G="(UTC-4) Toronto",j="(UTC-3) S\xE3o Paulo",J="(UTC+1) London",N="(UTC+2) Berlin",X="(UTC+3) Bahrain",Z="(UTC+4) Dubai",Y="(UTC+5) Aschgabat",q="(UTC+6) Almaty",Q="(UTC+7) Bangkok",$="(UTC+8) Shanghai",ee="(UTC+9) Tokio",ne="(UTC+10) Sydney",ie="(UTC+12) Norfolk",ae="Horizontale Linie",re="Horizontaler Strahl",te="Horizontales Segment",le="Vertikale Linie",oe="Vertikaler Strahl",se="Vertikales Segment",ce="Trendlinie",_e="Strahl",he="Segment",ge="Pfeil",de="Preislinie",me="Preiskanalline",ue="Parallele Linie",be="Fibonacci-Linie",ke="Fibonacci-Segment",pe="Fibonacci-Kreis",Ce="Fibonacci-Spirale",Se="Fibonacci-Sektor",Te="Fibonacci-Extension",fe="Gann-Box",we="Gann-F\xE4cher",ze="Andrews-Pitchfork",Be="Rechteck",ye="Parallelogramm",Ue="Kreis",Ae="Dreieck",ve="Drei Wellen",Pe="F\xFCnf Wellen",Le="Acht Wellen",De="Beliebige Wellen",xe="ABCD-Muster",Ie="XABCD-Muster",Ve="Schwacher Magnet",Me="Starker Magnet",Re="Symbol suchen",Fe="Symbol-Code",Ke="Parameter 1",Oe="Parameter 2",He="Parameter 3",Ee="Parameter 4",We="Parameter 5",Ge="Linie 1",je="Linie 2",Je="Linie 3",Ne="Linie 4",Xe="Linie 5",Ze="Zeitraum",Ye="Standardabweichung",qe="Kerzentyp",Qe="Kerze ausgef\xFCllt",$e="Kerze Umriss",en="Aufw\xE4rtskerze Umriss",nn="Abw\xE4rtskerze Umriss",an="OHLC",rn="Fl\xE4che",tn="Letzten Preis anzeigen",ln="H\xF6chstpreis anzeigen",on="Tiefstkurs anzeigen",sn="Letzten Indikatorwert anzeigen",cn="Preisachsentyp",_n="Normal",hn="Prozent",gn="Logarithmisch",dn="Koordinaten umkehren",mn="Gitter anzeigen",un="Standard wiederherstellen",bn={indicator:i,main_indicator:a,sub_indicator:r,setting:t,timezone:l,screenshot:o,full_screen:s,exit_full_screen:c,save:_,confirm:h,cancel:g,ma:d,ema:m,sma:u,boll:b,bbi:k,sar:p,vol:C,macd:S,kdj:T,rsi:f,bias:w,brar:z,cci:B,dmi:y,cr:U,psy:A,dma:v,trix:P,obv:L,vr:D,wr:x,mtm:I,emv:V,roc:M,pvt:R,ao:F,utc:K,honolulu:O,juneau:H,los_angeles:E,chicago:W,toronto:G,sao_paulo:j,london:J,berlin:N,bahrain:X,dubai:Z,ashkhabad:Y,almaty:q,bangkok:Q,shanghai:$,tokyo:ee,sydney:ne,norfolk:ie,horizontal_straight_line:ae,horizontal_ray_line:re,horizontal_segment:te,vertical_straight_line:le,vertical_ray_line:oe,vertical_segment:se,straight_line:ce,ray_line:_e,segment:he,arrow:ge,price_line:de,price_channel_line:me,parallel_straight_line:ue,fibonacci_line:be,fibonacci_segment:ke,fibonacci_circle:pe,fibonacci_spiral:Ce,fibonacci_speed_resistance_fan:Se,fibonacci_extension:Te,gann_box:fe,gann_fan:we,pitchfork:ze,rect:Be,parallelogram:ye,circle:Ue,triangle:Ae,three_waves:ve,five_waves:Pe,eight_waves:Le,any_waves:De,abcd:xe,xabcd:Ie,weak_magnet:Ve,strong_magnet:Me,symbol_search:Re,symbol_code:Fe,params_1:Ke,params_2:Oe,params_3:He,params_4:Ee,params_5:We,line_1:Ge,line_2:je,line_3:Je,line_4:Ne,line_5:Xe,period:Ze,standard_deviation:Ye,candle_type:qe,candle_solid:Qe,candle_stroke:$e,candle_up_stroke:en,candle_down_stroke:nn,ohlc:an,area:rn,last_price_show:tn,high_price_show:ln,low_price_show:on,indicator_last_value_show:sn,price_axis_type:cn,normal:_n,percentage:hn,log:gn,reverse_coordinate:dn,grid_show:mn,restore_default:un};export{xe as abcd,q as almaty,De as any_waves,F as ao,rn as area,ge as arrow,Y as ashkhabad,X as bahrain,Q as bangkok,k as bbi,N as berlin,w as bias,b as boll,z as brar,g as cancel,nn as candle_down_stroke,Qe as candle_solid,$e as candle_stroke,qe as candle_type,en as candle_up_stroke,B as cci,W as chicago,Ue as circle,h as confirm,U as cr,bn as default,v as dma,y as dmi,Z as dubai,Le as eight_waves,m as ema,V as emv,c as exit_full_screen,pe as fibonacci_circle,Te as fibonacci_extension,be as fibonacci_line,ke as fibonacci_segment,Se as fibonacci_speed_resistance_fan,Ce as fibonacci_spiral,Pe as five_waves,s as full_screen,fe as gann_box,we as gann_fan,mn as grid_show,ln as high_price_show,O as honolulu,re as horizontal_ray_line,te as horizontal_segment,ae as horizontal_straight_line,i as indicator,sn as indicator_last_value_show,H as juneau,T as kdj,tn as last_price_show,Ge as line_1,je as line_2,Je as line_3,Ne as line_4,Xe as line_5,gn as log,J as london,E as los_angeles,on as low_price_show,d as ma,S as macd,a as main_indicator,I as mtm,ie as norfolk,_n as normal,L as obv,an as ohlc,ue as parallel_straight_line,ye as parallelogram,Ke as params_1,Oe as params_2,He as params_3,Ee as params_4,We as params_5,hn as percentage,Ze as period,ze as pitchfork,cn as price_axis_type,me as price_channel_line,de as price_line,A as psy,R as pvt,_e as ray_line,Be as rect,un as restore_default,dn as reverse_coordinate,M as roc,f as rsi,j as sao_paulo,p as sar,_ as save,o as screenshot,he as segment,t as setting,$ as shanghai,u as sma,Ye as standard_deviation,ce as straight_line,Me as strong_magnet,r as sub_indicator,ne as sydney,Fe as symbol_code,Re as symbol_search,ve as three_waves,l as timezone,ee as tokyo,G as toronto,Ae as triangle,P as trix,K as utc,oe as vertical_ray_line,se as vertical_segment,le as vertical_straight_line,C as vol,D as vr,Ve as weak_magnet,x as wr,Ie as xabcd};
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Client-side price / indicator alerts engine — extended.
3
+ *
4
+ * Alerts are persisted to localStorage and evaluated on every new bar
5
+ * or price tick via `AlertManager.check()`.
6
+ *
7
+ * Extended fields: expiration, messageTemplate, emailEnabled,
8
+ * plainTextEnabled, plainTextEmail, toastEnabled, notificationSchedule,
9
+ * soundTitle, soundDuration.
10
+ *
11
+ * Delivery: sound (variable titles), browser notification, toast popup,
12
+ * webhook (via server-side relay /astroneum/api/alerts/webhook), email
13
+ * (via API route), plain-text email, schedule gate. Webhook delivery status
14
+ * is written back onto the alert so the alert log can surface it
15
+ * (mirrors TradingView's "Webhook status" column).
16
+ */
17
+ type AlertCondition = 'above' | 'below' | 'crosses_above' | 'crosses_below' | 'crossing';
18
+ type AlertStatus = 'active' | 'triggered' | 'expired' | 'dismissed';
19
+ type AlertFrequency = 'once' | 'every_bar' | 'bar_close';
20
+ type SoundTitle = 'Thin' | 'Classic' | 'Alert' | 'Bell' | 'Chime';
21
+ type SoundDuration = 'once' | 'repeating';
22
+ type WebhookStatus = 'pending' | 'delivered' | 'failed';
23
+ interface NotificationSchedule {
24
+ preset: '24/7' | 'weekdays' | 'working_hours' | 'custom';
25
+ days?: number[];
26
+ from?: string;
27
+ to?: string;
28
+ }
29
+ interface Alert {
30
+ id: string;
31
+ symbol: string;
32
+ condition: AlertCondition;
33
+ price: number;
34
+ note?: string;
35
+ timeframe?: string;
36
+ frequency: AlertFrequency;
37
+ status: AlertStatus;
38
+ createdAt: string;
39
+ triggeredAt?: string;
40
+ soundEnabled: boolean;
41
+ notificationEnabled: boolean;
42
+ webhookUrl?: string;
43
+ webhookStatus?: WebhookStatus;
44
+ webhookStatusAt?: string;
45
+ webhookHttpStatus?: number;
46
+ expiration?: string;
47
+ messageTemplate?: string;
48
+ emailEnabled?: boolean;
49
+ plainTextEnabled?: boolean;
50
+ plainTextEmail?: string;
51
+ toastEnabled?: boolean;
52
+ notificationSchedule?: NotificationSchedule;
53
+ soundTitle?: SoundTitle;
54
+ soundDuration?: SoundDuration;
55
+ }
56
+ type AlertCreate = Omit<Alert, 'id' | 'status' | 'createdAt' | 'triggeredAt'> & Partial<Pick<Alert, 'frequency' | 'soundEnabled' | 'notificationEnabled'>>;
57
+ interface AlertCheckInput {
58
+ symbol: string;
59
+ price: number;
60
+ timestamp: number;
61
+ }
62
+ type AlertTriggeredCallback = (alert: Alert, price: number) => void;
63
+ declare class AlertManager {
64
+ private static _instance;
65
+ private _alerts;
66
+ private _lastPrice;
67
+ private _listeners;
68
+ private _savePending;
69
+ private constructor();
70
+ static getInstance(): AlertManager;
71
+ add(create: AlertCreate): string;
72
+ update(id: string, patch: Partial<Omit<Alert, 'id' | 'createdAt'>>): boolean;
73
+ delete(id: string): boolean;
74
+ dismiss(id: string): boolean;
75
+ reactivate(id: string): boolean;
76
+ clear(symbol?: string): void;
77
+ getAll(): readonly Alert[];
78
+ getActive(): Alert[];
79
+ getForSymbol(symbol: string): Alert[];
80
+ getActiveForSymbol(symbol: string): Alert[];
81
+ getHistory(): Alert[];
82
+ /**
83
+ * Call on every price tick or bar close.
84
+ * Checks expiration, evaluates conditions, fires delivery.
85
+ */
86
+ check(input: AlertCheckInput): void;
87
+ private _schedulePersist;
88
+ private _fire;
89
+ onTriggered(cb: AlertTriggeredCallback): () => void;
90
+ requestNotificationPermission(): Promise<NotificationPermission>;
91
+ }
92
+
93
+ export { type Alert, type AlertCheckInput, type AlertCondition, type AlertCreate, type AlertFrequency, AlertManager, type AlertStatus, type AlertTriggeredCallback, type NotificationSchedule, type SoundDuration, type SoundTitle };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export{a as AlertManager}from'../chunk-4YOLQ5DC.js';
@@ -0,0 +1,65 @@
1
+ import { e as SymbolInfo, d as Period, C as CandleData, D as Datafeed, i as DatafeedSubscribeCallback } from '../../Indicator-BBI3L_lx.js';
2
+ import 'react';
3
+
4
+ interface CryptoSymbolInfo extends SymbolInfo {
5
+ exchange: string;
6
+ venueSymbol?: string;
7
+ instId?: string;
8
+ productType?: string;
9
+ }
10
+ declare const STANDARD_CRYPTO_SYMBOLS: readonly SymbolInfo[];
11
+ type DatafeedErrorType = 'history-empty' | 'history-request-failed' | 'unsupported-period' | 'unsupported-symbol' | 'subscription-failed';
12
+ interface DatafeedErrorDetail {
13
+ exchange?: string;
14
+ ticker: string;
15
+ period: string;
16
+ type: DatafeedErrorType;
17
+ message: string;
18
+ }
19
+ declare const DATAFEED_ERROR_EVENT = "astroneum:datafeed-error";
20
+ interface ExchangeAdapter {
21
+ readonly id: string;
22
+ getHistoryBars(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<CandleData[]>;
23
+ getWebSocketUrl(symbol: SymbolInfo, period: Period): string;
24
+ parseMessage(event: MessageEvent, symbol: SymbolInfo, period: Period): CandleData | null;
25
+ onOpen?(ws: WebSocket, symbol: SymbolInfo, period: Period): void;
26
+ }
27
+ declare const BinanceAdapter: ExchangeAdapter;
28
+ declare const BitgetAdapter: ExchangeAdapter;
29
+ declare const OkxAdapter: ExchangeAdapter;
30
+ interface StandardCryptoDatafeedOptions {
31
+ /**
32
+ * Symbols available through searchSymbols.
33
+ * Defaults to STANDARD_CRYPTO_SYMBOLS.
34
+ */
35
+ symbols?: readonly SymbolInfo[];
36
+ /**
37
+ * Exchange adapters keyed by adapter.id.
38
+ * Defaults to built-in Binance, Bitget, and OKX adapters.
39
+ */
40
+ adapters?: readonly ExchangeAdapter[];
41
+ /**
42
+ * Tick interpolation duration (ms) for smoother live movement.
43
+ * Set to 0 for raw, non-interpolated tick rendering.
44
+ * Defaults to 220.
45
+ */
46
+ smoothingDuration?: number;
47
+ }
48
+ declare class StandardCryptoDatafeed implements Datafeed {
49
+ private readonly symbols;
50
+ private readonly liveFeeds;
51
+ private readonly supportedExchanges;
52
+ private readonly noDataFeed;
53
+ private readonly activeFeedByKey;
54
+ constructor(options?: StandardCryptoDatafeedOptions);
55
+ searchSymbols(search?: string): Promise<SymbolInfo[]>;
56
+ getHistoryData(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<CandleData[]>;
57
+ subscribe(symbol: SymbolInfo, period: Period, callback: DatafeedSubscribeCallback): void;
58
+ unsubscribe(symbol: SymbolInfo, period: Period): void;
59
+ private normalizeSymbol;
60
+ private resolveFeed;
61
+ private resolveExchange;
62
+ }
63
+ declare function createStandardCryptoDatafeed(options?: StandardCryptoDatafeedOptions): StandardCryptoDatafeed;
64
+
65
+ export { BinanceAdapter, BitgetAdapter, type CryptoSymbolInfo, DATAFEED_ERROR_EVENT, type DatafeedErrorDetail, type DatafeedErrorType, type ExchangeAdapter, OkxAdapter, STANDARD_CRYPTO_SYMBOLS, StandardCryptoDatafeed, type StandardCryptoDatafeedOptions, createStandardCryptoDatafeed };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export{c as BinanceAdapter,d as BitgetAdapter,b as DATAFEED_ERROR_EVENT,e as OkxAdapter,a as STANDARD_CRYPTO_SYMBOLS,f as StandardCryptoDatafeed,g as createStandardCryptoDatafeed}from'../../chunk-I4YQBP2M.js';import'../../chunk-SDXH2WAI.js';
@@ -0,0 +1,113 @@
1
+ import { D as Datafeed, e as SymbolInfo, d as Period, C as CandleData, i as DatafeedSubscribeCallback } from '../../Indicator-BBI3L_lx.js';
2
+ import 'react';
3
+
4
+ declare class DefaultDatafeed implements Datafeed {
5
+ #private;
6
+ constructor(apiKey: string);
7
+ private _prevSymbolMarket?;
8
+ private _ws?;
9
+ private _reconnectDelay;
10
+ private _reconnectTimer?;
11
+ private _currentSymbol?;
12
+ private _currentCallback?;
13
+ private _prevTickTimestamp;
14
+ private _prevTickOpen;
15
+ private _prevTickHigh;
16
+ private _prevTickLow;
17
+ private _prevTickClose;
18
+ /** Returns true when the incoming tick carries new information. */
19
+ private _isDeltaTick;
20
+ /** Update the rolling reference point for delta comparison. */
21
+ private _updateDeltaRef;
22
+ /**
23
+ * OHLCV-aware coalescer: merges ticks arriving within the same rAF frame
24
+ * into one financially accurate bar (high=max, low=min, close=last, volume=sum).
25
+ * Feeds the merged result into the TickAnimator for smooth close interpolation.
26
+ */
27
+ private readonly _mergeTick;
28
+ /**
29
+ * Smooth price interpolation: animates the last bar's close/high/low values
30
+ * over 120ms so rapid ticks produce fluid motion instead of jarring jumps.
31
+ * The interpolated frame is what actually reaches the chart callback.
32
+ */
33
+ private readonly _animator;
34
+ searchSymbols(search?: string): Promise<SymbolInfo[]>;
35
+ getHistoryData(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<CandleData[]>;
36
+ /**
37
+ * Subscribes to real-time trade ticks for the given symbol.
38
+ * NOTE: Polygon's delayed WebSocket stream delivers raw trades (ev: 'T'),
39
+ * not pre-aggregated OHLCV bars. Bar aggregation is handled by the engine.
40
+ * The `_period` parameter is intentionally unused.
41
+ */
42
+ subscribe(symbol: SymbolInfo, _period: Period, callback: DatafeedSubscribeCallback): void;
43
+ private _setupWS;
44
+ private _scheduleReconnect;
45
+ private _teardownWS;
46
+ /**
47
+ * Tears down the active WebSocket subscription for the given symbol.
48
+ * The `_period` parameter is intentionally unused (matches interface contract).
49
+ */
50
+ unsubscribe(symbol: SymbolInfo, _period: Period): void;
51
+ }
52
+
53
+ interface WebSocketDatafeedOptions {
54
+ /**
55
+ * Duration in milliseconds for TickAnimator smooth interpolation.
56
+ * Set to 0 to disable smoothing. Default: 140
57
+ */
58
+ smoothingDuration?: number;
59
+ /**
60
+ * Base reconnect delay in ms (doubles on each failure). Default: 1000
61
+ */
62
+ reconnectBaseMs?: number;
63
+ /**
64
+ * Maximum reconnect delay in ms. Default: 30000
65
+ */
66
+ reconnectMaxMs?: number;
67
+ }
68
+ declare abstract class WebSocketDatafeed implements Datafeed {
69
+ protected readonly smoothingDuration: number;
70
+ protected readonly reconnectBaseMs: number;
71
+ protected readonly reconnectMaxMs: number;
72
+ private readonly _sockets;
73
+ private readonly _animators;
74
+ private readonly _reconnectTimers;
75
+ private readonly _reconnectDelays;
76
+ private readonly _manualClose;
77
+ constructor(options?: WebSocketDatafeedOptions);
78
+ /** Fetch historical OHLCV bars from your REST API. */
79
+ abstract getHistoryBars(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<CandleData[]>;
80
+ /**
81
+ * Return the WebSocket URL for the given symbol/period.
82
+ * Called on every (re)connect.
83
+ */
84
+ abstract getWebSocketUrl(symbol: SymbolInfo, period: Period): string;
85
+ /**
86
+ * Parse a raw WebSocket MessageEvent.
87
+ * Return a CandleData object to emit a tick, or null to ignore the message.
88
+ */
89
+ abstract parseMessage(event: MessageEvent, symbol: SymbolInfo, period: Period): CandleData | null;
90
+ /** Optionally override to search your symbol catalogue. Default returns []. */
91
+ searchSymbols(_search?: string): Promise<SymbolInfo[]>;
92
+ /**
93
+ * Called immediately after a WebSocket connection opens.
94
+ * Override to send a subscription frame (e.g., Binance topic subscribe JSON).
95
+ */
96
+ protected onOpen(_ws: WebSocket, _symbol: SymbolInfo, _period: Period): void;
97
+ getHistoryData(symbol: SymbolInfo, period: Period, from: number, to: number): Promise<CandleData[]>;
98
+ subscribe(symbol: SymbolInfo, period: Period, callback: DatafeedSubscribeCallback): void;
99
+ unsubscribe(symbol: SymbolInfo, period: Period): void;
100
+ /**
101
+ * Convert a Period to a Binance-style interval string ('1m', '5m', '1h', etc.)
102
+ * Returns null if the multiplier is not a standard Binance interval.
103
+ */
104
+ protected toInterval(period: Period): string | null;
105
+ /** Period duration in milliseconds. */
106
+ protected periodMs(period: Period): number;
107
+ private _key;
108
+ private _connect;
109
+ private _scheduleReconnect;
110
+ private _cleanup;
111
+ }
112
+
113
+ export { DefaultDatafeed, WebSocketDatafeed, type WebSocketDatafeedOptions };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export{a as DefaultDatafeed}from'../../chunk-2YYGUSVX.js';import'../../chunk-YFPXTHZX.js';export{b as WebSocketDatafeed}from'../../chunk-SDXH2WAI.js';
@@ -0,0 +1,96 @@
1
+ import { A as AstroneumOptions, e as SymbolInfo, d as Period, a as AstroneumHandle } from '../Indicator-BBI3L_lx.js';
2
+ import 'react';
3
+
4
+ /** Number of charts in a multi-chart view. */
5
+ type MultiChartCount = 2 | 4 | 8 | 16;
6
+ /** A slot configuration within the layout. */
7
+ interface MultiChartSlot {
8
+ symbol: SymbolInfo;
9
+ period: Period;
10
+ }
11
+ /** Options for creating a MultiChartLayout. */
12
+ interface MultiChartLayoutOptions extends Omit<AstroneumOptions, 'symbol' | 'period'> {
13
+ /** The DOM element (or id) to render the layout into. */
14
+ container: string | HTMLElement;
15
+ /**
16
+ * Number of charts to display. Determines the grid.
17
+ * 2 → 1×2 (two columns)
18
+ * 4 → 2×2
19
+ * 8 → 2×4
20
+ * 16 → 4×4
21
+ */
22
+ count?: MultiChartCount;
23
+ /** Initial slot configuration. Defaults to the first symbol/period for all slots. */
24
+ slots?: MultiChartSlot[];
25
+ /** Symbol / period used for slots with no explicit configuration. */
26
+ symbol: SymbolInfo;
27
+ period: Period;
28
+ /** Whether to sync crosshair across all charts (default: true). */
29
+ syncCrosshair?: boolean;
30
+ /** Whether to sync symbol and period across all charts (default: false). */
31
+ syncSymbolPeriod?: boolean;
32
+ /** localStorage key for layout persistence. Pass null to disable. */
33
+ storageKey?: string | null;
34
+ }
35
+ /**
36
+ * Manages a grid of Astroneum chart instances inside a single container.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const layout = new MultiChartLayout({
41
+ * container: 'chart-root',
42
+ * count: 4,
43
+ * symbol: { ticker: 'AAPL' },
44
+ * period: { multiplier: 1, timespan: 'day', text: 'D' },
45
+ * datafeed: myDatafeed,
46
+ * storageKey: 'my-layout'
47
+ * })
48
+ * ```
49
+ */
50
+ declare class MultiChartLayout {
51
+ private _container;
52
+ private _count;
53
+ private _charts;
54
+ private _slots;
55
+ private _options;
56
+ private _storageKey;
57
+ private _syncCrosshair;
58
+ private _syncSymbolPeriod;
59
+ private _activeIndex;
60
+ private _wrapperEl;
61
+ constructor(options: MultiChartLayoutOptions);
62
+ private _render;
63
+ private _setActive;
64
+ private _destroy;
65
+ private _persist;
66
+ /** Change the layout grid (2 | 4 | 8 | 16). Re-renders all charts. */
67
+ setCount(count: MultiChartCount): void;
68
+ /** Get the count of charts. */
69
+ getCount(): MultiChartCount;
70
+ /** Get the chart instance at a given index. */
71
+ getChart(index: number): AstroneumHandle | undefined;
72
+ /** Get all chart instances. */
73
+ getAllCharts(): AstroneumHandle[];
74
+ /** Get the index of the currently active (focused) chart. */
75
+ getActiveIndex(): number;
76
+ /** Get the currently active chart instance. */
77
+ getActiveChart(): AstroneumHandle | undefined;
78
+ /**
79
+ * Set the symbol for a specific chart slot (or all slots if syncSymbolPeriod is on).
80
+ */
81
+ setSymbol(symbol: SymbolInfo, index?: number): void;
82
+ /**
83
+ * Set the period for a specific chart slot (or all slots if syncSymbolPeriod is on).
84
+ */
85
+ setPeriod(period: Period, index?: number): void;
86
+ /** Set theme for all charts. */
87
+ setTheme(theme: string): void;
88
+ /** Set locale for all charts. */
89
+ setLocale(locale: string): void;
90
+ /** Save current layout to localStorage immediately. */
91
+ saveLayout(): void;
92
+ /** Destroy all charts and clean up the DOM. */
93
+ destroy(): void;
94
+ }
95
+
96
+ export { type MultiChartCount, MultiChartLayout, type MultiChartLayoutOptions, type MultiChartSlot };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export{m as MultiChartLayout}from'../chunk-OOMZRONH.js';import'../chunk-YFPXTHZX.js';import'../chunk-4YOLQ5DC.js';import'../chunk-YW3STIPY.js';
@@ -0,0 +1,55 @@
1
+ /**
2
+ * PortfolioTracker — client-side position / P&L tracker.
3
+ * Persists to localStorage under key 'astroneum-portfolio'.
4
+ */
5
+ type PositionSide = 'long' | 'short';
6
+ interface Position {
7
+ id: string;
8
+ symbol: string;
9
+ side: PositionSide;
10
+ quantity: number;
11
+ entryPrice: number;
12
+ entryTime: string;
13
+ exitPrice?: number;
14
+ exitTime?: string;
15
+ note?: string;
16
+ }
17
+ interface PnLResult {
18
+ position: Position;
19
+ /** Unrealised (open) or realised (closed) gross P&L in price units × quantity */
20
+ pnl: number;
21
+ /** P&L as a fraction of entry value, e.g. 0.05 = +5 % */
22
+ pnlPercent: number;
23
+ }
24
+ type PortfolioChangedCallback = (positions: Position[]) => void;
25
+ declare class PortfolioTracker {
26
+ private static _instance;
27
+ private _positions;
28
+ private _listeners;
29
+ private constructor();
30
+ static getInstance(): PortfolioTracker;
31
+ onChange(cb: PortfolioChangedCallback): () => void;
32
+ addPosition(params: Omit<Position, 'id' | 'entryTime'> & {
33
+ entryTime?: string;
34
+ }): Position;
35
+ closePosition(id: string, exitPrice: number, exitTime?: string): void;
36
+ deletePosition(id: string): void;
37
+ getOpenPositions(symbol?: string): Position[];
38
+ getClosedPositions(symbol?: string): Position[];
39
+ getAllPositions(): Position[];
40
+ /**
41
+ * Calculate P&L for a single position.
42
+ * @param id - Position id
43
+ * @param currentPrice - Current market price (used for open positions)
44
+ */
45
+ getPnL(id: string, currentPrice?: number): PnLResult | null;
46
+ /**
47
+ * Calculate total P&L across all positions (open or closed).
48
+ * @param currentPrices - Map of symbol → current price for open positions
49
+ */
50
+ getTotalPnL(currentPrices?: Record<string, number>): number;
51
+ private _persist;
52
+ private _load;
53
+ }
54
+
55
+ export { type PnLResult, PortfolioTracker, type Position, type PositionSide };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export{a as PortfolioTracker}from'../chunk-2SN3RH42.js';
@@ -0,0 +1,141 @@
1
+ import { D as Datafeed, e as SymbolInfo, d as Period, C as CandleData, N as Nullable } from '../Indicator-BBI3L_lx.js';
2
+ import 'react';
3
+
4
+ type BarReplayState = 'idle' | 'playing' | 'paused' | 'finished';
5
+ interface BarReplayOptions {
6
+ /** The datafeed to load historical bars from. */
7
+ datafeed: Datafeed;
8
+ /** Symbol to replay. */
9
+ symbol: SymbolInfo;
10
+ /** Period to replay. */
11
+ period: Period;
12
+ /**
13
+ * Timestamp (ms) to start the replay from.
14
+ * If omitted, uses the earliest bar in the loaded history.
15
+ */
16
+ startTime?: number;
17
+ /**
18
+ * Timestamp (ms) to end the replay at.
19
+ * If omitted, replays to the latest available bar.
20
+ */
21
+ endTime?: number;
22
+ /**
23
+ * Milliseconds between each bar step when playing automatically.
24
+ * Default: 500ms
25
+ */
26
+ intervalMs?: number;
27
+ /**
28
+ * Number of initial bars to pre-load before replay begins.
29
+ * Default: 300
30
+ */
31
+ initialBars?: number;
32
+ /** Called whenever a new bar is emitted during replay. */
33
+ onBar?: (bar: CandleData, index: number, total: number) => void;
34
+ /** Called when replay state changes. */
35
+ onStateChange?: (state: BarReplayState) => void;
36
+ /** Called when replay finishes (reached endTime or last bar). */
37
+ onFinish?: () => void;
38
+ }
39
+ /**
40
+ * Historical bar replay engine for manual strategy testing.
41
+ *
42
+ * Important: for realistic backtesting, use `getRevealedBars()` to feed only
43
+ * bars up to the cursor into the chart. This ensures indicators only see data
44
+ * available at the replay point — not future bars.
45
+ *
46
+ * Usage:
47
+ * ```ts
48
+ * const replay = new BarReplay({
49
+ * datafeed,
50
+ * symbol: { ticker: 'AAPL' },
51
+ * period: { multiplier: 1, timespan: 'day', text: 'D' },
52
+ * onBar: (bar, idx, total) => {
53
+ * // Feed only revealed bars for realistic indicator calculations
54
+ * chart.setData(replay.getRevealedBars())
55
+ * },
56
+ * onStateChange: (s) => console.log('state:', s),
57
+ * })
58
+ *
59
+ * await replay.load()
60
+ * // Initialize chart with pre-replay context only
61
+ * chart.setData(replay.getRevealedBars())
62
+ * replay.play()
63
+ * ```
64
+ */
65
+ declare class BarReplay {
66
+ private _opts;
67
+ private _bars;
68
+ private _cursor;
69
+ private _state;
70
+ private _timer;
71
+ constructor(options: BarReplayOptions);
72
+ private _setState;
73
+ private _emitCurrent;
74
+ private _advance;
75
+ private _stop;
76
+ /**
77
+ * Load historical bars from the datafeed.
78
+ * Must be called before play/step.
79
+ */
80
+ load(): Promise<void>;
81
+ /**
82
+ * Get the bars that have been "revealed" so far (up to and including cursor).
83
+ * Use this to initialise the chart with the pre-replay context bars.
84
+ */
85
+ getRevealedBars(): CandleData[];
86
+ /** Get all loaded bars (for reference). */
87
+ getAllBars(): CandleData[];
88
+ /** Current replay state. */
89
+ get state(): BarReplayState;
90
+ /** Index of the current bar (0-based from start of loaded bars). */
91
+ get cursor(): number;
92
+ /** Total number of loaded bars. */
93
+ get total(): number;
94
+ /** Current bar or null if no bars loaded. */
95
+ get currentBar(): Nullable<CandleData>;
96
+ /** Progress as a value between 0 and 1. */
97
+ get progress(): number;
98
+ /**
99
+ * Start auto-playing the replay at the configured interval.
100
+ */
101
+ play(): void;
102
+ /**
103
+ * Pause auto-play. Use play() to resume.
104
+ */
105
+ pause(): void;
106
+ /**
107
+ * Toggle between play and pause.
108
+ */
109
+ togglePlayPause(): void;
110
+ /**
111
+ * Advance by one bar (manual step). Pauses auto-play if running.
112
+ */
113
+ stepForward(): void;
114
+ /**
115
+ * Go back one bar. Pauses auto-play if running.
116
+ */
117
+ stepBack(): void;
118
+ /**
119
+ * Jump to a specific bar index. Pauses auto-play.
120
+ */
121
+ seekTo(index: number): void;
122
+ /**
123
+ * Seek to a timestamp. Finds the nearest bar at or before the given time.
124
+ */
125
+ seekToTime(timestamp: number): void;
126
+ /**
127
+ * Change the playback speed.
128
+ * @param intervalMs Milliseconds between bars (lower = faster)
129
+ */
130
+ setSpeed(intervalMs: number): void;
131
+ /**
132
+ * Reset replay to the beginning (before initial pre-load position).
133
+ */
134
+ reset(): void;
135
+ /**
136
+ * Stop and clean up. Call when done with this instance.
137
+ */
138
+ destroy(): void;
139
+ }
140
+
141
+ export { BarReplay, type BarReplayOptions, type BarReplayState };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export{a as BarReplay}from'../chunk-3GJSZFLM.js';
@@ -0,0 +1,68 @@
1
+ import { I as IndicatorTemplate } from '../Indicator-BBI3L_lx.js';
2
+ import 'react';
3
+
4
+ /**
5
+ * Client-side JavaScript indicator scripting engine.
6
+ *
7
+ * Lets users write Pine-Script–inspired indicator logic in plain JS
8
+ * and compile it into an IndicatorTemplate that is registered
9
+ * with the chart engine during compilation.
10
+ *
11
+ * Security: scripts run inside a Function scope with a curated API
12
+ * surface (forbidden identifiers shadowed, Object/Array prototypes frozen).
13
+ * This is a best-effort sandbox suitable for trusted user scripts only —
14
+ * constructor-chain escapes (e.g. (0).constructor.constructor) are not
15
+ * fully blocked. Do NOT run untrusted third-party scripts without a
16
+ * real isolate (sandboxed iframe or Web Worker).
17
+ *
18
+ * Usage:
19
+ * const engine = ScriptEngine.getInstance()
20
+ * const template = engine.compile(`
21
+ * study('My MA', { overlay: true })
22
+ * const len = input('Length', 14)
23
+ * plot(ta.sma(close, len), { title: 'SMA', color: '#2962ff' })
24
+ * `)
25
+ * chart.createIndicator(template.name)
26
+ */
27
+
28
+ interface StudyOptions {
29
+ /** Display name shown in tooltip */
30
+ shortName?: string;
31
+ /** Whether to overlay on the price pane (default false) */
32
+ overlay?: boolean;
33
+ /** Precision of displayed values */
34
+ precision?: number;
35
+ }
36
+ interface PlotOptions {
37
+ title?: string;
38
+ color?: string;
39
+ lineWidth?: number;
40
+ visible?: boolean;
41
+ }
42
+ interface InputOptions {
43
+ type?: 'int' | 'float' | 'bool' | 'string';
44
+ options?: (number | string)[];
45
+ }
46
+ interface CompiledIndicator extends IndicatorTemplate {
47
+ /** Original source for editing */
48
+ _source: string;
49
+ }
50
+ declare class ScriptEngine {
51
+ private static _instance;
52
+ private _registry;
53
+ private constructor();
54
+ static getInstance(): ScriptEngine;
55
+ /**
56
+ * Compile a script string into an IndicatorTemplate.
57
+ * Throws a descriptive Error if compilation or type validation fails.
58
+ */
59
+ compile(source: string, name?: string): CompiledIndicator;
60
+ /** Get a previously compiled template by name */
61
+ get(name: string): CompiledIndicator | undefined;
62
+ /** All registered script names */
63
+ list(): string[];
64
+ /** Remove a compiled indicator */
65
+ remove(name: string): void;
66
+ }
67
+
68
+ export { type CompiledIndicator, type InputOptions, type PlotOptions, ScriptEngine, type StudyOptions };
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export{l as ScriptEngine}from'../chunk-YW3STIPY.js';