backtest-kit 3.0.0 → 3.0.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.
- package/build/index.cjs +2116 -947
- package/build/index.mjs +2114 -948
- package/package.json +1 -1
- package/types.d.ts +396 -117
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -8710,6 +8710,71 @@ declare class PersistStorageUtils {
|
|
|
8710
8710
|
* Used by SignalLiveUtils for signal storage persistence.
|
|
8711
8711
|
*/
|
|
8712
8712
|
declare const PersistStorageAdapter: PersistStorageUtils;
|
|
8713
|
+
/**
|
|
8714
|
+
* Type for persisted notification data.
|
|
8715
|
+
* Each notification is stored as a separate file keyed by its id.
|
|
8716
|
+
*/
|
|
8717
|
+
type NotificationData = NotificationModel[];
|
|
8718
|
+
/**
|
|
8719
|
+
* Utility class for managing notification persistence.
|
|
8720
|
+
*
|
|
8721
|
+
* Features:
|
|
8722
|
+
* - Memoized storage instances
|
|
8723
|
+
* - Custom adapter support
|
|
8724
|
+
* - Atomic read/write operations for NotificationData
|
|
8725
|
+
* - Each notification stored as separate file keyed by id
|
|
8726
|
+
* - Crash-safe notification state management
|
|
8727
|
+
*
|
|
8728
|
+
* Used by NotificationPersistLiveUtils/NotificationPersistBacktestUtils for persistence.
|
|
8729
|
+
*/
|
|
8730
|
+
declare class PersistNotificationUtils {
|
|
8731
|
+
private PersistNotificationFactory;
|
|
8732
|
+
private getNotificationStorage;
|
|
8733
|
+
/**
|
|
8734
|
+
* Registers a custom persistence adapter.
|
|
8735
|
+
*
|
|
8736
|
+
* @param Ctor - Custom PersistBase constructor
|
|
8737
|
+
*/
|
|
8738
|
+
usePersistNotificationAdapter(Ctor: TPersistBaseCtor<string, NotificationModel>): void;
|
|
8739
|
+
/**
|
|
8740
|
+
* Reads persisted notifications data.
|
|
8741
|
+
*
|
|
8742
|
+
* Called by NotificationPersistLiveUtils/NotificationPersistBacktestUtils.waitForInit() to restore state.
|
|
8743
|
+
* Uses keys() from PersistBase to iterate over all stored notifications.
|
|
8744
|
+
* Returns empty array if no notifications exist.
|
|
8745
|
+
*
|
|
8746
|
+
* @param backtest - If true, reads from backtest storage; otherwise from live storage
|
|
8747
|
+
* @returns Promise resolving to array of notification entries
|
|
8748
|
+
*/
|
|
8749
|
+
readNotificationData: (backtest: boolean) => Promise<NotificationData>;
|
|
8750
|
+
/**
|
|
8751
|
+
* Writes notification data to disk with atomic file writes.
|
|
8752
|
+
*
|
|
8753
|
+
* Called by NotificationPersistLiveUtils/NotificationPersistBacktestUtils after notification changes to persist state.
|
|
8754
|
+
* Uses notification.id as the storage key for individual file storage.
|
|
8755
|
+
* Uses atomic writes to prevent corruption on crashes.
|
|
8756
|
+
*
|
|
8757
|
+
* @param notificationData - Notification entries to persist
|
|
8758
|
+
* @param backtest - If true, writes to backtest storage; otherwise to live storage
|
|
8759
|
+
* @returns Promise that resolves when write is complete
|
|
8760
|
+
*/
|
|
8761
|
+
writeNotificationData: (notificationData: NotificationData, backtest: boolean) => Promise<void>;
|
|
8762
|
+
/**
|
|
8763
|
+
* Switches to the default JSON persist adapter.
|
|
8764
|
+
* All future persistence writes will use JSON storage.
|
|
8765
|
+
*/
|
|
8766
|
+
useJson(): void;
|
|
8767
|
+
/**
|
|
8768
|
+
* Switches to a dummy persist adapter that discards all writes.
|
|
8769
|
+
* All future persistence writes will be no-ops.
|
|
8770
|
+
*/
|
|
8771
|
+
useDummy(): void;
|
|
8772
|
+
}
|
|
8773
|
+
/**
|
|
8774
|
+
* Global singleton instance of PersistNotificationUtils.
|
|
8775
|
+
* Used by NotificationPersistLiveUtils/NotificationPersistBacktestUtils for notification persistence.
|
|
8776
|
+
*/
|
|
8777
|
+
declare const PersistNotificationAdapter: PersistNotificationUtils;
|
|
8713
8778
|
|
|
8714
8779
|
declare const WAIT_FOR_INIT_SYMBOL$1: unique symbol;
|
|
8715
8780
|
declare const WRITE_SAFE_SYMBOL$1: unique symbol;
|
|
@@ -13333,6 +13398,336 @@ declare const StorageLive: StorageLiveAdapter;
|
|
|
13333
13398
|
*/
|
|
13334
13399
|
declare const StorageBacktest: StorageBacktestAdapter;
|
|
13335
13400
|
|
|
13401
|
+
/**
|
|
13402
|
+
* Base interface for notification adapters.
|
|
13403
|
+
* All notification adapters must implement this interface.
|
|
13404
|
+
*/
|
|
13405
|
+
interface INotificationUtils {
|
|
13406
|
+
/**
|
|
13407
|
+
* Handles signal events (opened, closed, scheduled, cancelled).
|
|
13408
|
+
* @param data - The strategy tick result data
|
|
13409
|
+
*/
|
|
13410
|
+
handleSignal(data: IStrategyTickResult): Promise<void>;
|
|
13411
|
+
/**
|
|
13412
|
+
* Handles partial profit availability event.
|
|
13413
|
+
* @param data - The partial profit contract data
|
|
13414
|
+
*/
|
|
13415
|
+
handlePartialProfit(data: PartialProfitContract): Promise<void>;
|
|
13416
|
+
/**
|
|
13417
|
+
* Handles partial loss availability event.
|
|
13418
|
+
* @param data - The partial loss contract data
|
|
13419
|
+
*/
|
|
13420
|
+
handlePartialLoss(data: PartialLossContract): Promise<void>;
|
|
13421
|
+
/**
|
|
13422
|
+
* Handles breakeven availability event.
|
|
13423
|
+
* @param data - The breakeven contract data
|
|
13424
|
+
*/
|
|
13425
|
+
handleBreakeven(data: BreakevenContract): Promise<void>;
|
|
13426
|
+
/**
|
|
13427
|
+
* Handles strategy commit events (partial-profit, breakeven, trailing, etc.).
|
|
13428
|
+
* @param data - The strategy commit contract data
|
|
13429
|
+
*/
|
|
13430
|
+
handleStrategyCommit(data: StrategyCommitContract): Promise<void>;
|
|
13431
|
+
/**
|
|
13432
|
+
* Handles risk rejection event.
|
|
13433
|
+
* @param data - The risk contract data
|
|
13434
|
+
*/
|
|
13435
|
+
handleRisk(data: RiskContract): Promise<void>;
|
|
13436
|
+
/**
|
|
13437
|
+
* Handles error event.
|
|
13438
|
+
* @param error - The error object
|
|
13439
|
+
*/
|
|
13440
|
+
handleError(error: Error): Promise<void>;
|
|
13441
|
+
/**
|
|
13442
|
+
* Handles critical error event.
|
|
13443
|
+
* @param error - The error object
|
|
13444
|
+
*/
|
|
13445
|
+
handleCriticalError(error: Error): Promise<void>;
|
|
13446
|
+
/**
|
|
13447
|
+
* Handles validation error event.
|
|
13448
|
+
* @param error - The error object
|
|
13449
|
+
*/
|
|
13450
|
+
handleValidationError(error: Error): Promise<void>;
|
|
13451
|
+
/**
|
|
13452
|
+
* Gets all stored notifications.
|
|
13453
|
+
* @returns Array of all notification models
|
|
13454
|
+
*/
|
|
13455
|
+
getData(): Promise<NotificationModel[]>;
|
|
13456
|
+
/**
|
|
13457
|
+
* Clears all stored notifications.
|
|
13458
|
+
*/
|
|
13459
|
+
clear(): Promise<void>;
|
|
13460
|
+
}
|
|
13461
|
+
/**
|
|
13462
|
+
* Constructor type for notification adapters.
|
|
13463
|
+
* Used for custom notification implementations.
|
|
13464
|
+
*/
|
|
13465
|
+
type TNotificationUtilsCtor = new () => INotificationUtils;
|
|
13466
|
+
/**
|
|
13467
|
+
* Backtest notification adapter with pluggable notification backend.
|
|
13468
|
+
*
|
|
13469
|
+
* Features:
|
|
13470
|
+
* - Adapter pattern for swappable notification implementations
|
|
13471
|
+
* - Default adapter: NotificationMemoryBacktestUtils (in-memory storage)
|
|
13472
|
+
* - Alternative adapters: NotificationPersistBacktestUtils, NotificationDummyBacktestUtils
|
|
13473
|
+
* - Convenience methods: usePersist(), useMemory(), useDummy()
|
|
13474
|
+
*/
|
|
13475
|
+
declare class NotificationBacktestAdapter implements INotificationUtils {
|
|
13476
|
+
/** Internal notification utils instance */
|
|
13477
|
+
private _notificationBacktestUtils;
|
|
13478
|
+
/**
|
|
13479
|
+
* Handles signal events.
|
|
13480
|
+
* Proxies call to the underlying notification adapter.
|
|
13481
|
+
* @param data - The strategy tick result data
|
|
13482
|
+
*/
|
|
13483
|
+
handleSignal: (data: IStrategyTickResult) => Promise<void>;
|
|
13484
|
+
/**
|
|
13485
|
+
* Handles partial profit availability event.
|
|
13486
|
+
* Proxies call to the underlying notification adapter.
|
|
13487
|
+
* @param data - The partial profit contract data
|
|
13488
|
+
*/
|
|
13489
|
+
handlePartialProfit: (data: PartialProfitContract) => Promise<void>;
|
|
13490
|
+
/**
|
|
13491
|
+
* Handles partial loss availability event.
|
|
13492
|
+
* Proxies call to the underlying notification adapter.
|
|
13493
|
+
* @param data - The partial loss contract data
|
|
13494
|
+
*/
|
|
13495
|
+
handlePartialLoss: (data: PartialLossContract) => Promise<void>;
|
|
13496
|
+
/**
|
|
13497
|
+
* Handles breakeven availability event.
|
|
13498
|
+
* Proxies call to the underlying notification adapter.
|
|
13499
|
+
* @param data - The breakeven contract data
|
|
13500
|
+
*/
|
|
13501
|
+
handleBreakeven: (data: BreakevenContract) => Promise<void>;
|
|
13502
|
+
/**
|
|
13503
|
+
* Handles strategy commit events.
|
|
13504
|
+
* Proxies call to the underlying notification adapter.
|
|
13505
|
+
* @param data - The strategy commit contract data
|
|
13506
|
+
*/
|
|
13507
|
+
handleStrategyCommit: (data: StrategyCommitContract) => Promise<void>;
|
|
13508
|
+
/**
|
|
13509
|
+
* Handles risk rejection event.
|
|
13510
|
+
* Proxies call to the underlying notification adapter.
|
|
13511
|
+
* @param data - The risk contract data
|
|
13512
|
+
*/
|
|
13513
|
+
handleRisk: (data: RiskContract) => Promise<void>;
|
|
13514
|
+
/**
|
|
13515
|
+
* Handles error event.
|
|
13516
|
+
* Proxies call to the underlying notification adapter.
|
|
13517
|
+
* @param error - The error object
|
|
13518
|
+
*/
|
|
13519
|
+
handleError: (error: Error) => Promise<void>;
|
|
13520
|
+
/**
|
|
13521
|
+
* Handles critical error event.
|
|
13522
|
+
* Proxies call to the underlying notification adapter.
|
|
13523
|
+
* @param error - The error object
|
|
13524
|
+
*/
|
|
13525
|
+
handleCriticalError: (error: Error) => Promise<void>;
|
|
13526
|
+
/**
|
|
13527
|
+
* Handles validation error event.
|
|
13528
|
+
* Proxies call to the underlying notification adapter.
|
|
13529
|
+
* @param error - The error object
|
|
13530
|
+
*/
|
|
13531
|
+
handleValidationError: (error: Error) => Promise<void>;
|
|
13532
|
+
/**
|
|
13533
|
+
* Gets all stored notifications.
|
|
13534
|
+
* Proxies call to the underlying notification adapter.
|
|
13535
|
+
* @returns Array of all notification models
|
|
13536
|
+
*/
|
|
13537
|
+
getData: () => Promise<NotificationModel[]>;
|
|
13538
|
+
/**
|
|
13539
|
+
* Clears all stored notifications.
|
|
13540
|
+
* Proxies call to the underlying notification adapter.
|
|
13541
|
+
*/
|
|
13542
|
+
clear: () => Promise<void>;
|
|
13543
|
+
/**
|
|
13544
|
+
* Sets the notification adapter constructor.
|
|
13545
|
+
* All future notification operations will use this adapter.
|
|
13546
|
+
*
|
|
13547
|
+
* @param Ctor - Constructor for notification adapter
|
|
13548
|
+
*/
|
|
13549
|
+
useNotificationAdapter: (Ctor: TNotificationUtilsCtor) => void;
|
|
13550
|
+
/**
|
|
13551
|
+
* Switches to dummy notification adapter.
|
|
13552
|
+
* All future notification writes will be no-ops.
|
|
13553
|
+
*/
|
|
13554
|
+
useDummy: () => void;
|
|
13555
|
+
/**
|
|
13556
|
+
* Switches to in-memory notification adapter (default).
|
|
13557
|
+
* Notifications will be stored in memory only.
|
|
13558
|
+
*/
|
|
13559
|
+
useMemory: () => void;
|
|
13560
|
+
/**
|
|
13561
|
+
* Switches to persistent notification adapter.
|
|
13562
|
+
* Notifications will be persisted to disk.
|
|
13563
|
+
*/
|
|
13564
|
+
usePersist: () => void;
|
|
13565
|
+
}
|
|
13566
|
+
/**
|
|
13567
|
+
* Live trading notification adapter with pluggable notification backend.
|
|
13568
|
+
*
|
|
13569
|
+
* Features:
|
|
13570
|
+
* - Adapter pattern for swappable notification implementations
|
|
13571
|
+
* - Default adapter: NotificationMemoryLiveUtils (in-memory storage)
|
|
13572
|
+
* - Alternative adapters: NotificationPersistLiveUtils, NotificationDummyLiveUtils
|
|
13573
|
+
* - Convenience methods: usePersist(), useMemory(), useDummy()
|
|
13574
|
+
*/
|
|
13575
|
+
declare class NotificationLiveAdapter implements INotificationUtils {
|
|
13576
|
+
/** Internal notification utils instance */
|
|
13577
|
+
private _notificationLiveUtils;
|
|
13578
|
+
/**
|
|
13579
|
+
* Handles signal events.
|
|
13580
|
+
* Proxies call to the underlying notification adapter.
|
|
13581
|
+
* @param data - The strategy tick result data
|
|
13582
|
+
*/
|
|
13583
|
+
handleSignal: (data: IStrategyTickResult) => Promise<void>;
|
|
13584
|
+
/**
|
|
13585
|
+
* Handles partial profit availability event.
|
|
13586
|
+
* Proxies call to the underlying notification adapter.
|
|
13587
|
+
* @param data - The partial profit contract data
|
|
13588
|
+
*/
|
|
13589
|
+
handlePartialProfit: (data: PartialProfitContract) => Promise<void>;
|
|
13590
|
+
/**
|
|
13591
|
+
* Handles partial loss availability event.
|
|
13592
|
+
* Proxies call to the underlying notification adapter.
|
|
13593
|
+
* @param data - The partial loss contract data
|
|
13594
|
+
*/
|
|
13595
|
+
handlePartialLoss: (data: PartialLossContract) => Promise<void>;
|
|
13596
|
+
/**
|
|
13597
|
+
* Handles breakeven availability event.
|
|
13598
|
+
* Proxies call to the underlying notification adapter.
|
|
13599
|
+
* @param data - The breakeven contract data
|
|
13600
|
+
*/
|
|
13601
|
+
handleBreakeven: (data: BreakevenContract) => Promise<void>;
|
|
13602
|
+
/**
|
|
13603
|
+
* Handles strategy commit events.
|
|
13604
|
+
* Proxies call to the underlying notification adapter.
|
|
13605
|
+
* @param data - The strategy commit contract data
|
|
13606
|
+
*/
|
|
13607
|
+
handleStrategyCommit: (data: StrategyCommitContract) => Promise<void>;
|
|
13608
|
+
/**
|
|
13609
|
+
* Handles risk rejection event.
|
|
13610
|
+
* Proxies call to the underlying notification adapter.
|
|
13611
|
+
* @param data - The risk contract data
|
|
13612
|
+
*/
|
|
13613
|
+
handleRisk: (data: RiskContract) => Promise<void>;
|
|
13614
|
+
/**
|
|
13615
|
+
* Handles error event.
|
|
13616
|
+
* Proxies call to the underlying notification adapter.
|
|
13617
|
+
* @param error - The error object
|
|
13618
|
+
*/
|
|
13619
|
+
handleError: (error: Error) => Promise<void>;
|
|
13620
|
+
/**
|
|
13621
|
+
* Handles critical error event.
|
|
13622
|
+
* Proxies call to the underlying notification adapter.
|
|
13623
|
+
* @param error - The error object
|
|
13624
|
+
*/
|
|
13625
|
+
handleCriticalError: (error: Error) => Promise<void>;
|
|
13626
|
+
/**
|
|
13627
|
+
* Handles validation error event.
|
|
13628
|
+
* Proxies call to the underlying notification adapter.
|
|
13629
|
+
* @param error - The error object
|
|
13630
|
+
*/
|
|
13631
|
+
handleValidationError: (error: Error) => Promise<void>;
|
|
13632
|
+
/**
|
|
13633
|
+
* Gets all stored notifications.
|
|
13634
|
+
* Proxies call to the underlying notification adapter.
|
|
13635
|
+
* @returns Array of all notification models
|
|
13636
|
+
*/
|
|
13637
|
+
getData: () => Promise<NotificationModel[]>;
|
|
13638
|
+
/**
|
|
13639
|
+
* Clears all stored notifications.
|
|
13640
|
+
* Proxies call to the underlying notification adapter.
|
|
13641
|
+
*/
|
|
13642
|
+
clear: () => Promise<void>;
|
|
13643
|
+
/**
|
|
13644
|
+
* Sets the notification adapter constructor.
|
|
13645
|
+
* All future notification operations will use this adapter.
|
|
13646
|
+
*
|
|
13647
|
+
* @param Ctor - Constructor for notification adapter
|
|
13648
|
+
*/
|
|
13649
|
+
useNotificationAdapter: (Ctor: TNotificationUtilsCtor) => void;
|
|
13650
|
+
/**
|
|
13651
|
+
* Switches to dummy notification adapter.
|
|
13652
|
+
* All future notification writes will be no-ops.
|
|
13653
|
+
*/
|
|
13654
|
+
useDummy: () => void;
|
|
13655
|
+
/**
|
|
13656
|
+
* Switches to in-memory notification adapter (default).
|
|
13657
|
+
* Notifications will be stored in memory only.
|
|
13658
|
+
*/
|
|
13659
|
+
useMemory: () => void;
|
|
13660
|
+
/**
|
|
13661
|
+
* Switches to persistent notification adapter.
|
|
13662
|
+
* Notifications will be persisted to disk.
|
|
13663
|
+
*/
|
|
13664
|
+
usePersist: () => void;
|
|
13665
|
+
}
|
|
13666
|
+
/**
|
|
13667
|
+
* Main notification adapter that manages both backtest and live notification storage.
|
|
13668
|
+
*
|
|
13669
|
+
* Features:
|
|
13670
|
+
* - Subscribes to signal emitters for automatic notification updates
|
|
13671
|
+
* - Provides unified access to both backtest and live notifications
|
|
13672
|
+
* - Singleshot enable pattern prevents duplicate subscriptions
|
|
13673
|
+
* - Cleanup function for proper unsubscription
|
|
13674
|
+
*/
|
|
13675
|
+
declare class NotificationAdapter {
|
|
13676
|
+
/**
|
|
13677
|
+
* Enables notification storage by subscribing to signal emitters.
|
|
13678
|
+
* Uses singleshot to ensure one-time subscription.
|
|
13679
|
+
*
|
|
13680
|
+
* @returns Cleanup function that unsubscribes from all emitters
|
|
13681
|
+
*/
|
|
13682
|
+
enable: (() => () => void) & functools_kit.ISingleshotClearable;
|
|
13683
|
+
/**
|
|
13684
|
+
* Disables notification storage by unsubscribing from all emitters.
|
|
13685
|
+
* Safe to call multiple times.
|
|
13686
|
+
*/
|
|
13687
|
+
disable: () => void;
|
|
13688
|
+
/**
|
|
13689
|
+
* Gets all backtest notifications from storage.
|
|
13690
|
+
*
|
|
13691
|
+
* @returns Array of all backtest notification models
|
|
13692
|
+
* @throws Error if NotificationAdapter is not enabled
|
|
13693
|
+
*/
|
|
13694
|
+
getDataBacktest: () => Promise<NotificationModel[]>;
|
|
13695
|
+
/**
|
|
13696
|
+
* Gets all live notifications from storage.
|
|
13697
|
+
*
|
|
13698
|
+
* @returns Array of all live notification models
|
|
13699
|
+
* @throws Error if NotificationAdapter is not enabled
|
|
13700
|
+
*/
|
|
13701
|
+
getDataLive: () => Promise<NotificationModel[]>;
|
|
13702
|
+
/**
|
|
13703
|
+
* Clears all backtest notifications from storage.
|
|
13704
|
+
*
|
|
13705
|
+
* @throws Error if NotificationAdapter is not enabled
|
|
13706
|
+
*/
|
|
13707
|
+
clearBacktest: () => Promise<void>;
|
|
13708
|
+
/**
|
|
13709
|
+
* Clears all live notifications from storage.
|
|
13710
|
+
*
|
|
13711
|
+
* @throws Error if NotificationAdapter is not enabled
|
|
13712
|
+
*/
|
|
13713
|
+
clearLive: () => Promise<void>;
|
|
13714
|
+
}
|
|
13715
|
+
/**
|
|
13716
|
+
* Global singleton instance of NotificationAdapter.
|
|
13717
|
+
* Provides unified notification management for backtest and live trading.
|
|
13718
|
+
*/
|
|
13719
|
+
declare const Notification: NotificationAdapter;
|
|
13720
|
+
/**
|
|
13721
|
+
* Global singleton instance of NotificationLiveAdapter.
|
|
13722
|
+
* Provides live trading notification storage with pluggable backends.
|
|
13723
|
+
*/
|
|
13724
|
+
declare const NotificationLive: NotificationLiveAdapter;
|
|
13725
|
+
/**
|
|
13726
|
+
* Global singleton instance of NotificationBacktestAdapter.
|
|
13727
|
+
* Provides backtest notification storage with pluggable backends.
|
|
13728
|
+
*/
|
|
13729
|
+
declare const NotificationBacktest: NotificationBacktestAdapter;
|
|
13730
|
+
|
|
13336
13731
|
/**
|
|
13337
13732
|
* Utility class for exchange operations.
|
|
13338
13733
|
*
|
|
@@ -13597,122 +13992,6 @@ declare class CacheUtils {
|
|
|
13597
13992
|
*/
|
|
13598
13993
|
declare const Cache: CacheUtils;
|
|
13599
13994
|
|
|
13600
|
-
/**
|
|
13601
|
-
* Public facade for notification operations.
|
|
13602
|
-
*
|
|
13603
|
-
* Automatically subscribes on first use and provides simplified access to notification instance methods.
|
|
13604
|
-
*
|
|
13605
|
-
* @example
|
|
13606
|
-
* ```typescript
|
|
13607
|
-
* import { Notification } from "./classes/Notification";
|
|
13608
|
-
*
|
|
13609
|
-
* // Get all notifications (auto-subscribes if not subscribed)
|
|
13610
|
-
* const all = await Notification.getData();
|
|
13611
|
-
*
|
|
13612
|
-
* // Process notifications with type discrimination
|
|
13613
|
-
* all.forEach(notification => {
|
|
13614
|
-
* switch (notification.type) {
|
|
13615
|
-
* case "signal.closed":
|
|
13616
|
-
* console.log(`Closed: ${notification.pnlPercentage}%`);
|
|
13617
|
-
* break;
|
|
13618
|
-
* case "partial.loss":
|
|
13619
|
-
* if (notification.level >= 30) {
|
|
13620
|
-
* alert("High loss!");
|
|
13621
|
-
* }
|
|
13622
|
-
* break;
|
|
13623
|
-
* case "risk.rejection":
|
|
13624
|
-
* console.warn(notification.rejectionNote);
|
|
13625
|
-
* break;
|
|
13626
|
-
* }
|
|
13627
|
-
* });
|
|
13628
|
-
*
|
|
13629
|
-
* // Clear history
|
|
13630
|
-
* await Notification.clear();
|
|
13631
|
-
*
|
|
13632
|
-
* // Unsubscribe when done
|
|
13633
|
-
* await Notification.unsubscribe();
|
|
13634
|
-
* ```
|
|
13635
|
-
*/
|
|
13636
|
-
declare class NotificationUtils {
|
|
13637
|
-
/** Internal instance containing business logic */
|
|
13638
|
-
private _instance;
|
|
13639
|
-
/**
|
|
13640
|
-
* Returns all notifications in chronological order (newest first).
|
|
13641
|
-
* Automatically subscribes to emitters if not already subscribed.
|
|
13642
|
-
*
|
|
13643
|
-
* @returns Array of strongly-typed notification objects
|
|
13644
|
-
*
|
|
13645
|
-
* @example
|
|
13646
|
-
* ```typescript
|
|
13647
|
-
* const notifications = await Notification.getData();
|
|
13648
|
-
*
|
|
13649
|
-
* notifications.forEach(notification => {
|
|
13650
|
-
* switch (notification.type) {
|
|
13651
|
-
* case "signal.closed":
|
|
13652
|
-
* console.log(`${notification.symbol}: ${notification.pnlPercentage}%`);
|
|
13653
|
-
* break;
|
|
13654
|
-
* case "partial.loss":
|
|
13655
|
-
* if (notification.level >= 30) {
|
|
13656
|
-
* console.warn(`High loss: ${notification.symbol}`);
|
|
13657
|
-
* }
|
|
13658
|
-
* break;
|
|
13659
|
-
* }
|
|
13660
|
-
* });
|
|
13661
|
-
* ```
|
|
13662
|
-
*/
|
|
13663
|
-
getData(): Promise<NotificationModel[]>;
|
|
13664
|
-
/**
|
|
13665
|
-
* Clears all notification history.
|
|
13666
|
-
* Automatically subscribes to emitters if not already subscribed.
|
|
13667
|
-
*
|
|
13668
|
-
* @example
|
|
13669
|
-
* ```typescript
|
|
13670
|
-
* await Notification.clear();
|
|
13671
|
-
* ```
|
|
13672
|
-
*/
|
|
13673
|
-
clear(): Promise<void>;
|
|
13674
|
-
/**
|
|
13675
|
-
* Unsubscribes from all notification emitters.
|
|
13676
|
-
* Call this when you no longer need to collect notifications.
|
|
13677
|
-
*
|
|
13678
|
-
* @example
|
|
13679
|
-
* ```typescript
|
|
13680
|
-
* await Notification.unsubscribe();
|
|
13681
|
-
* ```
|
|
13682
|
-
*/
|
|
13683
|
-
enable(): Promise<void>;
|
|
13684
|
-
/**
|
|
13685
|
-
* Unsubscribes from all notification emitters.
|
|
13686
|
-
* Call this when you no longer need to collect notifications.
|
|
13687
|
-
* @example
|
|
13688
|
-
* ```typescript
|
|
13689
|
-
* await Notification.unsubscribe();
|
|
13690
|
-
* ```
|
|
13691
|
-
*/
|
|
13692
|
-
disable(): Promise<void>;
|
|
13693
|
-
}
|
|
13694
|
-
/**
|
|
13695
|
-
* Singleton instance of NotificationUtils for convenient notification access.
|
|
13696
|
-
*
|
|
13697
|
-
* @example
|
|
13698
|
-
* ```typescript
|
|
13699
|
-
* import { Notification } from "./classes/Notification";
|
|
13700
|
-
*
|
|
13701
|
-
* // Get all notifications
|
|
13702
|
-
* const all = await Notification.getData();
|
|
13703
|
-
*
|
|
13704
|
-
* // Filter by type using type discrimination
|
|
13705
|
-
* const closedSignals = all.filter(n => n.type === "signal.closed");
|
|
13706
|
-
* const highLosses = all.filter(n =>
|
|
13707
|
-
* n.type === "partial.loss" && n.level >= 30
|
|
13708
|
-
* );
|
|
13709
|
-
*
|
|
13710
|
-
* // Clear history
|
|
13711
|
-
* await Notification.clear();
|
|
13712
|
-
* ```
|
|
13713
|
-
*/
|
|
13714
|
-
declare const Notification: NotificationUtils;
|
|
13715
|
-
|
|
13716
13995
|
/**
|
|
13717
13996
|
* Type alias for column configuration used in breakeven markdown reports.
|
|
13718
13997
|
*
|
|
@@ -20456,4 +20735,4 @@ declare const backtest: {
|
|
|
20456
20735
|
loggerService: LoggerService;
|
|
20457
20736
|
};
|
|
20458
20737
|
|
|
20459
|
-
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
|
|
20738
|
+
export { ActionBase, type ActivateScheduledCommit, type ActivateScheduledCommitNotification, type ActivePingContract, Backtest, type BacktestStatisticsModel, Breakeven, type BreakevenAvailableNotification, type BreakevenCommit, type BreakevenCommitNotification, type BreakevenContract, type BreakevenData, Cache, type CancelScheduledCommit, type CandleData, type CandleInterval, type ClosePendingCommit, type ColumnConfig, type ColumnModel, Constant, type CriticalErrorNotification, type DoneContract, type EntityId, Exchange, ExecutionContextService, type FrameInterval, type GlobalConfig, Heat, type HeatmapStatisticsModel, type IActivateScheduledCommitRow, type IBidData, type IBreakevenCommitRow, type ICandleData, type ICommitRow, type IExchangeSchema, type IFrameSchema, type IHeatmapRow, type IMarkdownDumpOptions, type INotificationUtils, type IOrderBookData, type IPartialLossCommitRow, type IPartialProfitCommitRow, type IPersistBase, type IPositionSizeATRParams, type IPositionSizeFixedPercentageParams, type IPositionSizeKellyParams, type IPublicSignalRow, type IReportDumpOptions, type IRiskActivePosition, type IRiskCheckArgs, type IRiskSchema, type IRiskSignalRow, type IRiskValidation, type IRiskValidationFn, type IRiskValidationPayload, type IScheduledSignalCancelRow, type IScheduledSignalRow, type ISignalDto, type ISignalRow, type ISizingCalculateParams, type ISizingCalculateParamsATR, type ISizingCalculateParamsFixedPercentage, type ISizingCalculateParamsKelly, type ISizingParams, type ISizingParamsATR, type ISizingParamsFixedPercentage, type ISizingParamsKelly, type ISizingSchema, type ISizingSchemaATR, type ISizingSchemaFixedPercentage, type ISizingSchemaKelly, type IStorageSignalRow, type IStorageUtils, type IStrategyPnL, type IStrategyResult, type IStrategySchema, type IStrategyTickResult, type IStrategyTickResultActive, type IStrategyTickResultCancelled, type IStrategyTickResultClosed, type IStrategyTickResultIdle, type IStrategyTickResultOpened, type IStrategyTickResultScheduled, type IStrategyTickResultWaiting, type ITrailingStopCommitRow, type ITrailingTakeCommitRow, type IWalkerResults, type IWalkerSchema, type IWalkerStrategyResult, type InfoErrorNotification, Live, type LiveStatisticsModel, Markdown, MarkdownFileBase, MarkdownFolderBase, type MarkdownName, MethodContextService, type MetricStats, Notification, NotificationBacktest, type NotificationData, NotificationLive, type NotificationModel, Partial$1 as Partial, type PartialData, type PartialEvent, type PartialLossAvailableNotification, type PartialLossCommit, type PartialLossCommitNotification, type PartialLossContract, type PartialProfitAvailableNotification, type PartialProfitCommit, type PartialProfitCommitNotification, type PartialProfitContract, type PartialStatisticsModel, Performance, type PerformanceContract, type PerformanceMetricType, type PerformanceStatisticsModel, PersistBase, PersistBreakevenAdapter, PersistCandleAdapter, PersistNotificationAdapter, PersistPartialAdapter, PersistRiskAdapter, PersistScheduleAdapter, PersistSignalAdapter, PersistStorageAdapter, PositionSize, type ProgressBacktestContract, type ProgressWalkerContract, Report, ReportBase, type ReportName, Risk, type RiskContract, type RiskData, type RiskEvent, type RiskRejectionNotification, type RiskStatisticsModel, Schedule, type ScheduleData, type SchedulePingContract, type ScheduleStatisticsModel, type ScheduledEvent, type SignalCancelledNotification, type SignalClosedNotification, type SignalData, type SignalInterval, type SignalOpenedNotification, type SignalScheduledNotification, Storage, StorageBacktest, type StorageData, StorageLive, Strategy, type StrategyActionType, type StrategyCancelReason, type StrategyCloseReason, type StrategyCommitContract, type StrategyEvent, type StrategyStatisticsModel, type TMarkdownBase, type TNotificationUtilsCtor, type TPersistBase, type TPersistBaseCtor, type TReportBase, type TStorageUtilsCtor, type TickEvent, type TrailingStopCommit, type TrailingStopCommitNotification, type TrailingTakeCommit, type TrailingTakeCommitNotification, type ValidationErrorNotification, Walker, type WalkerCompleteContract, type WalkerContract, type WalkerMetric, type SignalData$1 as WalkerSignalData, type WalkerStatisticsModel, addActionSchema, addExchangeSchema, addFrameSchema, addRiskSchema, addSizingSchema, addStrategySchema, addWalkerSchema, commitActivateScheduled, commitBreakeven, commitCancelScheduled, commitClosePending, commitPartialLoss, commitPartialProfit, commitTrailingStop, commitTrailingTake, emitters, formatPrice, formatQuantity, get, getActionSchema, getAveragePrice, getBacktestTimeframe, getCandles, getColumns, getConfig, getContext, getDate, getDefaultColumns, getDefaultConfig, getExchangeSchema, getFrameSchema, getMode, getNextCandles, getOrderBook, getRawCandles, getRiskSchema, getSizingSchema, getStrategySchema, getSymbol, getWalkerSchema, hasTradeContext, backtest as lib, listExchangeSchema, listFrameSchema, listRiskSchema, listSizingSchema, listStrategySchema, listWalkerSchema, listenActivePing, listenActivePingOnce, listenBacktestProgress, listenBreakevenAvailable, listenBreakevenAvailableOnce, listenDoneBacktest, listenDoneBacktestOnce, listenDoneLive, listenDoneLiveOnce, listenDoneWalker, listenDoneWalkerOnce, listenError, listenExit, listenPartialLossAvailable, listenPartialLossAvailableOnce, listenPartialProfitAvailable, listenPartialProfitAvailableOnce, listenPerformance, listenRisk, listenRiskOnce, listenSchedulePing, listenSchedulePingOnce, listenSignal, listenSignalBacktest, listenSignalBacktestOnce, listenSignalLive, listenSignalLiveOnce, listenSignalOnce, listenStrategyCommit, listenStrategyCommitOnce, listenValidation, listenWalker, listenWalkerComplete, listenWalkerOnce, listenWalkerProgress, overrideActionSchema, overrideExchangeSchema, overrideFrameSchema, overrideRiskSchema, overrideSizingSchema, overrideStrategySchema, overrideWalkerSchema, parseArgs, roundTicks, set, setColumns, setConfig, setLogger, stopStrategy, validate };
|