Live Trading

Results

Introduction

The live results page shows your algorithm's live trading performance. Review the results page to see how your algorithm has been performing and to investigate ways to improve it.

View Live Results

The live results page automatically displays when you deploy a live algorithm. The page presents the algorithm's equity curve, holdings, trades, logs, server statistics, and much more information.

Live result interface

The content in the live results page updates as your algorithm executes. You can close or refresh the window without interrupting the algorithm because the live trading node processes on our servers. If you close the page, you can view all of your live projects to open the page again.

Runtime Statistics

The banner at the top of the live results page displays the performance statistics of your algorithm.

Live runtime statistics

The following table describes the default runtime statistics:

StatisticDescription
EquityThe total portfolio value if all of the holdings were sold at current market rates.
FeesThe total quantity of fees paid for all the transactions.
HoldingsThe absolute sum of the items in the portfolio.
Net ProfitThe dollar-value return across the entire trading period.
PSRThe probability that the estimated Sharpe ratio of an algorithm is greater than a benchmark (1).
ReturnThe rate of return across the entire trading period.
UnrealizedThe amount of profit a portfolio would capture if it liquidated all open positions and paid the fees for transacting and crossing the spread.
VolumeThe total value of assets traded for all of an algorithm's transactions.

To add a custom runtime statistic, see Add Statistics.

If you stop and redeploy a live algorithm, the runtime statistics are reset.

Built-in Charts

The live results page displays the equity curve of your algorithm so that you can analyze its performance in real-time.

Live strategy equity candle chart

The following table describes the series in the Strategy Equity chart:

SeriesDescription
EquityThe live equity curve of your algorithm.
Out of Sample BacktestThe backtest equity curve of your algorithm during the live trading period.
MetaPoints in time when you deployed your algorithm, stopped your algorithm, and when your algorithm encountered a runtime error.

The following table describes the other charts displayed on the page:

Chart
Description
DrawdownA time series of equity peak-to-trough value.
ExposureA time series of long and short exposure ratios.
Assets Sales VolumeA chart showing the proportion of total volume for each traded security.
Portfolio MarginA stacked area chart of the portfolio margin usage. For more information about this chart, see Portfolio Margin Plots.
Asset PlotA time series of an asset's price with order event annotations. For more information about these charts, see Asset Plots.

Asset Plots

Asset plots display the trade prices of an asset and the following order events you have for the asset:

Order EventIcon
SubmissionsGray circle
UpdatesBlue circle
CancellationsGray square
Fills and partial fillsGreen (buys) or red (sells) arrows

The following image shows an example asset plot for AAPL:

AAPL stock price with order events overlaid

View Plots

Follow these steps to open an asset plot:

  1. Open the live results page.
  2. Click the Orders tab.
  3. Click the Asset Plot icon that's next to the asset Symbol in the Orders table.

Tool Tips

When you hover over one of the order events in the table, the asset plot highlights the order event, displays the asset price at the time of the event, and displays the tag associated with the event. Consider adding helpful tags to each order event to help with debugging your algorithm. For example, when you cancel an order, you can add a tag that explains the reason for cancelling it.

Adjust the Display Period

The resolution of the asset price time series in the plot doesn't necessarily match the resolution you set when you subscribed to the asset in your algorithm. If you are displaying the entire price series, the series usually displays the daily closing price. However, when you zoom in, the chart will adjust its display period and may use higher resolution data. To zoom in and out, perform either of the following actions:

  • Click the 1m, 3m, 1y, or All period in the top-right corner of the chart.
  • Click a point on the chart and drag your mouse horizontally to highlight a specific period of time in the chart.
gif that shows the price of AAPL while zooming in and out

If you have multiple order events in a single day and you zoom out on the chart so that it displays the daily closing prices, the plot aggregates the order event icons together as the price on that day.

Order Fill Prices

The plot displays fill order events at the actual fill price of your orders. The fill price is usually not equal to the asset price that displays because of the following reasons:

  • Your order experiences slippage.
  • If you use quote data, your order fills at the bid or ask price.
  • The fill model may fill your order at the high or low price.

Custom Charts

The results page shows the custom charts that you create.

Supported Chart Types

We support the following types of charts:

If you use SeriesType.Candle and plot enough values, the plot displays candlesticks. However, the Plot method only accepts one numerical value per time step, so you can't plot candles that represent the open, high, low, and close values of each bar in your algorithm. The charting software automatically groups the data points you provide to create the candlesticks, so you can't control the period of time that each candlestick represents.

To create other types of charts, save the plot data in the Object Store and then load it into the Research Environment. In the Research Environment, you can create other types of charts with third-party charting packages.

Supported Markers

When you create scatter plots, you can set a marker symbol. We support the following marker symbols:

Chart Sampling

Charts are sampled every one and ten minutes. If you create 1-minute resolution custom charts, the IDE charting will downgrade the granularity and display the 10-minutes sampling after a certain amount of samples.

Demonstration

For more information about creating custom charts, see Charting.

Adjust Charts

You can manipulate the charts displayed on the live results page.

Toggle Charts

To display and hide a chart on the live results page, in the Select Chart section, click the name of a chart.

Toggle Chart Series

To display and hide a series on a chart on the live results page, click the name of a series at the top of a chart.

Demostration of toggling series displays on charts

Adjust the Display Period

To zoom in and out of a time series chart on the live results page, perform either of the following actions:

  • Click the 1m, 3m, 1y, or All period in the top-right corner of the chart.
  • Click a point on the chart and drag your mouse horizontally to highlight a specific period of time in the chart.
  • Demostration of zooming in for time period on charts

If you adjust the zoom on a chart, it affects all of the charts.

After you zoom in on a chart, slide the horizontal bar at the bottom of the chart to adjust the time frame that displays.

Demostration of scrolling for time period on charts

Resize Charts

To resize a chart on the live results page, hover over the bottom-right corner of the chart. When the resize cursor appears, hold the left mouse button and then drag to the desired size.

Move Charts

To move a chart on the live results page, click, hold, and drag the chart title.

Refresh Charts

Refreshing the charts on the live results page resets the zoom level on all the charts. If you refresh the charts while your algorithm is executing, only the data that was seen by the Lean engine after you refreshed the charts is displayed. To refresh the charts, in the Select Chart section, click the reset icon.

Holdings

The Holdings tab on the live results page displays your positions and cash.

Live holdings table

The following table describes the properties that display for each of your positions:

PropertyDescription
SymbolThe ticker of the security.
Average PriceThe average price that you paid for the position.
QuantityThe size of your position.
Market ValueThe value of your position if sold with market orders.
UnrealizedThe unrealized profit of your position, including fees and spread costs.

The values in the positions section update as new data points are injected into your algorithm. The cash section displays the quantity of each currency in your algorithm's CashBook. View the Holdings tab to see your holdings, add security subscriptions, and place manual orders. To view all of your current holdings and active data subscriptions, enable the Show All Portfolio check box.

Orders

The live results page displays the orders of your algorithm and you can download them to your local machine.

View in the GUI

To see the orders that your algorithm created, open the live results page and then click the Orders tab. If there are more than 10 orders, use the pagination tools at the bottom of the Orders Summary table to see all of the orders. Click on an individual order in the Orders Summary table to reveal all of the order events, which include:

  • Submissions
  • Fills
  • Partial fills
  • Updates
  • Cancellations
  • Option contract exercises and expiration

The timestamps in the Order Summary table are based in Eastern Time (ET).

Access the Order Summary CSV

To view the orders data in CSV format, open the live results page, click the Orders tab, and then click Download Orders. The content of the CSV file is the content displayed in the Orders Summary table when the table rows are collapsed. The timestamps in the CSV file are based in Coordinated Universal Time (UTC).

Insights

The live results page displays the insights of your algorithm and you can download them to your local machine.

View in the GUI

To see the insights your algorithm emit, open the live result page and then click the Insights tab. If there are more than 10 insights, use the pagination tools at the bottom of the Insights Summary table to see all of the insights. The timestamps in the Insights Summary table are based in Eastern Time (ET).

Download JSON

To view the insights in JSON format, open the live result page, click the Insights tab, and then click Download Insights. The timestamps in the CSV file are based in Coordinated Universal Time (UTC).

Logs

The Logs tab on the live results page displays all of the logging statements and status messages your algorithm creates. Their timestamps in the log file are in Coordinated Universal Time (UTC). The status messages include all of the points in time when your algorithm deployed, encountered an error, sent an order, or quit executing. It's good practice to add logs in live algorithms because then you can see what is happening while it executes. If you stop and redeploy your algorithm, the logs are retained. You can view the log file on the live results page or download them to your local machine.

View in the GUI

To see the log file your algorithm has created, open the live results page and then click the Logs tab.

To filter the logs, enter a search string in the Filter logs field.

Download Log File

To download the log file, open the live result page, click the Logs tab, and then click Download Logs.

Project Files

The live results page displays the project files used to deploy the algorithm. To view the files, click the Code tab. By default, the main.py or Main.cs file displays. To view other files in the project, click the file name and then select a different file from the drop-down menu.

Algorithm code snippets

View All Live Projects

The Your Strategies section of the Strategy Explorer page displays the status of all the live algorithms in your organizations. To view the page, log in to the Algorithm Lab and then, in the left navigation bar, click Strategy Explorer.

View live project in algorithm lab

Errors

If your live algorithm throws a runtime error, it stops executing and we send you an email. If you enabled automatic restarts when you deployed your algorithm, your algorithm will try five times to restart.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: