PartialMarkdownService

Service for generating and saving partial profit/loss markdown reports.

Features:

  • Listens to partial profit and loss events via partialProfitSubject/partialLossSubject
  • Accumulates all events (profit, loss) per symbol
  • Generates markdown tables with detailed event information
  • Provides statistics (total profit/loss events)
  • Saves reports to disk in dump/partial/{symbol}.md
constructor();
loggerService: any

Logger service for debug output

getStorage: any

Memoized function to get or create ReportStorage for a symbol. Each symbol gets its own isolated storage instance.

tickProfit: any

Processes profit events and accumulates them. Should be called from partialProfitSubject subscription.

tickLoss: any

Processes loss events and accumulates them. Should be called from partialLossSubject subscription.

getData: (symbol: string) => Promise<PartialStatistics>

Gets statistical data from all partial profit/loss events for a symbol. Delegates to ReportStorage.getData().

getReport: (symbol: string) => Promise<string>

Generates markdown report with all partial events for a symbol. Delegates to ReportStorage.getReport().

dump: (symbol: string, path?: string) => Promise<void>

Saves symbol report to disk. Creates directory if it doesn't exist. Delegates to ReportStorage.dump().

clear: (symbol?: string) => Promise<void>

Clears accumulated event data from storage. If symbol is provided, clears only that symbol's data. If symbol is omitted, clears all symbols' data.

init: (() => Promise<void>) & ISingleshotClearable

Initializes the service by subscribing to partial profit/loss events. Uses singleshot to ensure initialization happens only once. Automatically called on first use.