Lean  $LEAN_TAG$
QuantConnect.Lean.Engine.Results.BaseResultsHandler Class Referenceabstract

Provides base functionality to the implementations of IResultHandler More...

Inheritance diagram for QuantConnect.Lean.Engine.Results.BaseResultsHandler:
[legend]

Public Member Functions

virtual void OrderEvent (OrderEvent newEvent)
 New order event for the algorithm More...
 
virtual void Exit ()
 Terminate the result thread and apply any required exit procedures like sending final results More...
 
virtual void Initialize (ResultHandlerInitializeParameters parameters)
 Initialize the result handler with this result packet. More...
 
virtual void OnSecuritiesChanged (SecurityChanges changes)
 Event fired each time that we add/remove securities from the data feed More...
 
virtual string SaveLogs (string id, List< LogEntry > logs)
 Returns the location of the logs More...
 
virtual void SaveResults (string name, Result result)
 Save the results to disk More...
 
virtual void Sample (DateTime time)
 Samples portfolio equity, benchmark, and daily performance Called by scheduled event every night at midnight algorithm time More...
 

Public Attributes

bool IsActive => _updateRunner != null && _updateRunner.IsAlive
 Boolean flag indicating the thread is still active. More...
 

Static Public Attributes

const string StrategyEquityKey = "Strategy Equity"
 String message saying: Strategy Equity More...
 
const string EquityKey = "Equity"
 String message saying: Equity More...
 
const string ReturnKey = "Return"
 String message saying: Return More...
 
const string BenchmarkKey = "Benchmark"
 String message saying: Benchmark More...
 
const string DrawdownKey = "Drawdown"
 String message saying: Drawdown More...
 
const string PortfolioTurnoverKey = "Portfolio Turnover"
 String message saying: PortfolioTurnover More...
 
const string PortfolioMarginKey = "Portfolio Margin"
 String message saying: Portfolio Margin More...
 
const string AssetsSalesVolumeKey = "Assets Sales Volume"
 String message saying: Portfolio Margin More...
 

Protected Member Functions

 BaseResultsHandler ()
 Creates a new instance More...
 
virtual Dictionary< string, string > GetServerStatistics (DateTime utcNow)
 Gets the current Server statistics More...
 
virtual void StoreOrderEvents (DateTime utcTime, List< OrderEvent > orderEvents)
 Stores the order events More...
 
virtual void StoreInsights ()
 Save insight results to persistent storage More...
 
virtual Dictionary< int, OrderGetDeltaOrders (int orderEventsStartPosition, Func< int, bool > shouldStop)
 Gets the orders generated starting from the provided ITransactionHandler.OrderEvents position More...
 
abstract void Run ()
 Result handler update method More...
 
string GetResultsPath (string filename)
 Gets the full path for a results file More...
 
void PurgeQueue ()
 Purge/clear any outstanding messages in message queue. More...
 
void StopUpdateRunner ()
 Stops the update runner task More...
 
decimal GetNetReturn ()
 Gets the algorithm net return More...
 
abstract void StoreResult (Packet packet)
 Save the snapshot of the total results to storage. More...
 
virtual decimal GetPortfolioValue ()
 Gets the current portfolio value More...
 
virtual decimal GetBenchmarkValue (DateTime time)
 Gets the current benchmark value More...
 
virtual void SampleEquity (DateTime time)
 Sample the current equity of the strategy directly with time and using the current algorithm equity value in CurrentAlgorithmEquity More...
 
virtual void SamplePerformance (DateTime time, decimal value)
 Sample the current daily performance directly with a time-value pair. More...
 
virtual void SampleBenchmark (DateTime time, decimal value)
 Sample the current benchmark performance directly with a time-value pair. More...
 
virtual void SampleDrawdown (DateTime time, decimal currentPortfolioValue)
 Sample drawdown of equity of the strategy More...
 
virtual void SamplePortfolioTurnover (DateTime time, decimal currentPortfolioValue)
 Sample portfolio turn over of the strategy More...
 
virtual void SampleSalesVolume (DateTime time)
 Sample assets sales volume More...
 
