backtest-kit 1.11.5 → 1.11.6

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/types.d.ts CHANGED
@@ -6869,6 +6869,43 @@ declare class ReportUtils {
6869
6869
  * @returns Cleanup function that unsubscribes from all enabled services
6870
6870
  */
6871
6871
  enable: ({ backtest: bt, breakeven, heat, live, partial, performance, risk, schedule, walker, }?: Partial<IReportTarget>) => (...args: any[]) => any;
6872
+ /**
6873
+ * Disables report services selectively.
6874
+ *
6875
+ * Unsubscribes from specified report services to stop event logging.
6876
+ * Use this method to stop JSONL logging for specific services while keeping others active.
6877
+ *
6878
+ * Each disabled service will:
6879
+ * - Stop listening to events immediately
6880
+ * - Stop writing to JSONL files
6881
+ * - Free up event listener resources
6882
+ *
6883
+ * Unlike enable(), this method does NOT return an unsubscribe function.
6884
+ * Services are unsubscribed immediately upon calling this method.
6885
+ *
6886
+ * @param config - Service configuration object specifying which services to disable. Defaults to disabling all services.
6887
+ * @param config.backtest - Disable backtest closed signal logging
6888
+ * @param config.breakeven - Disable breakeven event logging
6889
+ * @param config.partial - Disable partial close event logging
6890
+ * @param config.heat - Disable heatmap data logging
6891
+ * @param config.walker - Disable walker iteration logging
6892
+ * @param config.performance - Disable performance metrics logging
6893
+ * @param config.risk - Disable risk rejection logging
6894
+ * @param config.schedule - Disable scheduled signal logging
6895
+ * @param config.live - Disable live trading event logging
6896
+ *
6897
+ * @example
6898
+ * ```typescript
6899
+ * import { Report } from "backtest-kit";
6900
+ *
6901
+ * // Disable specific services
6902
+ * Report.disable({ backtest: true, live: true });
6903
+ *
6904
+ * // Disable all services
6905
+ * Report.disable();
6906
+ * ```
6907
+ */
6908
+ disable: ({ backtest: bt, breakeven, heat, live, partial, performance, risk, schedule, walker, }?: Partial<IReportTarget>) => void;
6872
6909
  }
6873
6910
  /**
6874
6911
  * Report adapter with pluggable storage backend and instance memoization.
@@ -7144,6 +7181,44 @@ declare class MarkdownUtils {
7144
7181
  * @returns Cleanup function that unsubscribes from all enabled services
7145
7182
  */
7146
7183
  enable: ({ backtest: bt, breakeven, heat, live, partial, performance, risk, schedule, walker, }?: Partial<IMarkdownTarget>) => (...args: any[]) => any;
7184
+ /**
7185
+ * Disables markdown report services selectively.
7186
+ *
7187
+ * Unsubscribes from specified markdown services to stop report generation.
7188
+ * Use this method to stop markdown report generation for specific services while keeping others active.
7189
+ *
7190
+ * Each disabled service will:
7191
+ * - Stop listening to events immediately
7192
+ * - Stop accumulating data for reports
7193
+ * - Stop generating markdown files
7194
+ * - Free up event listener and memory resources
7195
+ *
7196
+ * Unlike enable(), this method does NOT return an unsubscribe function.
7197
+ * Services are unsubscribed immediately upon calling this method.
7198
+ *
7199
+ * @param config - Service configuration object specifying which services to disable. Defaults to disabling all services.
7200
+ * @param config.backtest - Disable backtest result reports with full trade history
7201
+ * @param config.breakeven - Disable breakeven event tracking
7202
+ * @param config.partial - Disable partial profit/loss event tracking
7203
+ * @param config.heat - Disable portfolio heatmap analysis
7204
+ * @param config.walker - Disable walker strategy comparison reports
7205
+ * @param config.performance - Disable performance bottleneck analysis
7206
+ * @param config.risk - Disable risk rejection tracking
7207
+ * @param config.schedule - Disable scheduled signal tracking
7208
+ * @param config.live - Disable live trading event reports
7209
+ *
7210
+ * @example
7211
+ * ```typescript
7212
+ * import { Markdown } from "backtest-kit";
7213
+ *
7214
+ * // Disable specific services
7215
+ * Markdown.disable({ backtest: true, walker: true });
7216
+ *
7217
+ * // Disable all services
7218
+ * Markdown.disable();
7219
+ * ```
7220
+ */
7221
+ disable: ({ backtest: bt, breakeven, heat, live, partial, performance, risk, schedule, walker, }?: Partial<IMarkdownTarget>) => void;
7147
7222
  }
7148
7223
  /**
7149
7224
  * Markdown adapter with pluggable storage backend and instance memoization.
@@ -15321,67 +15396,657 @@ declare class ColumnValidationService {
15321
15396
  validate: () => void;
15322
15397
  }
15323
15398
 
15399
+ /**
15400
+ * Service for logging backtest strategy tick events to SQLite database.
15401
+ *
15402
+ * Captures all backtest signal lifecycle events (idle, opened, active, closed)
15403
+ * and stores them in the Report database for analysis and debugging.
15404
+ *
15405
+ * Features:
15406
+ * - Listens to backtest signal events via signalBacktestEmitter
15407
+ * - Logs all tick event types with full signal details
15408
+ * - Stores events in Report.writeData() for persistence
15409
+ * - Protected against multiple subscriptions using singleshot
15410
+ *
15411
+ * @example
15412
+ * ```typescript
15413
+ * import { BacktestReportService } from "backtest-kit";
15414
+ *
15415
+ * const reportService = new BacktestReportService();
15416
+ *
15417
+ * // Subscribe to backtest events
15418
+ * const unsubscribe = reportService.subscribe();
15419
+ *
15420
+ * // Run backtest...
15421
+ * // Events are automatically logged
15422
+ *
15423
+ * // Later: unsubscribe
15424
+ * await reportService.unsubscribe();
15425
+ * ```
15426
+ */
15324
15427
  declare class BacktestReportService {
15428
+ /** Logger service for debug output */
15325
15429
  private readonly loggerService;
15430
+ /**
15431
+ * Processes backtest tick events and logs them to the database.
15432
+ * Handles all event types: idle, opened, active, closed.
15433
+ *
15434
+ * @param data - Backtest tick result with signal lifecycle information
15435
+ *
15436
+ * @internal
15437
+ */
15326
15438
  private tick;
15439
+ /**
15440
+ * Subscribes to backtest signal emitter to receive tick events.
15441
+ * Protected against multiple subscriptions.
15442
+ * Returns an unsubscribe function to stop receiving events.
15443
+ *
15444
+ * @returns Unsubscribe function to stop receiving backtest events
15445
+ *
15446
+ * @example
15447
+ * ```typescript
15448
+ * const service = new BacktestReportService();
15449
+ * const unsubscribe = service.subscribe();
15450
+ * // ... later
15451
+ * unsubscribe();
15452
+ * ```
15453
+ */
15327
15454
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
15455
+ /**
15456
+ * Unsubscribes from backtest signal emitter to stop receiving tick events.
15457
+ * Calls the unsubscribe function returned by subscribe().
15458
+ * If not subscribed, does nothing.
15459
+ *
15460
+ * @example
15461
+ * ```typescript
15462
+ * const service = new BacktestReportService();
15463
+ * service.subscribe();
15464
+ * // ... later
15465
+ * await service.unsubscribe();
15466
+ * ```
15467
+ */
15328
15468
  unsubscribe: () => Promise<void>;
15329
15469
  }
15330
15470
 
15471
+ /**
15472
+ * Service for logging live trading strategy tick events to SQLite database.
15473
+ *
15474
+ * Captures all live trading signal lifecycle events (idle, opened, active, closed)
15475
+ * and stores them in the Report database for real-time monitoring and analysis.
15476
+ *
15477
+ * Features:
15478
+ * - Listens to live signal events via signalLiveEmitter
15479
+ * - Logs all tick event types with full signal details
15480
+ * - Stores events in Report.writeData() for persistence
15481
+ * - Protected against multiple subscriptions using singleshot
15482
+ *
15483
+ * @example
15484
+ * ```typescript
15485
+ * import { LiveReportService } from "backtest-kit";
15486
+ *
15487
+ * const reportService = new LiveReportService();
15488
+ *
15489
+ * // Subscribe to live trading events
15490
+ * const unsubscribe = reportService.subscribe();
15491
+ *
15492
+ * // Run live trading...
15493
+ * // Events are automatically logged
15494
+ *
15495
+ * // Later: unsubscribe
15496
+ * await reportService.unsubscribe();
15497
+ * ```
15498
+ */
15331
15499
  declare class LiveReportService {
15500
+ /** Logger service for debug output */
15332
15501
  private readonly loggerService;
15502
+ /**
15503
+ * Processes live trading tick events and logs them to the database.
15504
+ * Handles all event types: idle, opened, active, closed.
15505
+ *
15506
+ * @param data - Live trading tick result with signal lifecycle information
15507
+ *
15508
+ * @internal
15509
+ */
15333
15510
  private tick;
15511
+ /**
15512
+ * Subscribes to live signal emitter to receive tick events.
15513
+ * Protected against multiple subscriptions.
15514
+ * Returns an unsubscribe function to stop receiving events.
15515
+ *
15516
+ * @returns Unsubscribe function to stop receiving live trading events
15517
+ *
15518
+ * @example
15519
+ * ```typescript
15520
+ * const service = new LiveReportService();
15521
+ * const unsubscribe = service.subscribe();
15522
+ * // ... later
15523
+ * unsubscribe();
15524
+ * ```
15525
+ */
15334
15526
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
15527
+ /**
15528
+ * Unsubscribes from live signal emitter to stop receiving tick events.
15529
+ * Calls the unsubscribe function returned by subscribe().
15530
+ * If not subscribed, does nothing.
15531
+ *
15532
+ * @example
15533
+ * ```typescript
15534
+ * const service = new LiveReportService();
15535
+ * service.subscribe();
15536
+ * // ... later
15537
+ * await service.unsubscribe();
15538
+ * ```
15539
+ */
15335
15540
  unsubscribe: () => Promise<void>;
15336
15541
  }
15337
15542
 
15543
+ /**
15544
+ * Service for logging scheduled signal events to SQLite database.
15545
+ *
15546
+ * Captures all scheduled signal lifecycle events (scheduled, opened, cancelled)
15547
+ * and stores them in the Report database for tracking delayed order execution.
15548
+ *
15549
+ * Features:
15550
+ * - Listens to signal events via signalEmitter
15551
+ * - Logs scheduled, opened (from scheduled), and cancelled events
15552
+ * - Calculates duration between scheduling and execution/cancellation
15553
+ * - Stores events in Report.writeData() for schedule tracking
15554
+ * - Protected against multiple subscriptions using singleshot
15555
+ *
15556
+ * @example
15557
+ * ```typescript
15558
+ * import { ScheduleReportService } from "backtest-kit";
15559
+ *
15560
+ * const reportService = new ScheduleReportService();
15561
+ *
15562
+ * // Subscribe to scheduled signal events
15563
+ * const unsubscribe = reportService.subscribe();
15564
+ *
15565
+ * // Run strategy with scheduled orders...
15566
+ * // Scheduled events are automatically logged
15567
+ *
15568
+ * // Later: unsubscribe
15569
+ * await reportService.unsubscribe();
15570
+ * ```
15571
+ */
15338
15572
  declare class ScheduleReportService {
15573
+ /** Logger service for debug output */
15339
15574
  private readonly loggerService;
15575
+ /**
15576
+ * Processes signal tick events and logs scheduled signal lifecycle to the database.
15577
+ * Handles scheduled, opened (from scheduled), and cancelled event types.
15578
+ *
15579
+ * @param data - Strategy tick result with signal lifecycle information
15580
+ *
15581
+ * @internal
15582
+ */
15340
15583
  private tick;
15584
+ /**
15585
+ * Subscribes to signal emitter to receive scheduled signal events.
15586
+ * Protected against multiple subscriptions.
15587
+ * Returns an unsubscribe function to stop receiving events.
15588
+ *
15589
+ * @returns Unsubscribe function to stop receiving scheduled signal events
15590
+ *
15591
+ * @example
15592
+ * ```typescript
15593
+ * const service = new ScheduleReportService();
15594
+ * const unsubscribe = service.subscribe();
15595
+ * // ... later
15596
+ * unsubscribe();
15597
+ * ```
15598
+ */
15341
15599
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
15600
+ /**
15601
+ * Unsubscribes from signal emitter to stop receiving events.
15602
+ * Calls the unsubscribe function returned by subscribe().
15603
+ * If not subscribed, does nothing.
15604
+ *
15605
+ * @example
15606
+ * ```typescript
15607
+ * const service = new ScheduleReportService();
15608
+ * service.subscribe();
15609
+ * // ... later
15610
+ * await service.unsubscribe();
15611
+ * ```
15612
+ */
15342
15613
  unsubscribe: () => Promise<void>;
15343
15614
  }
15344
15615
 
15616
+ /**
15617
+ * Service for logging performance metrics to SQLite database.
15618
+ *
15619
+ * Captures all performance timing events from strategy execution
15620
+ * and stores them in the Report database for bottleneck analysis and optimization.
15621
+ *
15622
+ * Features:
15623
+ * - Listens to performance events via performanceEmitter
15624
+ * - Logs all timing metrics with duration and metadata
15625
+ * - Stores events in Report.writeData() for performance analysis
15626
+ * - Protected against multiple subscriptions using singleshot
15627
+ *
15628
+ * @example
15629
+ * ```typescript
15630
+ * import { PerformanceReportService } from "backtest-kit";
15631
+ *
15632
+ * const reportService = new PerformanceReportService();
15633
+ *
15634
+ * // Subscribe to performance events
15635
+ * const unsubscribe = reportService.subscribe();
15636
+ *
15637
+ * // Run strategy...
15638
+ * // Performance metrics are automatically logged
15639
+ *
15640
+ * // Later: unsubscribe
15641
+ * await reportService.unsubscribe();
15642
+ * ```
15643
+ */
15345
15644
  declare class PerformanceReportService {
15645
+ /** Logger service for debug output */
15346
15646
  private readonly loggerService;
15647
+ /**
15648
+ * Processes performance tracking events and logs them to the database.
15649
+ *
15650
+ * @param event - Performance contract with timing and metric information
15651
+ *
15652
+ * @internal
15653
+ */
15347
15654
  private track;
15655
+ /**
15656
+ * Subscribes to performance emitter to receive timing events.
15657
+ * Protected against multiple subscriptions.
15658
+ * Returns an unsubscribe function to stop receiving events.
15659
+ *
15660
+ * @returns Unsubscribe function to stop receiving performance events
15661
+ *
15662
+ * @example
15663
+ * ```typescript
15664
+ * const service = new PerformanceReportService();
15665
+ * const unsubscribe = service.subscribe();
15666
+ * // ... later
15667
+ * unsubscribe();
15668
+ * ```
15669
+ */
15348
15670
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
15671
+ /**
15672
+ * Unsubscribes from performance emitter to stop receiving events.
15673
+ * Calls the unsubscribe function returned by subscribe().
15674
+ * If not subscribed, does nothing.
15675
+ *
15676
+ * @example
15677
+ * ```typescript
15678
+ * const service = new PerformanceReportService();
15679
+ * service.subscribe();
15680
+ * // ... later
15681
+ * await service.unsubscribe();
15682
+ * ```
15683
+ */
15349
15684
  unsubscribe: () => Promise<void>;
15350
15685
  }
15351
15686
 
15687
+ /**
15688
+ * Service for logging walker optimization progress to SQLite database.
15689
+ *
15690
+ * Captures walker strategy optimization results and stores them in the Report database
15691
+ * for tracking parameter optimization and comparing strategy performance.
15692
+ *
15693
+ * Features:
15694
+ * - Listens to walker events via walkerEmitter
15695
+ * - Logs each strategy test result with metrics and statistics
15696
+ * - Tracks best strategy and optimization progress
15697
+ * - Stores events in Report.writeData() for optimization analysis
15698
+ * - Protected against multiple subscriptions using singleshot
15699
+ *
15700
+ * @example
15701
+ * ```typescript
15702
+ * import { WalkerReportService } from "backtest-kit";
15703
+ *
15704
+ * const reportService = new WalkerReportService();
15705
+ *
15706
+ * // Subscribe to walker optimization events
15707
+ * const unsubscribe = reportService.subscribe();
15708
+ *
15709
+ * // Run walker optimization...
15710
+ * // Each strategy result is automatically logged
15711
+ *
15712
+ * // Later: unsubscribe
15713
+ * await reportService.unsubscribe();
15714
+ * ```
15715
+ */
15352
15716
  declare class WalkerReportService {
15717
+ /** Logger service for debug output */
15353
15718
  private readonly loggerService;
15719
+ /**
15720
+ * Processes walker optimization events and logs them to the database.
15721
+ *
15722
+ * @param data - Walker contract with strategy optimization results
15723
+ *
15724
+ * @internal
15725
+ */
15354
15726
  private tick;
15727
+ /**
15728
+ * Subscribes to walker emitter to receive optimization progress events.
15729
+ * Protected against multiple subscriptions.
15730
+ * Returns an unsubscribe function to stop receiving events.
15731
+ *
15732
+ * @returns Unsubscribe function to stop receiving walker optimization events
15733
+ *
15734
+ * @example
15735
+ * ```typescript
15736
+ * const service = new WalkerReportService();
15737
+ * const unsubscribe = service.subscribe();
15738
+ * // ... later
15739
+ * unsubscribe();
15740
+ * ```
15741
+ */
15355
15742
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
15743
+ /**
15744
+ * Unsubscribes from walker emitter to stop receiving events.
15745
+ * Calls the unsubscribe function returned by subscribe().
15746
+ * If not subscribed, does nothing.
15747
+ *
15748
+ * @example
15749
+ * ```typescript
15750
+ * const service = new WalkerReportService();
15751
+ * service.subscribe();
15752
+ * // ... later
15753
+ * await service.unsubscribe();
15754
+ * ```
15755
+ */
15356
15756
  unsubscribe: () => Promise<void>;
15357
15757
  }
15358
15758
 
15759
+ /**
15760
+ * Service for logging heatmap (closed signals) events to SQLite database.
15761
+ *
15762
+ * Captures closed signal events across all symbols for portfolio-wide
15763
+ * heatmap analysis and stores them in the Report database.
15764
+ *
15765
+ * Features:
15766
+ * - Listens to signal events via signalEmitter
15767
+ * - Logs only closed signals with PNL data
15768
+ * - Stores events in Report.writeData() for heatmap generation
15769
+ * - Protected against multiple subscriptions using singleshot
15770
+ *
15771
+ * @example
15772
+ * ```typescript
15773
+ * import { HeatReportService } from "backtest-kit";
15774
+ *
15775
+ * const reportService = new HeatReportService();
15776
+ *
15777
+ * // Subscribe to signal events
15778
+ * const unsubscribe = reportService.subscribe();
15779
+ *
15780
+ * // Run strategy...
15781
+ * // Closed signals are automatically logged
15782
+ *
15783
+ * // Later: unsubscribe
15784
+ * await reportService.unsubscribe();
15785
+ * ```
15786
+ */
15359
15787
  declare class HeatReportService {
15788
+ /** Logger service for debug output */
15360
15789
  private readonly loggerService;
15790
+ /**
15791
+ * Processes signal tick events and logs closed signals to the database.
15792
+ * Only processes closed signals - other actions are ignored.
15793
+ *
15794
+ * @param data - Strategy tick result with signal lifecycle information
15795
+ *
15796
+ * @internal
15797
+ */
15361
15798
  private tick;
15799
+ /**
15800
+ * Subscribes to signal emitter to receive closed signal events.
15801
+ * Protected against multiple subscriptions.
15802
+ * Returns an unsubscribe function to stop receiving events.
15803
+ *
15804
+ * @returns Unsubscribe function to stop receiving signal events
15805
+ *
15806
+ * @example
15807
+ * ```typescript
15808
+ * const service = new HeatReportService();
15809
+ * const unsubscribe = service.subscribe();
15810
+ * // ... later
15811
+ * unsubscribe();
15812
+ * ```
15813
+ */
15362
15814
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
15815
+ /**
15816
+ * Unsubscribes from signal emitter to stop receiving events.
15817
+ * Calls the unsubscribe function returned by subscribe().
15818
+ * If not subscribed, does nothing.
15819
+ *
15820
+ * @example
15821
+ * ```typescript
15822
+ * const service = new HeatReportService();
15823
+ * service.subscribe();
15824
+ * // ... later
15825
+ * await service.unsubscribe();
15826
+ * ```
15827
+ */
15363
15828
  unsubscribe: () => Promise<void>;
15364
15829
  }
15365
15830
 
15831
+ /**
15832
+ * Service for logging partial profit/loss events to SQLite database.
15833
+ *
15834
+ * Captures all partial position exit events (profit and loss levels)
15835
+ * and stores them in the Report database for tracking partial closures.
15836
+ *
15837
+ * Features:
15838
+ * - Listens to partial profit events via partialProfitSubject
15839
+ * - Listens to partial loss events via partialLossSubject
15840
+ * - Logs all partial exit events with level and price information
15841
+ * - Stores events in Report.writeData() for persistence
15842
+ * - Protected against multiple subscriptions using singleshot
15843
+ *
15844
+ * @example
15845
+ * ```typescript
15846
+ * import { PartialReportService } from "backtest-kit";
15847
+ *
15848
+ * const reportService = new PartialReportService();
15849
+ *
15850
+ * // Subscribe to partial events
15851
+ * const unsubscribe = reportService.subscribe();
15852
+ *
15853
+ * // Run strategy with partial exits...
15854
+ * // Partial events are automatically logged
15855
+ *
15856
+ * // Later: unsubscribe
15857
+ * await reportService.unsubscribe();
15858
+ * ```
15859
+ */
15366
15860
  declare class PartialReportService {
15861
+ /** Logger service for debug output */
15367
15862
  private readonly loggerService;
15863
+ /**
15864
+ * Processes partial profit events and logs them to the database.
15865
+ *
15866
+ * @param data - Partial profit event data with signal, level, and price information
15867
+ *
15868
+ * @internal
15869
+ */
15368
15870
  private tickProfit;
15871
+ /**
15872
+ * Processes partial loss events and logs them to the database.
15873
+ *
15874
+ * @param data - Partial loss event data with signal, level, and price information
15875
+ *
15876
+ * @internal
15877
+ */
15369
15878
  private tickLoss;
15879
+ /**
15880
+ * Subscribes to partial profit/loss emitters to receive partial exit events.
15881
+ * Protected against multiple subscriptions.
15882
+ * Returns an unsubscribe function to stop receiving events.
15883
+ *
15884
+ * @returns Unsubscribe function to stop receiving partial events
15885
+ *
15886
+ * @example
15887
+ * ```typescript
15888
+ * const service = new PartialReportService();
15889
+ * const unsubscribe = service.subscribe();
15890
+ * // ... later
15891
+ * unsubscribe();
15892
+ * ```
15893
+ */
15370
15894
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
15895
+ /**
15896
+ * Unsubscribes from partial profit/loss emitters to stop receiving events.
15897
+ * Calls the unsubscribe function returned by subscribe().
15898
+ * If not subscribed, does nothing.
15899
+ *
15900
+ * @example
15901
+ * ```typescript
15902
+ * const service = new PartialReportService();
15903
+ * service.subscribe();
15904
+ * // ... later
15905
+ * await service.unsubscribe();
15906
+ * ```
15907
+ */
15371
15908
  unsubscribe: () => Promise<void>;
15372
15909
  }
15373
15910
 
15911
+ /**
15912
+ * Service for logging breakeven events to SQLite database.
15913
+ *
15914
+ * Captures all breakeven events (when signal reaches breakeven point)
15915
+ * and stores them in the Report database for analysis and tracking.
15916
+ *
15917
+ * Features:
15918
+ * - Listens to breakeven events via breakevenSubject
15919
+ * - Logs all breakeven achievements with full signal details
15920
+ * - Stores events in Report.writeData() for persistence
15921
+ * - Protected against multiple subscriptions using singleshot
15922
+ *
15923
+ * @example
15924
+ * ```typescript
15925
+ * import { BreakevenReportService } from "backtest-kit";
15926
+ *
15927
+ * const reportService = new BreakevenReportService();
15928
+ *
15929
+ * // Subscribe to breakeven events
15930
+ * const unsubscribe = reportService.subscribe();
15931
+ *
15932
+ * // Run strategy...
15933
+ * // Breakeven events are automatically logged
15934
+ *
15935
+ * // Later: unsubscribe
15936
+ * await reportService.unsubscribe();
15937
+ * ```
15938
+ */
15374
15939
  declare class BreakevenReportService {
15940
+ /** Logger service for debug output */
15375
15941
  private readonly loggerService;
15942
+ /**
15943
+ * Processes breakeven events and logs them to the database.
15944
+ *
15945
+ * @param data - Breakeven event data with signal and price information
15946
+ *
15947
+ * @internal
15948
+ */
15376
15949
  private tickBreakeven;
15950
+ /**
15951
+ * Subscribes to breakeven signal emitter to receive breakeven events.
15952
+ * Protected against multiple subscriptions.
15953
+ * Returns an unsubscribe function to stop receiving events.
15954
+ *
15955
+ * @returns Unsubscribe function to stop receiving breakeven events
15956
+ *
15957
+ * @example
15958
+ * ```typescript
15959
+ * const service = new BreakevenReportService();
15960
+ * const unsubscribe = service.subscribe();
15961
+ * // ... later
15962
+ * unsubscribe();
15963
+ * ```
15964
+ */
15377
15965
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
15966
+ /**
15967
+ * Unsubscribes from breakeven signal emitter to stop receiving events.
15968
+ * Calls the unsubscribe function returned by subscribe().
15969
+ * If not subscribed, does nothing.
15970
+ *
15971
+ * @example
15972
+ * ```typescript
15973
+ * const service = new BreakevenReportService();
15974
+ * service.subscribe();
15975
+ * // ... later
15976
+ * await service.unsubscribe();
15977
+ * ```
15978
+ */
15378
15979
  unsubscribe: () => Promise<void>;
15379
15980
  }
15380
15981
 
15982
+ /**
15983
+ * Service for logging risk rejection events to SQLite database.
15984
+ *
15985
+ * Captures all signal rejection events from the risk management system
15986
+ * and stores them in the Report database for risk analysis and auditing.
15987
+ *
15988
+ * Features:
15989
+ * - Listens to risk rejection events via riskSubject
15990
+ * - Logs all rejected signals with reason and pending signal details
15991
+ * - Stores events in Report.writeData() for risk tracking
15992
+ * - Protected against multiple subscriptions using singleshot
15993
+ *
15994
+ * @example
15995
+ * ```typescript
15996
+ * import { RiskReportService } from "backtest-kit";
15997
+ *
15998
+ * const reportService = new RiskReportService();
15999
+ *
16000
+ * // Subscribe to risk rejection events
16001
+ * const unsubscribe = reportService.subscribe();
16002
+ *
16003
+ * // Run strategy with risk management...
16004
+ * // Rejection events are automatically logged
16005
+ *
16006
+ * // Later: unsubscribe
16007
+ * await reportService.unsubscribe();
16008
+ * ```
16009
+ */
15381
16010
  declare class RiskReportService {
16011
+ /** Logger service for debug output */
15382
16012
  private readonly loggerService;
16013
+ /**
16014
+ * Processes risk rejection events and logs them to the database.
16015
+ *
16016
+ * @param data - Risk event with rejection reason and pending signal information
16017
+ *
16018
+ * @internal
16019
+ */
15383
16020
  private tickRejection;
16021
+ /**
16022
+ * Subscribes to risk rejection emitter to receive rejection events.
16023
+ * Protected against multiple subscriptions.
16024
+ * Returns an unsubscribe function to stop receiving events.
16025
+ *
16026
+ * @returns Unsubscribe function to stop receiving risk rejection events
16027
+ *
16028
+ * @example
16029
+ * ```typescript
16030
+ * const service = new RiskReportService();
16031
+ * const unsubscribe = service.subscribe();
16032
+ * // ... later
16033
+ * unsubscribe();
16034
+ * ```
16035
+ */
15384
16036
  subscribe: (() => () => void) & functools_kit.ISingleshotClearable;
16037
+ /**
16038
+ * Unsubscribes from risk rejection emitter to stop receiving events.
16039
+ * Calls the unsubscribe function returned by subscribe().
16040
+ * If not subscribed, does nothing.
16041
+ *
16042
+ * @example
16043
+ * ```typescript
16044
+ * const service = new RiskReportService();
16045
+ * service.subscribe();
16046
+ * // ... later
16047
+ * await service.unsubscribe();
16048
+ * ```
16049
+ */
15385
16050
  unsubscribe: () => Promise<void>;
15386
16051
  }
15387
16052