@stocksharp/trading-controls 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +30 -0
- package/NOTICE +21 -0
- package/README.md +240 -0
- package/dist/esm/active-orders-widget.js +382 -0
- package/dist/esm/active-orders-widget.js.map +1 -0
- package/dist/esm/control-types.js +23 -0
- package/dist/esm/control-types.js.map +1 -0
- package/dist/esm/dom.js +55 -0
- package/dist/esm/dom.js.map +1 -0
- package/dist/esm/formatters.js +69 -0
- package/dist/esm/formatters.js.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/positions-widget.js +258 -0
- package/dist/esm/positions-widget.js.map +1 -0
- package/dist/esm/trade-history-widget.js +197 -0
- package/dist/esm/trade-history-widget.js.map +1 -0
- package/dist/esm/trading-data.js +26 -0
- package/dist/esm/trading-data.js.map +1 -0
- package/dist/esm/trading-host.js +79 -0
- package/dist/esm/trading-host.js.map +1 -0
- package/dist/esm/watchlist-widget.js +481 -0
- package/dist/esm/watchlist-widget.js.map +1 -0
- package/dist/sstradingcontrols.js +1740 -0
- package/dist/sstradingcontrols.js.map +7 -0
- package/dist/types/active-orders-widget.d.ts +52 -0
- package/dist/types/active-orders-widget.d.ts.map +1 -0
- package/dist/types/control-types.d.ts +8 -0
- package/dist/types/control-types.d.ts.map +1 -0
- package/dist/types/dom.d.ts +6 -0
- package/dist/types/dom.d.ts.map +1 -0
- package/dist/types/formatters.d.ts +8 -0
- package/dist/types/formatters.d.ts.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/positions-widget.d.ts +37 -0
- package/dist/types/positions-widget.d.ts.map +1 -0
- package/dist/types/trade-history-widget.d.ts +25 -0
- package/dist/types/trade-history-widget.d.ts.map +1 -0
- package/dist/types/trading-data.d.ts +55 -0
- package/dist/types/trading-data.d.ts.map +1 -0
- package/dist/types/trading-host.d.ts +62 -0
- package/dist/types/trading-host.d.ts.map +1 -0
- package/dist/types/watchlist-widget.d.ts +60 -0
- package/dist/types/watchlist-widget.d.ts.map +1 -0
- package/package.json +129 -0
- package/src/active-orders-widget.ts +411 -0
- package/src/control-types.ts +24 -0
- package/src/dom.ts +68 -0
- package/src/formatters.ts +72 -0
- package/src/index.ts +52 -0
- package/src/positions-widget.ts +305 -0
- package/src/trade-history-widget.ts +221 -0
- package/src/trading-data.ts +121 -0
- package/src/trading-host.ts +300 -0
- package/src/watchlist-widget.ts +513 -0
- package/styles/theme.css +86 -0
- package/styles/trading-controls.css +469 -0
- package/translation-keys.json +58 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TradingHost } from './trading-host.js';
|
|
2
|
+
import type { TradeRow } from './trading-data.js';
|
|
3
|
+
import { DataGrid, GridColumn } from '@stocksharp/grids/data-grid';
|
|
4
|
+
export interface TradeHistoryDeps {
|
|
5
|
+
host: TradingHost;
|
|
6
|
+
}
|
|
7
|
+
export declare class TradeHistoryWidget {
|
|
8
|
+
static TYPE: "tradeHistory";
|
|
9
|
+
rootEl: HTMLElement;
|
|
10
|
+
bodyEl: HTMLElement | null;
|
|
11
|
+
_host: TradingHost;
|
|
12
|
+
_closeBtn: HTMLElement | null;
|
|
13
|
+
_refreshBtn: HTMLElement | null;
|
|
14
|
+
_exportBtn: HTMLElement | null;
|
|
15
|
+
_rows: TradeRow[];
|
|
16
|
+
_grid: DataGrid<TradeRow> | null;
|
|
17
|
+
static create(hostEl: HTMLElement, state: Record<string, unknown>, deps: TradeHistoryDeps): TradeHistoryWidget;
|
|
18
|
+
static _buildRoot(host: TradingHost): HTMLElement;
|
|
19
|
+
constructor(rootEl: HTMLElement, _state: Record<string, unknown>, deps: TradeHistoryDeps);
|
|
20
|
+
dispose(): void;
|
|
21
|
+
refresh(): Promise<void>;
|
|
22
|
+
_export(): void;
|
|
23
|
+
_columns(): GridColumn<TradeRow>[];
|
|
24
|
+
}
|
|
25
|
+
//# source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}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type OrderSide = number | string;
|
|
2
|
+
export type OrderType = number | string;
|
|
3
|
+
export type OrderStatus = number | string;
|
|
4
|
+
export interface PositionRow {
|
|
5
|
+
portfolioId?: number | null;
|
|
6
|
+
instrumentId?: number | null;
|
|
7
|
+
instrument?: string;
|
|
8
|
+
quantity?: number | null;
|
|
9
|
+
avgPrice?: number | null;
|
|
10
|
+
currentPrice?: number | null;
|
|
11
|
+
unrealizedPnl?: number | null;
|
|
12
|
+
realizedPnl?: number | null;
|
|
13
|
+
}
|
|
14
|
+
export interface BalanceRow {
|
|
15
|
+
available?: number | null;
|
|
16
|
+
locked?: number | null;
|
|
17
|
+
total?: number | null;
|
|
18
|
+
}
|
|
19
|
+
export interface OrderRow {
|
|
20
|
+
id?: number | null;
|
|
21
|
+
localId?: number | null;
|
|
22
|
+
instrument?: string;
|
|
23
|
+
side?: OrderSide;
|
|
24
|
+
type?: OrderType;
|
|
25
|
+
quantity?: number | null;
|
|
26
|
+
balance?: number | null;
|
|
27
|
+
limitPrice?: number | null;
|
|
28
|
+
stopPrice?: number | null;
|
|
29
|
+
status?: OrderStatus;
|
|
30
|
+
rejectReason?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface TradeRow {
|
|
33
|
+
id?: number | null;
|
|
34
|
+
executedAt?: string;
|
|
35
|
+
time?: string;
|
|
36
|
+
instrumentSymbol?: string;
|
|
37
|
+
symbol?: string;
|
|
38
|
+
side?: OrderSide;
|
|
39
|
+
quantity?: number | null;
|
|
40
|
+
price?: number | null;
|
|
41
|
+
order?: number | null;
|
|
42
|
+
orderId?: number | null;
|
|
43
|
+
}
|
|
44
|
+
export interface InstrumentRow {
|
|
45
|
+
symbol?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
exchange?: string;
|
|
48
|
+
category?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface QuoteStats {
|
|
51
|
+
lastPrice?: number | null;
|
|
52
|
+
baseline?: number | null;
|
|
53
|
+
chgPct?: number | null;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=trading-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trading-data.d.ts","sourceRoot":"","sources":["../../src/trading-data.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAIxC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAIxC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAG1C,MAAM,WAAW,WAAW;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAI5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAGD,MAAM,WAAW,UAAU;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAGD,MAAM,WAAW,QAAQ;IAGrB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAIzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IAGrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,QAAQ;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAGD,MAAM,WAAW,aAAa;IAE1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAID,MAAM,WAAW,UAAU;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { InstrumentRow, OrderRow, OrderSide, OrderStatus, OrderType, QuoteStats, TradeRow } from './trading-data.js';
|
|
2
|
+
export interface TradingPresentation {
|
|
3
|
+
sideText(side: OrderSide): string;
|
|
4
|
+
typeText(type: OrderType, limitPrice: number, stopPrice: number): string;
|
|
5
|
+
statusText(status: OrderStatus): string;
|
|
6
|
+
sideClass(side: OrderSide): string;
|
|
7
|
+
pnlClass(pnl: number): string;
|
|
8
|
+
}
|
|
9
|
+
export declare const PRESENTATION_CLASSES: {
|
|
10
|
+
readonly sideClass: readonly ["side-buy", "side-sell"];
|
|
11
|
+
readonly pnlClass: readonly ["pnl-positive", "pnl-negative"];
|
|
12
|
+
};
|
|
13
|
+
export interface HostStore {
|
|
14
|
+
get(key: string, fallback: string | null): string | null;
|
|
15
|
+
set(key: string, value: string | null): void;
|
|
16
|
+
}
|
|
17
|
+
export interface TradingApi {
|
|
18
|
+
getExecutions(portfolioId: number, symbol: string | null, limit: number): Promise<TradeRow[]>;
|
|
19
|
+
searchInstruments(query: string): Promise<InstrumentRow[]>;
|
|
20
|
+
}
|
|
21
|
+
export declare const MarketDataLevels: {
|
|
22
|
+
readonly Quotes: "l1only";
|
|
23
|
+
readonly Tape: "tape";
|
|
24
|
+
readonly Full: "full";
|
|
25
|
+
};
|
|
26
|
+
export type MarketDataLevel = typeof MarketDataLevels[keyof typeof MarketDataLevels];
|
|
27
|
+
export interface MarketDataClient {
|
|
28
|
+
addSymbol(symbol: string, level: MarketDataLevel): Promise<unknown>;
|
|
29
|
+
removeSymbol(symbol: string): Promise<unknown>;
|
|
30
|
+
resubscribe(symbol: string, level: MarketDataLevel): Promise<void>;
|
|
31
|
+
getOrders(): OrderRow[];
|
|
32
|
+
}
|
|
33
|
+
export interface TradingContext {
|
|
34
|
+
readonly api: TradingApi;
|
|
35
|
+
readonly marketData: MarketDataClient;
|
|
36
|
+
portfolioId(): number | null;
|
|
37
|
+
pickInstrument(onPicked: (symbol: string) => void): void;
|
|
38
|
+
}
|
|
39
|
+
export interface TickerSink {
|
|
40
|
+
publish(symbols: string[], stats: Map<string, QuoteStats>): void;
|
|
41
|
+
}
|
|
42
|
+
export type TradingControl = object;
|
|
43
|
+
export interface TradingHost {
|
|
44
|
+
readonly isPrimary: boolean;
|
|
45
|
+
t(key: string, ...args: unknown[]): string;
|
|
46
|
+
readonly presentation: TradingPresentation;
|
|
47
|
+
readonly preferences: HostStore;
|
|
48
|
+
readonly cache: HostStore;
|
|
49
|
+
readonly trading: TradingContext;
|
|
50
|
+
readonly ticker: TickerSink;
|
|
51
|
+
allow(action: string): boolean;
|
|
52
|
+
log(message: string): void;
|
|
53
|
+
close(): void;
|
|
54
|
+
spawn(state: Record<string, unknown>): void;
|
|
55
|
+
persistState(patch: Record<string, unknown>): void;
|
|
56
|
+
saveLayout(): void;
|
|
57
|
+
register(control: TradingControl): void;
|
|
58
|
+
unregister(control: TradingControl): void;
|
|
59
|
+
broadcast<T>(apply: (control: T) => void): void;
|
|
60
|
+
}
|
|
61
|
+
export declare function assertHost(host: TradingHost, controlName: string): TradingHost;
|
|
62
|
+
//# sourceMappingURL=trading-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trading-host.d.ts","sourceRoot":"","sources":["../../src/trading-host.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAc1H,MAAM,WAAW,mBAAmB;IAEhC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IAIlC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzE,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;IAIxC,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IAInC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAOD,eAAO,MAAM,oBAAoB;;;CAGvB,CAAC;AAIX,MAAM,WAAW,SAAS;IAEtB,GAAG,CAAC,GAAG,EAA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ow, QuoteStats } from './trading-data.js';
|
|
3
|
+
import { DataGrid, GridColumn } from '@stocksharp/grids/data-grid';
|
|
4
|
+
export interface WatchlistDeps {
|
|
5
|
+
host: TradingHost;
|
|
6
|
+
onSelect(symbol: string): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class WatchlistWidget {
|
|
9
|
+
static FAVORITES_KEY: string;
|
|
10
|
+
static BASELINE_KEY_PREFIX: string;
|
|
11
|
+
static VISIBLE_CAP: number;
|
|
12
|
+
static RENDER_CAP: number;
|
|
13
|
+
static TYPE: "watchlist";
|
|
14
|
+
rootEl: HTMLElement;
|
|
15
|
+
api: TradingApi;
|
|
16
|
+
instruments: InstrumentRow[];
|
|
17
|
+
stats: Map<string, QuoteStats>;
|
|
18
|
+
favorites: Set<string>;
|
|
19
|
+
filter: string;
|
|
20
|
+
search: string;
|
|
21
|
+
currentSymbol: string | null;
|
|
22
|
+
wsClient: MarketDataClient;
|
|
23
|
+
bodyEl: HTMLElement | null;
|
|
24
|
+
searchEl: HTMLInputElement | null;
|
|
25
|
+
tabsEl: HTMLElement | null;
|
|
26
|
+
sortHeaderEl: HTMLElement | null;
|
|
27
|
+
_host: TradingHost;
|
|
28
|
+
_deps: WatchlistDeps;
|
|
29
|
+
_subscribedSyms: Set<string>;
|
|
30
|
+
_closeBtn: HTMLElement | null;
|
|
31
|
+
_exportBtn: HTMLElement | null;
|
|
32
|
+
_grid: DataGrid<InstrumentRow> | null;
|
|
33
|
+
static create(hostEl: HTMLElement, state: Record<string, unknown>, deps: WatchlistDeps): WatchlistWidget;
|
|
34
|
+
static _buildRoot(host: TradingHost): HTMLElement;
|
|
35
|
+
constructor(rootEl: HTMLElement, _state: Record<string, unknown>, deps: WatchlistDeps);
|
|
36
|
+
dispose(): void;
|
|
37
|
+
init(): Promise<void>;
|
|
38
|
+
_renderCategoryTabs(): void;
|
|
39
|
+
setCurrentSymbol(symbol: string | null): void;
|
|
40
|
+
onPriceUpdate(symbol: string, price: number): void;
|
|
41
|
+
static _baselineKey(symbol: string): string;
|
|
42
|
+
_bind(): void;
|
|
43
|
+
_filtered(): InstrumentRow[];
|
|
44
|
+
_render(): void;
|
|
45
|
+
_columns(): GridColumn<InstrumentRow>[];
|
|
46
|
+
_statsOf(instrument: InstrumentRow): QuoteStats;
|
|
47
|
+
_symbolCell(instrument: InstrumentRow): Node;
|
|
48
|
+
_export(): void;
|
|
49
|
+
_updateRow(symbol: string, prevPrice: number | null | undefined): void;
|
|
50
|
+
_toggleFavorite(symbol: string): void;
|
|
51
|
+
_loadFavorites(): string[];
|
|
52
|
+
_saveFavorites(): void;
|
|
53
|
+
_visible(): InstrumentRow[];
|
|
54
|
+
_syncSubs(): void;
|
|
55
|
+
_publishVisible(): void;
|
|
56
|
+
static _priceText(price: number | null | undefined): string;
|
|
57
|
+
static _changeText(chgPct: number | null | undefined): string;
|
|
58
|
+
static _changeClass(chgPct: number | null | undefined): string;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=watchlist-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watchlist-widget.d.ts","sourceRoot":"","sources":["../../src/watchlist-widget.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAoB,UAAU,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAC5G,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAK1E,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,qBAAa,eAAe;IACxB,MAAM,CAAC,aAAa,SAAkC;IAQtD,MAAM,CAAC,mBAAmB,SAAiB;IAC3C,MAAM,CAAC,WAAW,SAAM;IACxB,MAAM,CAAC,UAAU,SAAO;IACxB,MAAM,CAAC,IA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,GAAG,IAAI,GAAG,IAAI;IAQ7C,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IA6BlD,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAK3C,KAAK,IAAI,IAAI;IAsBb,SAAS,IAAI,aAAa,EAAE;IAyB5B,OAAO,IAAI,IAAI;IAOf,QAAQ,IAAI,UAAU,CAAC,aAAa,CAAC,EAAE;IAmCvC,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG,UAAU;IAM/C,WAAW,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI;IAwB5C,OAAO,IAAI,IAAI;IAMf,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;IAoBtE,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAarC,cAAc,IAAI,MAAM,EAAE;IAO1B,cAAc,IAAI,IAAI;IAQtB,QAAQ,IAAI,aAAa,EAAE;IAS3B,SAAS,IAAI,IAAI;IA6BjB,eAAe,IAAI,IAAI;IAKvB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;IAQ3D,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;IAM7D,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM;CAKjE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stocksharp/trading-controls",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Browser trading controls for StockSharp: order blotters, positions, trade history, watchlist and trade feed, each built against one host port and rendering its own DOM.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "StockSharp Platform LLC",
|
|
8
|
+
"url": "https://stocksharp.com/"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/StockSharp/JS-TradingControls.git"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/StockSharp/JS-TradingControls#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/StockSharp/JS-TradingControls/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"stocksharp",
|
|
20
|
+
"trading",
|
|
21
|
+
"terminal",
|
|
22
|
+
"blotter",
|
|
23
|
+
"positions",
|
|
24
|
+
"orders",
|
|
25
|
+
"watchlist",
|
|
26
|
+
"market-data",
|
|
27
|
+
"typescript",
|
|
28
|
+
"dom"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"sideEffects": [
|
|
32
|
+
"*.css"
|
|
33
|
+
],
|
|
34
|
+
"main": "./dist/esm/index.js",
|
|
35
|
+
"module": "./dist/esm/index.js",
|
|
36
|
+
"types": "./dist/types/index.d.ts",
|
|
37
|
+
"unpkg": "./dist/sstradingcontrols.js",
|
|
38
|
+
"jsdelivr": "./dist/sstradingcontrols.js",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/types/index.d.ts",
|
|
42
|
+
"import": "./dist/esm/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./trading-host": {
|
|
45
|
+
"types": "./dist/types/trading-host.d.ts",
|
|
46
|
+
"import": "./dist/esm/trading-host.js"
|
|
47
|
+
},
|
|
48
|
+
"./control-types": {
|
|
49
|
+
"types": "./dist/types/control-types.d.ts",
|
|
50
|
+
"import": "./dist/esm/control-types.js"
|
|
51
|
+
},
|
|
52
|
+
"./formatters": {
|
|
53
|
+
"types": "./dist/types/formatters.d.ts",
|
|
54
|
+
"import": "./dist/esm/formatters.js"
|
|
55
|
+
},
|
|
56
|
+
"./dom": {
|
|
57
|
+
"types": "./dist/types/dom.d.ts",
|
|
58
|
+
"import": "./dist/esm/dom.js"
|
|
59
|
+
},
|
|
60
|
+
"./positions-widget": {
|
|
61
|
+
"types": "./dist/types/positions-widget.d.ts",
|
|
62
|
+
"import": "./dist/esm/positions-widget.js"
|
|
63
|
+
},
|
|
64
|
+
"./trade-history-widget": {
|
|
65
|
+
"types": "./dist/types/trade-history-widget.d.ts",
|
|
66
|
+
"import": "./dist/esm/trade-history-widget.js"
|
|
67
|
+
},
|
|
68
|
+
"./active-orders-widget": {
|
|
69
|
+
"types": "./dist/types/active-orders-widget.d.ts",
|
|
70
|
+
"import": "./dist/esm/active-orders-widget.js"
|
|
71
|
+
},
|
|
72
|
+
"./watchlist-widget": {
|
|
73
|
+
"types": "./dist/types/watchlist-widget.d.ts",
|
|
74
|
+
"import": "./dist/esm/watchlist-widget.js"
|
|
75
|
+
},
|
|
76
|
+
"./source": "./src/index.ts",
|
|
77
|
+
"./source/trading-host": "./src/trading-host.ts",
|
|
78
|
+
"./source/control-types": "./src/control-types.ts",
|
|
79
|
+
"./source/formatters": "./src/formatters.ts",
|
|
80
|
+
"./source/dom": "./src/dom.ts",
|
|
81
|
+
"./source/positions-widget": "./src/positions-widget.ts",
|
|
82
|
+
"./source/trade-history-widget": "./src/trade-history-widget.ts",
|
|
83
|
+
"./source/active-orders-widget": "./src/active-orders-widget.ts",
|
|
84
|
+
"./source/watchlist-widget": "./src/watchlist-widget.ts",
|
|
85
|
+
"./styles.css": "./styles/trading-controls.css",
|
|
86
|
+
"./theme.css": "./styles/theme.css",
|
|
87
|
+
"./translation-keys.json": "./translation-keys.json",
|
|
88
|
+
"./package.json": "./package.json"
|
|
89
|
+
},
|
|
90
|
+
"files": [
|
|
91
|
+
"dist",
|
|
92
|
+
"src",
|
|
93
|
+
"styles",
|
|
94
|
+
"translation-keys.json",
|
|
95
|
+
"LICENSE",
|
|
96
|
+
"NOTICE",
|
|
97
|
+
"README.md"
|
|
98
|
+
],
|
|
99
|
+
"publishConfig": {
|
|
100
|
+
"access": "public",
|
|
101
|
+
"provenance": true,
|
|
102
|
+
"registry": "https://registry.npmjs.org/"
|
|
103
|
+
},
|
|
104
|
+
"scripts": {
|
|
105
|
+
"build": "node build.mjs",
|
|
106
|
+
"prepack": "npm run build",
|
|
107
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
108
|
+
"api:check": "node tools/check-public-api.mjs",
|
|
109
|
+
"api:update": "node tools/check-public-api.mjs --update",
|
|
110
|
+
"css:check": "node tools/check-style-contract.mjs",
|
|
111
|
+
"i18n:check": "node tools/check-translation-keys.mjs",
|
|
112
|
+
"i18n:update": "node tools/check-translation-keys.mjs --update",
|
|
113
|
+
"build:tests": "node build-tests.mjs",
|
|
114
|
+
"test": "npm run typecheck && npm run api:check && npm run css:check && npm run i18n:check && npm run build:tests && node --test \"tests/_dist/**/*.test.cjs\"",
|
|
115
|
+
"pack:check": "npm pack --dry-run",
|
|
116
|
+
"release:check": "node tools/check-release-tag.mjs",
|
|
117
|
+
"release:patch": "npm version patch -m \"chore: release v%s\"",
|
|
118
|
+
"release:minor": "npm version minor -m \"chore: release v%s\"",
|
|
119
|
+
"release:major": "npm version major -m \"chore: release v%s\""
|
|
120
|
+
},
|
|
121
|
+
"dependencies": {
|
|
122
|
+
"@stocksharp/grids": "^0.1.1"
|
|
123
|
+
},
|
|
124
|
+
"devDependencies": {
|
|
125
|
+
"@types/node": "^24.0.0",
|
|
126
|
+
"esbuild": "^0.25.0",
|
|
127
|
+
"typescript": "^5.8.0"
|
|
128
|
+
}
|
|
129
|
+
}
|