virtual void SampleExposure (DateTime time, decimal currentPortfolioValue)
 Sample portfolio exposure long/short ratios by security type More...
 
virtual void SampleCapacity (DateTime time)
 Sample estimated strategy capacity More...
 
abstract void Sample (string chartName, string seriesName, int seriesIndex, SeriesType seriesType, ISeriesPoint value, string unit="$")
 Add a sample to the chart specified by the chartName, and seriesName. More...
 
SortedDictionary< string, string > GetAlgorithmRuntimeStatistics (Dictionary< string, string > summary, CapacityEstimate capacityEstimate=null)
 Gets the algorithm runtime statistics More...
 
void SetAlgorithmState (string error, string stack)
 Sets the algorithm state data More...
 
Dictionary< string, string > GetAlgorithmState (DateTime? endTime=null)
 Gets the algorithm state data More...
 
StatisticsResults GenerateStatisticsResults (Dictionary< string, Chart > charts, SortedDictionary< DateTime, decimal > profitLoss=null, CapacityEstimate estimatedStrategyCapacity=null)
 Will generate the statistics results and update the provided runtime statistics More...
 
int TotalTradesCount ()
 Helper method to get the total trade count statistic More...
 
StatisticsResults GenerateStatisticsResults (CapacityEstimate estimatedStrategyCapacity=null)
 Calculates and gets the current statistics for the algorithm. It will use the current Charts and profit loss information calculated from the current transaction record to generate the results. More...
 
virtual void AddToLogStore (string message)
 Save an algorithm message to the log store. Uses a different timestamped method of adding messaging to interweve debug and logging messages. More...
 
void ProcessAlgorithmLogs (int? messageQueueLimit=null)
 Processes algorithm logs. Logs of the same type are batched together one per line and are sent out More...
 
void SummaryStatistic (string name, string value)
 Sets or updates a custom summary statistic More...
 
void UpdateAlgorithmEquity ()
 Updates the current equity bar with the current equity value from GetPortfolioValue More...
 

Protected Attributes

volatile bool ExitTriggered
 True if the exit has been triggered More...
 

Properties

virtual TimeSpan MainUpdateInterval = TimeSpan.FromSeconds(3) [get]
 The main loop update interval More...
 
TimeSpan ChartUpdateInterval = TimeSpan.FromMinutes(1) [get, set]
 The chart update interval More...
 
int LastDeltaOrderPosition [get, set]
 The last position consumed from the ITransactionHandler.OrderEvents by GetDeltaOrders More...
 
int LastDeltaOrderEventsPosition [get, set]
 The last position consumed from the ITransactionHandler.OrderEvents while determining delta order events More...
 
JsonSerializerSettings SerializerSettings [get, set]
 Serializer settings to use More...
 
Bar CurrentAlgorithmEquity [get, set]
 The current aggregated equity bar for sampling. It will be aggregated with values from the GetPortfolioValue More...
 
ConcurrentQueue< PacketMessages [get, set]
 Live packet messaging queue. Queue the messages here and send when the result queue is ready. More...
 
ConcurrentDictionary< string, ChartCharts [get, set]
 Storage for the price and equity charts of the live results. More...
 
ManualResetEvent ExitEvent [get]
 Event set when exit is triggered More...
 
List< LogEntryLogStore [get]
 The log store instance More...
 
List< string > AlgorithmPerformanceCharts = new List<string> { StrategyEquityKey, BenchmarkKey } [get]
 Algorithms performance related chart names More...
 
object ChartLock [get]
 Lock to be used when accessing the chart collection More...
 
int ProjectId [get, set]
 The algorithm project id More...
 
string RamAllocation [get, set]
 The maximum amount of RAM (in MB) this algorithm is allowed to utilize More...
 
string CompileId [get, set]
 The algorithm unique compilation id More...
 
string AlgorithmId [get, set]
 The algorithm job id. This is the deploy id for live, backtesting id for backtesting More...
 
DateTime StartTime [get]
 The result handler start time More...
 
Dictionary< string, string > RuntimeStatistics [get]
 Customizable dynamic statistics IAlgorithm.RuntimeStatistics More...
 
Dictionary< string, string > State [get, set]
 State of the algorithm More...
 
IMessagingHandler MessagingHandler [get, set]
 The handler responsible for communicating messages to listeners More...
 
ITransactionHandler TransactionHandler [get, set]
 The transaction handler used to get the algorithms Orders information More...
 
decimal StartingPortfolioValue [get, set]
 The algorithms starting portfolio value. Used to calculate the portfolio return More...
 
virtual IAlgorithm Algorithm [get, set]
 The algorithm instance More...
 
string AlgorithmCurrencySymbol [get, set]
 Algorithm currency symbol, used in charting More...
 
decimal DailyPortfolioValue [get, set]
 Closing portfolio value. Used to calculate daily performance. More...
 
decimal CumulativeMaxPortfolioValue [get, set]
 Cumulative max portfolio value. Used to calculate drawdown underwater. More...
 
TimeSpan ResamplePeriod [get, set]
 Sampling period for timespans between resamples of the charting equity. More...
 
TimeSpan NotificationPeriod [get, set]
 How frequently the backtests push messages to the browser. More...
 
string ResultsDestinationFolder [get, set]
 Directory location to store results More...
 
IMapFileProvider MapFileProvider [get, set]
 The map file provider instance to use More...
 

Detailed Description

Provides base functionality to the implementations of IResultHandler

Definition at line 43 of file BaseResultsHandler.cs.

Constructor & Destructor Documentation

◆ BaseResultsHandler()

QuantConnect.Lean.Engine.Results.BaseResultsHandler.BaseResultsHandler ( )
protected

Creates a new instance

Definition at line 297 of file BaseResultsHandler.cs.

Here is the call graph for this function:

Member Function Documentation

◆ OrderEvent()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.OrderEvent ( OrderEvent  newEvent)
virtual

◆ Exit()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.Exit ( )
virtual

Terminate the result thread and apply any required exit procedures like sending final results

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler, QuantConnect.Lean.Engine.Results.BacktestingResultHandler, and QuantConnect.Lean.Engine.Results.RegressionResultHandler.

Definition at line 340 of file BaseResultsHandler.cs.

◆ GetServerStatistics()

virtual Dictionary<string, string> QuantConnect.Lean.Engine.Results.BaseResultsHandler.GetServerStatistics ( DateTime  utcNow)
protectedvirtual

Gets the current Server statistics

Definition at line 350 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StoreOrderEvents()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.StoreOrderEvents ( DateTime  utcTime,
List< OrderEvent orderEvents 
)
protectedvirtual

Stores the order events

Parameters
utcTimeThe utc date associated with these order events
orderEventsThe order events to store

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler.

Definition at line 365 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StoreInsights()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.StoreInsights ( )
protectedvirtual

Save insight results to persistent storage

Method called by the storing timer and on exit

Definition at line 384 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDeltaOrders()

virtual Dictionary<int, Order> QuantConnect.Lean.Engine.Results.BaseResultsHandler.GetDeltaOrders ( int  orderEventsStartPosition,
Func< int, bool >  shouldStop 
)
protectedvirtual

Gets the orders generated starting from the provided ITransactionHandler.OrderEvents position

Returns
The delta orders

Definition at line 411 of file BaseResultsHandler.cs.

◆ Initialize()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.Initialize ( ResultHandlerInitializeParameters  parameters)
virtual

Initialize the result handler with this result packet.

Parameters
parametersDTO parameters class to initialize a result handler

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler, and QuantConnect.Lean.Engine.Results.BacktestingResultHandler.

Definition at line 449 of file BaseResultsHandler.cs.

Here is the call graph for this function:

◆ Run()

abstract void QuantConnect.Lean.Engine.Results.BaseResultsHandler.Run ( )
protectedpure virtual

Result handler update method

Implemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler, and QuantConnect.Lean.Engine.Results.BacktestingResultHandler.

Here is the caller graph for this function:

◆ GetResultsPath()

string QuantConnect.Lean.Engine.Results.BaseResultsHandler.GetResultsPath ( string  filename)
protected

Gets the full path for a results file

Parameters
filenameThe filename to add to the path
Returns
The full path, including the filename

Definition at line 487 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ OnSecuritiesChanged()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.OnSecuritiesChanged ( SecurityChanges  changes)
virtual

Event fired each time that we add/remove securities from the data feed

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler, and QuantConnect.Lean.Engine.Results.RegressionResultHandler.

Definition at line 495 of file BaseResultsHandler.cs.

◆ SaveLogs()

virtual string QuantConnect.Lean.Engine.Results.BaseResultsHandler.SaveLogs ( string  id,
List< LogEntry logs 
)
virtual

Returns the location of the logs

Parameters
idId that will be incorporated into the algorithm log name
logsThe logs to save
Returns
The path to the logs

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler.

Definition at line 505 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveResults()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SaveResults ( string  name,
Result  result 
)
virtual

Save the results to disk

Parameters
nameThe name of the results
resultThe results to save

Reimplemented in QuantConnect.Lean.Engine.Results.RegressionResultHandler.

Definition at line 519 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PurgeQueue()

void QuantConnect.Lean.Engine.Results.BaseResultsHandler.PurgeQueue ( )
protected

Purge/clear any outstanding messages in message queue.

Definition at line 527 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ StopUpdateRunner()

void QuantConnect.Lean.Engine.Results.BaseResultsHandler.StopUpdateRunner ( )
protected

Stops the update runner task

Definition at line 535 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ GetNetReturn()

decimal QuantConnect.Lean.Engine.Results.BaseResultsHandler.GetNetReturn ( )
protected

Gets the algorithm net return

Definition at line 544 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ StoreResult()

abstract void QuantConnect.Lean.Engine.Results.BaseResultsHandler.StoreResult ( Packet  packet)
protectedpure virtual

Save the snapshot of the total results to storage.

Parameters
packetPacket to store.

Implemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler, and QuantConnect.Lean.Engine.Results.BacktestingResultHandler.

◆ GetPortfolioValue()

virtual decimal QuantConnect.Lean.Engine.Results.BaseResultsHandler.GetPortfolioValue ( )
protectedvirtual

Gets the current portfolio value

Useful so that live trading implementation can freeze the returned value if there is no user exchange open so we ignore extended market hours updates

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler.

Definition at line 563 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ GetBenchmarkValue()

virtual decimal QuantConnect.Lean.Engine.Results.BaseResultsHandler.GetBenchmarkValue ( DateTime  time)
protectedvirtual

Gets the current benchmark value

Useful so that live trading implementation can freeze the returned value if there is no user exchange open so we ignore extended market hours updates

Parameters
timeTime to resolve benchmark value at

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler.

Definition at line 574 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ Sample() [1/2]

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.Sample ( DateTime  time)
virtual

Samples portfolio equity, benchmark, and daily performance Called by scheduled event every night at midnight algorithm time

Parameters
timeCurrent UTC time in the AlgorithmManager loop

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler.

Definition at line 589 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleEquity()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SampleEquity ( DateTime  time)
protectedvirtual

Sample the current equity of the strategy directly with time and using the current algorithm equity value in CurrentAlgorithmEquity

Parameters
timeEquity candlestick end time

Definition at line 633 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SamplePerformance()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SamplePerformance ( DateTime  time,
decimal  value 
)
protectedvirtual

Sample the current daily performance directly with a time-value pair.

Parameters
timeTime of the sample.
valueCurrent daily performance value.

Reimplemented in QuantConnect.Lean.Engine.Results.RegressionResultHandler.

Definition at line 646 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleBenchmark()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SampleBenchmark ( DateTime  time,
decimal  value 
)
protectedvirtual

Sample the current benchmark performance directly with a time-value pair.

Parameters
timeTime of the sample.
valueCurrent benchmark value.
See also
IResultHandler.Sample

Definition at line 661 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleDrawdown()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SampleDrawdown ( DateTime  time,
decimal  currentPortfolioValue 
)
protectedvirtual

Sample drawdown of equity of the strategy

Parameters
timeTime of the sample
currentPortfolioValueCurrent equity value

Definition at line 671 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SamplePortfolioTurnover()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SamplePortfolioTurnover ( DateTime  time,
decimal  currentPortfolioValue 
)
protectedvirtual

Sample portfolio turn over of the strategy

Parameters
timeTime of the sample
currentPortfolioValueCurrent equity value

Definition at line 687 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleSalesVolume()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SampleSalesVolume ( DateTime  time)
protectedvirtual

Sample assets sales volume

Parameters
timeTime of the sample

Definition at line 722 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleExposure()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SampleExposure ( DateTime  time,
decimal  currentPortfolioValue 
)
protectedvirtual

Sample portfolio exposure long/short ratios by security type

Parameters
timeTime of the sample
currentPortfolioValueCurrent value of the portfolio

Definition at line 738 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ SampleCapacity()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SampleCapacity ( DateTime  time)
protectedvirtual

Sample estimated strategy capacity

Parameters
timeTime of the sample

Reimplemented in QuantConnect.Lean.Engine.Results.BacktestingResultHandler.

Definition at line 804 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ Sample() [2/2]

abstract void QuantConnect.Lean.Engine.Results.BaseResultsHandler.Sample ( string  chartName,
string  seriesName,
int  seriesIndex,
SeriesType  seriesType,
ISeriesPoint  value,
string  unit = "$" 
)
protectedpure virtual

Add a sample to the chart specified by the chartName, and seriesName.

Parameters
chartNameString chart name to place the sample.
seriesNameSeries name for the chart.
seriesIndexSeries chart index - which chart should this series belong
seriesTypeSeries type for the chart.
valueValue for the chart sample.
unitUnit for the chart axis

Sample can be used to create new charts or sample equity - daily performance.

Implemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler, and QuantConnect.Lean.Engine.Results.BacktestingResultHandler.

◆ GetAlgorithmRuntimeStatistics()

SortedDictionary<string, string> QuantConnect.Lean.Engine.Results.BaseResultsHandler.GetAlgorithmRuntimeStatistics ( Dictionary< string, string >  summary,
CapacityEstimate  capacityEstimate = null 
)
protected

Gets the algorithm runtime statistics

Definition at line 829 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetAlgorithmState()

void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SetAlgorithmState ( string  error,
string  stack 
)
protected

Sets the algorithm state data

Definition at line 863 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ GetAlgorithmState()

Dictionary<string, string> QuantConnect.Lean.Engine.Results.BaseResultsHandler.GetAlgorithmState ( DateTime?  endTime = null)
protected

Gets the algorithm state data

Definition at line 872 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ GenerateStatisticsResults() [1/2]

StatisticsResults QuantConnect.Lean.Engine.Results.BaseResultsHandler.GenerateStatisticsResults ( Dictionary< string, Chart charts,
SortedDictionary< DateTime, decimal >  profitLoss = null,
CapacityEstimate  estimatedStrategyCapacity = null 
)
protected

Will generate the statistics results and update the provided runtime statistics

Definition at line 897 of file BaseResultsHandler.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TotalTradesCount()

int QuantConnect.Lean.Engine.Results.BaseResultsHandler.TotalTradesCount ( )
protected

Helper method to get the total trade count statistic

Definition at line 949 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ GenerateStatisticsResults() [2/2]

StatisticsResults QuantConnect.Lean.Engine.Results.BaseResultsHandler.GenerateStatisticsResults ( CapacityEstimate  estimatedStrategyCapacity = null)
protected

Calculates and gets the current statistics for the algorithm. It will use the current Charts and profit loss information calculated from the current transaction record to generate the results.

Returns
The current statistics

Definition at line 960 of file BaseResultsHandler.cs.

Here is the call graph for this function:

◆ AddToLogStore()

virtual void QuantConnect.Lean.Engine.Results.BaseResultsHandler.AddToLogStore ( string  message)
protectedvirtual

Save an algorithm message to the log store. Uses a different timestamped method of adding messaging to interweve debug and logging messages.

Parameters
messageString message to store

Reimplemented in QuantConnect.Lean.Engine.Results.LiveTradingResultHandler, QuantConnect.Lean.Engine.Results.BacktestingResultHandler, and QuantConnect.Lean.Engine.Results.RegressionResultHandler.

Definition at line 982 of file BaseResultsHandler.cs.

◆ ProcessAlgorithmLogs()

void QuantConnect.Lean.Engine.Results.BaseResultsHandler.ProcessAlgorithmLogs ( int?  messageQueueLimit = null)
protected

Processes algorithm logs. Logs of the same type are batched together one per line and are sent out

Definition at line 995 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ SummaryStatistic()

void QuantConnect.Lean.Engine.Results.BaseResultsHandler.SummaryStatistic ( string  name,
string  value 
)
protected

Sets or updates a custom summary statistic

Parameters
nameThe statistic name
valueThe statistic value

Definition at line 1057 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

◆ UpdateAlgorithmEquity()

void QuantConnect.Lean.Engine.Results.BaseResultsHandler.UpdateAlgorithmEquity ( )
protected

Updates the current equity bar with the current equity value from GetPortfolioValue

Definition at line 1077 of file BaseResultsHandler.cs.

Here is the caller graph for this function:

Member Data Documentation

◆ StrategyEquityKey

const string QuantConnect.Lean.Engine.Results.BaseResultsHandler.StrategyEquityKey = "Strategy Equity"
static

String message saying: Strategy Equity

Definition at line 61 of file BaseResultsHandler.cs.

◆ EquityKey

const string QuantConnect.Lean.Engine.Results.BaseResultsHandler.EquityKey = "Equity"
static

String message saying: Equity

Definition at line 66 of file BaseResultsHandler.cs.

◆ ReturnKey

const string QuantConnect.Lean.Engine.Results.BaseResultsHandler.ReturnKey = "Return"
static

String message saying: Return

Definition at line 71 of file BaseResultsHandler.cs.

◆ BenchmarkKey

const string QuantConnect.Lean.Engine.Results.BaseResultsHandler.BenchmarkKey = "Benchmark"
static

String message saying: Benchmark

Definition at line 76 of file BaseResultsHandler.cs.

◆ DrawdownKey

const string QuantConnect.Lean.Engine.Results.BaseResultsHandler.DrawdownKey = "Drawdown"
static

String message saying: Drawdown

Definition at line 81 of file BaseResultsHandler.cs.

◆ PortfolioTurnoverKey

const string QuantConnect.Lean.Engine.Results.BaseResultsHandler.PortfolioTurnoverKey = "Portfolio Turnover"
static

String message saying: PortfolioTurnover

Definition at line 86 of file BaseResultsHandler.cs.

◆ PortfolioMarginKey

const string QuantConnect.Lean.Engine.Results.BaseResultsHandler.PortfolioMarginKey = "Portfolio Margin"
static

String message saying: Portfolio Margin

Definition at line 91 of file BaseResultsHandler.cs.

◆ AssetsSalesVolumeKey

const string QuantConnect.Lean.Engine.Results.BaseResultsHandler.AssetsSalesVolumeKey = "Assets Sales Volume"
static

String message saying: Portfolio Margin

Definition at line 96 of file BaseResultsHandler.cs.

◆ IsActive

bool QuantConnect.Lean.Engine.Results.BaseResultsHandler.IsActive => _updateRunner != null && _updateRunner.IsAlive

Boolean flag indicating the thread is still active.

Definition at line 162 of file BaseResultsHandler.cs.

◆ ExitTriggered

volatile bool QuantConnect.Lean.Engine.Results.BaseResultsHandler.ExitTriggered
protected

True if the exit has been triggered

Definition at line 177 of file BaseResultsHandler.cs.

Property Documentation

◆ MainUpdateInterval

virtual TimeSpan QuantConnect.Lean.Engine.Results.BaseResultsHandler.MainUpdateInterval = TimeSpan.FromSeconds(3)
getprotected

The main loop update interval

Definition at line 101 of file BaseResultsHandler.cs.

◆ ChartUpdateInterval

TimeSpan QuantConnect.Lean.Engine.Results.BaseResultsHandler.ChartUpdateInterval = TimeSpan.FromMinutes(1)
getsetprotected

The chart update interval

Definition at line 106 of file BaseResultsHandler.cs.

◆ LastDeltaOrderPosition

int QuantConnect.Lean.Engine.Results.BaseResultsHandler.LastDeltaOrderPosition
getsetprotected

The last position consumed from the ITransactionHandler.OrderEvents by GetDeltaOrders

Definition at line 111 of file BaseResultsHandler.cs.

◆ LastDeltaOrderEventsPosition

int QuantConnect.Lean.Engine.Results.BaseResultsHandler.LastDeltaOrderEventsPosition
getsetprotected

The last position consumed from the ITransactionHandler.OrderEvents while determining delta order events

Definition at line 116 of file BaseResultsHandler.cs.

◆ SerializerSettings

JsonSerializerSettings QuantConnect.Lean.Engine.Results.BaseResultsHandler.SerializerSettings
getsetprotected
Initial value:
= new ()
{
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
ProcessDictionaryKeys = false,
OverrideSpecifiedNames = true
}
}
}

Serializer settings to use

Definition at line 121 of file BaseResultsHandler.cs.

◆ CurrentAlgorithmEquity

Bar QuantConnect.Lean.Engine.Results.BaseResultsHandler.CurrentAlgorithmEquity
getsetprotected

The current aggregated equity bar for sampling. It will be aggregated with values from the GetPortfolioValue

Definition at line 138 of file BaseResultsHandler.cs.

◆ Messages

ConcurrentQueue<Packet> QuantConnect.Lean.Engine.Results.BaseResultsHandler.Messages
getset

Live packet messaging queue. Queue the messages here and send when the result queue is ready.

Definition at line 167 of file BaseResultsHandler.cs.

◆ Charts

ConcurrentDictionary<string, Chart> QuantConnect.Lean.Engine.Results.BaseResultsHandler.Charts
getset

Storage for the price and equity charts of the live results.

Definition at line 172 of file BaseResultsHandler.cs.

◆ ExitEvent

ManualResetEvent QuantConnect.Lean.Engine.Results.BaseResultsHandler.ExitEvent
getprotected

Event set when exit is triggered

Definition at line 182 of file BaseResultsHandler.cs.

◆ LogStore

List<LogEntry> QuantConnect.Lean.Engine.Results.BaseResultsHandler.LogStore
getprotected

The log store instance

Definition at line 187 of file BaseResultsHandler.cs.

◆ AlgorithmPerformanceCharts

List<string> QuantConnect.Lean.Engine.Results.BaseResultsHandler.AlgorithmPerformanceCharts = new List<string> { StrategyEquityKey, BenchmarkKey }
getprotected

Algorithms performance related chart names

Used to calculate the probabilistic sharpe ratio

Definition at line 193 of file BaseResultsHandler.cs.

◆ ChartLock

object QuantConnect.Lean.Engine.Results.BaseResultsHandler.ChartLock
getprotected

Lock to be used when accessing the chart collection

Definition at line 198 of file BaseResultsHandler.cs.

◆ ProjectId

int QuantConnect.Lean.Engine.Results.BaseResultsHandler.ProjectId
getsetprotected

The algorithm project id

Definition at line 203 of file BaseResultsHandler.cs.

◆ RamAllocation

string QuantConnect.Lean.Engine.Results.BaseResultsHandler.RamAllocation
getsetprotected

The maximum amount of RAM (in MB) this algorithm is allowed to utilize

Definition at line 208 of file BaseResultsHandler.cs.

◆ CompileId

string QuantConnect.Lean.Engine.Results.BaseResultsHandler.CompileId
getsetprotected

The algorithm unique compilation id

Definition at line 213 of file BaseResultsHandler.cs.

◆ AlgorithmId

string QuantConnect.Lean.Engine.Results.BaseResultsHandler.AlgorithmId
getsetprotected

The algorithm job id. This is the deploy id for live, backtesting id for backtesting

Definition at line 219 of file BaseResultsHandler.cs.

◆ StartTime

DateTime QuantConnect.Lean.Engine.Results.BaseResultsHandler.StartTime
getprotected

The result handler start time

Definition at line 224 of file BaseResultsHandler.cs.

◆ RuntimeStatistics

Dictionary<string, string> QuantConnect.Lean.Engine.Results.BaseResultsHandler.RuntimeStatistics
getprotected

Customizable dynamic statistics IAlgorithm.RuntimeStatistics

Definition at line 229 of file BaseResultsHandler.cs.

◆ State

Dictionary<string, string> QuantConnect.Lean.Engine.Results.BaseResultsHandler.State
getsetprotected

State of the algorithm

Definition at line 234 of file BaseResultsHandler.cs.

◆ MessagingHandler

IMessagingHandler QuantConnect.Lean.Engine.Results.BaseResultsHandler.MessagingHandler
getsetprotected

The handler responsible for communicating messages to listeners

Definition at line 239 of file BaseResultsHandler.cs.

◆ TransactionHandler

ITransactionHandler QuantConnect.Lean.Engine.Results.BaseResultsHandler.TransactionHandler
getsetprotected

The transaction handler used to get the algorithms Orders information

Definition at line 244 of file BaseResultsHandler.cs.

◆ StartingPortfolioValue

decimal QuantConnect.Lean.Engine.Results.BaseResultsHandler.StartingPortfolioValue
getsetprotected

The algorithms starting portfolio value. Used to calculate the portfolio return

Definition at line 250 of file BaseResultsHandler.cs.

◆ Algorithm

virtual IAlgorithm QuantConnect.Lean.Engine.Results.BaseResultsHandler.Algorithm
getsetprotected

The algorithm instance

Definition at line 255 of file BaseResultsHandler.cs.

◆ AlgorithmCurrencySymbol

string QuantConnect.Lean.Engine.Results.BaseResultsHandler.AlgorithmCurrencySymbol
getsetprotected

Algorithm currency symbol, used in charting

Definition at line 260 of file BaseResultsHandler.cs.

◆ DailyPortfolioValue

decimal QuantConnect.Lean.Engine.Results.BaseResultsHandler.DailyPortfolioValue
getsetprotected

Closing portfolio value. Used to calculate daily performance.

Definition at line 265 of file BaseResultsHandler.cs.

◆ CumulativeMaxPortfolioValue

decimal QuantConnect.Lean.Engine.Results.BaseResultsHandler.CumulativeMaxPortfolioValue
getsetprotected

Cumulative max portfolio value. Used to calculate drawdown underwater.

Definition at line 270 of file BaseResultsHandler.cs.

◆ ResamplePeriod

TimeSpan QuantConnect.Lean.Engine.Results.BaseResultsHandler.ResamplePeriod
getsetprotected

Sampling period for timespans between resamples of the charting equity.

Specifically critical for backtesting since with such long timeframes the sampled data can get extreme.

Definition at line 276 of file BaseResultsHandler.cs.

◆ NotificationPeriod

TimeSpan QuantConnect.Lean.Engine.Results.BaseResultsHandler.NotificationPeriod
getsetprotected

How frequently the backtests push messages to the browser.

Update frequency of notification packets

Definition at line 282 of file BaseResultsHandler.cs.

◆ ResultsDestinationFolder

string QuantConnect.Lean.Engine.Results.BaseResultsHandler.ResultsDestinationFolder
getsetprotected

Directory location to store results

Definition at line 287 of file BaseResultsHandler.cs.

◆ MapFileProvider

IMapFileProvider QuantConnect.Lean.Engine.Results.BaseResultsHandler.MapFileProvider
getsetprotected

The map file provider instance to use

Definition at line 292 of file BaseResultsHandler.cs.


The documentation for this class was generated from the following file: