Backtest Management

Create Backtest

Introduction

Create a new backtest request and get the backtest Id.

Request

Create a new backtest given a project Id and compile Id. The /backtests/create API accepts requests in the following format:

CreateBacktestRequest Model - Request to create a new backtest.
projectId integer
Project Id we sent for compile.
compileId string
Compile Id for the project to backtest.
backtestName string
Name for the new backtest.
Example
{
  "projectId": 0,
  "compileId": "string",
  "backtestName": "string"
}

Responses

The /backtests/create API provides a response in the following format:

200 Success

BacktestResponse Model - Packet container for carrying Backtest results.
name string
Name of the backtest.
note string
Note on the backtest attached by the user.
backtestId string
Assigned backtest Id.
completed boolean
Boolean true when the backtest is completed.
progress number
Progress of the backtest in percent 0-1.
result BacktestResult object
Results object class. Results are exhaust from backtest or live algorithms running in LEAN.
error string
Backtest error message.
stacktrace string
Backtest error stacktrace.
created string($date-time)
Backtest creation date and time.
success boolean
Indicate if the API request was successful.
errors string Array
List of errors with the API call.
Example
{
  "name": "string",
  "note": "string",
  "backtestId": "string",
  "completed": true,
  "progress": 0,
  "result": {
    "RollingWindow": {
      "TradeStatistics": {
        "StartDateTime": "2021-11-26T15:18:27.693Z",
        "EndDateTime": "2021-11-26T15:18:27.693Z",
        "TotalNumberOfTrades": 0,
        "NumberOfWinningTrades": 0,
        "NumberOfLosingTrades": 0,
        "TotalProfitLoss": 0,
        "TotalProfit": 0,
        "TotalLoss": 0,
        "LargestProfit": 0,
        "LargestLoss": 0,
        "AverageProfitLoss": 0,
        "AverageProfit": 0,
        "AverageLoss": 0,
        "AverageTradeDuration": "string",
        "AverageWinningTradeDuration": "string",
        "AverageLosingTradeDuration": "string",
        "MedianTradeDuration": "string",
        "MedianWinningTradeDuration": "string",
        "MedianLosingTradeDuration": "string",
        "MaxConsecutiveWinningTrades": 0,
        "MaxConsecutiveLosingTrades": 0,
        "ProfitLossRatio": 0,
        "WinLossRatio": 0,
        "WinRate": 0,
        "LossRate": 0,
        "AverageMAE": 0,
        "AverageMFE": 0,
        "LargestMAE": 0,
        "LargestMFE": 0,
        "MaximumClosedTradeDrawdown": 0,
        "MaximumIntraTradeDrawdown": 0,
        "ProfitLossStandardDeviation": 0,
        "ProfitLossDownsideDeviation": 0,
        "ProfitFactor": 0,
        "SharpeRatio": 0,
        "SortinoRatio": 0,
        "ProfitToMaxDrawdownRatio": 0,
        "MaximumEndTradeDrawdown": 0,
        "AverageEndTradeDrawdown": 0,
        "MaximumDrawdownDuration": "string",
        "TotalFees": 0
      },
      "PortfolioStatistics": {
        "RiskFreeRate": 0,
        "AverageWinRate": 0,
        "AverageLossRate": 0,
        "ProfitLossRatio": 0,
        "WinRate": 0,
        "LossRate": 0,
        "Expectancy": 0,
        "CompoundingAnnualReturn": 0,
        "Drawdown": 0,
        "TotalNetProfit": 0,
        "SharpeRatio": 0,
        "ProbabilisticSharpeRatio": 0,
        "Alpha": 0,
        "Beta": 0,
        "AnnualStandardDeviation": 0,
        "AnnualVariance": 0,
        "InformationRatio": 0,
        "TrackingError": 0,
        "TreynorRatio": 0
      },
      "ClosedTrades": [
        {
          "Symbol": {
            "Value": "string",
            "ID": "string",
            "Permtick": "string"
          },
          "EntryTime": "2021-11-26T15:18:27.693Z",
          "EntryPrice": 0,
          "Direction": "Long",
          "Quantity": 0,
          "ExitTime": "2021-11-26T15:18:27.693Z",
          "ExitPrice": 0,
          "ProfitLoss": 0,
          "TotalFees": 0,
          "MAE": 0,
          "MFE": 0,
          "Duration": "string",
          "EndTradeDrawdown": 0
        }
      ]
    },
    "TotalPerformance": {
      "TradeStatistics": {
        "StartDateTime": "2021-11-26T15:18:27.693Z",
        "EndDateTime": "2021-11-26T15:18:27.693Z",
        "TotalNumberOfTrades": 0,
        "NumberOfWinningTrades": 0,
        "NumberOfLosingTrades": 0,
        "TotalProfitLoss": 0,
        "TotalProfit": 0,
        "TotalLoss": 0,
        "LargestProfit": 0,
        "LargestLoss": 0,
        "AverageProfitLoss": 0,
        "AverageProfit": 0,
        "AverageLoss": 0,
        "AverageTradeDuration": "string",
        "AverageWinningTradeDuration": "string",
        "AverageLosingTradeDuration": "string",
        "MedianTradeDuration": "string",
        "MedianWinningTradeDuration": "string",
        "MedianLosingTradeDuration": "string",
        "MaxConsecutiveWinningTrades": 0,
        "MaxConsecutiveLosingTrades": 0,
        "ProfitLossRatio": 0,
        "WinLossRatio": 0,
        "WinRate": 0,
        "LossRate": 0,
        "AverageMAE": 0,
        "AverageMFE": 0,
        "LargestMAE": 0,
        "LargestMFE": 0,
        "MaximumClosedTradeDrawdown": 0,
        "MaximumIntraTradeDrawdown": 0,
        "ProfitLossStandardDeviation": 0,
        "ProfitLossDownsideDeviation": 0,
        "ProfitFactor": 0,
        "SharpeRatio": 0,
        "SortinoRatio": 0,
        "ProfitToMaxDrawdownRatio": 0,
        "MaximumEndTradeDrawdown": 0,
        "AverageEndTradeDrawdown": 0,
        "MaximumDrawdownDuration": "string",
        "TotalFees": 0
      },
      "PortfolioStatistics": {
        "RiskFreeRate": 0,
        "AverageWinRate": 0,
        "AverageLossRate": 0,
        "ProfitLossRatio": 0,
        "WinRate": 0,
        "LossRate": 0,
        "Expectancy": 0,
        "CompoundingAnnualReturn": 0,
        "Drawdown": 0,
        "TotalNetProfit": 0,
        "SharpeRatio": 0,
        "ProbabilisticSharpeRatio": 0,
        "Alpha": 0,
        "Beta": 0,
        "AnnualStandardDeviation": 0,
        "AnnualVariance": 0,
        "InformationRatio": 0,
        "TrackingError": 0,
        "TreynorRatio": 0
      },
      "ClosedTrades": [
        {
          "Symbol": {
            "Value": "string",
            "ID": "string",
            "Permtick": "string"
          },
          "EntryTime": "2021-11-26T15:18:27.693Z",
          "EntryPrice": 0,
          "Direction": "Long",
          "Quantity": 0,
          "ExitTime": "2021-11-26T15:18:27.693Z",
          "ExitPrice": 0,
          "ProfitLoss": 0,
          "TotalFees": 0,
          "MAE": 0,
          "MFE": 0,
          "Duration": "string",
          "EndTradeDrawdown": 0
        }
      ]
    },
    "AlphaRuntimeStatistics": {
      "MeanPopulationScore": {
        "UpdatedTimeUtc": "2021-11-26T15:18:27.693Z",
        "Direction": 0,
        "Magnitude": 0,
        "IsFinalScore": true
      },
      "RollingAveragedPopulationScore": {
        "UpdatedTimeUtc": "2021-11-26T15:18:27.693Z",
        "Direction": 0,
        "Magnitude": 0,
        "IsFinalScore": true
      },
      "LongCount": "string",
      "ShortCount": "string",
      "LongShortRatio": 0,
      "TotalAccumulatedEstimatedAlphaValue": 0,
      "KellyCriterionEstimate": 0,
      "KellyCriterionProbabilityValue": 0,
      "FitnessScore": 0,
      "PortfolioTurnover": 0,
      "ReturnOverMaxDrawdown": 0,
      "SortinoRatio": 0,
      "EstimatedMonthlyAlphaValue": 0,
      "TotalInsightsGenerated": "string",
      "TotalInsightsClosed": "string",
      "TotalInsightsAnalysisCompleted": "string",
      "MeanPopulationEstimatedInsightValue": 0
    },
    "Charts": {
      "Name": "string",
      "ChartType": "Overlay",
      "Series": {
        "Name": "string",
        "Unit": "string",
        "Index": 0,
        "Values": [
          {
            "x": "string",
            "y": 0
          }
        ],
        "SeriesType": "Line",
        "Color": "string",
        "ScatterMarkerSymbol": "none"
      }
    },
    "Orders": {
      "Id": 0,
      "ContingentId": 0,
      "BrokerId": [
        "string"
      ],
      "Symbol": {
        "Value": "string",
        "ID": "string",
        "Permtick": "string"
      },
      "Price": 0,
      "PriceCurrency": "string",
      "Time": "2021-11-26T15:18:27.693Z",
      "CreatedTime": "2021-11-26T15:18:27.693Z",
      "LastFillTime": "2021-11-26T15:18:27.693Z",
      "LastUpdateTime": "2021-11-26T15:18:27.693Z",
      "CanceledTime": "2021-11-26T15:18:27.693Z",
      "Quantity": 0,
      "Type": "Market",
      "Status": "New",
      "Tag": "string",
      "SecurityType": "Base",
      "Direction": "Buy",
      "Value": 0,
      "OrderSubmissionData": {
        "BidPrice": 0,
        "AskPrice": 0,
        "LastPrice": 0
      },
      "IsMarketable": true
    },
    "OrderEvents": [
      {
        "OrderId": 0,
        "Id": 0,
        "Symbol": {
          "Value": "string",
          "ID": "string",
          "Permtick": "string"
        },
        "UtcTime": "2021-11-26T15:18:27.693Z",
        "Status": {
          "OrderId": 0,
          "Id": 0,
          "Symbol": {
            "Value": "string",
            "ID": "string",
            "Permtick": "string"
          },
          "UtcTime": "2021-11-26T15:18:27.693Z",
          "Status": "New",
          "FillPrice": 0,
          "FillPriceCurrency": "string",
          "FillQuantity": 0,
          "Direction": "Buy",
          "Message": "string",
          "IsAssignment": true,
          "StopPrice": 0,
          "LimitPrice": 0,
          "Quantity": 0
        },
        "OrderFee": {
          "Value": {
            "Amount": 0,
            "Currency": "string"
          }
        },
        "FillPrice": 0,
        "FillPriceCurrency": "string",
        "FillQuantity": 0,
        "Direction": "Buy",
        "Message": "string",
        "IsAssignment": true,
        "StopPrice": 0,
        "LimitPrice": 0,
        "Quantity": 0
      }
    ],
    "ProfitLoss": "number",
    "Statistics": "string",
    "RuntimeStatistics": "string",
    "ServerStatistics": "string"
  },
  "error": "string",
  "stacktrace": "string",
  "created": "2021-11-26T15:18:27.693Z",
  "success": true,
  "errors": [
    "string"
  ]
}
BacktestResult Model - Results object class. Results are exhaust from backtest or live algorithms running in LEAN.
RollingWindow AlgorithmPerformance object
Rolling window detailed statistics.
TotalPerformance AlgorithmPerformance object
The AlgorithmPerformance class is a wrapper for TradeStatistics and PortfolioStatistics.
AlphaRuntimeStatistics AlphaRuntimeStatistics object
Contains insight population run time statistics.
Charts Chart object
Charts updates for the live algorithm since the last result packet.
Orders Order object
Order updates since the last result packet.
OrderEvents OrderEvent Array
OrderEvent updates since the last result packet.
ProfitLoss number object
Trade profit and loss information since the last algorithm result packet.
Statistics string object
Statistics information sent during the algorithm operations.
RuntimeStatistics string object
Runtime banner/updating statistics in the title banner of the live algorithm GUI.
ServerStatistics string object
Server status information, including CPU and RAM usage.
Example
{
  "RollingWindow": {
    "TradeStatistics": {
      "StartDateTime": "2021-11-26T15:18:27.693Z",
      "EndDateTime": "2021-11-26T15:18:27.693Z",
      "TotalNumberOfTrades": 0,
      "NumberOfWinningTrades": 0,
      "NumberOfLosingTrades": 0,
      "TotalProfitLoss": 0,
      "TotalProfit": 0,
      "TotalLoss": 0,
      "LargestProfit": 0,
      "LargestLoss": 0,
      "AverageProfitLoss": 0,
      "AverageProfit": 0,
      "AverageLoss": 0,
      "AverageTradeDuration": "string",
      "AverageWinningTradeDuration": "string",
      "AverageLosingTradeDuration": "string",
      "MedianTradeDuration": "string",
      "MedianWinningTradeDuration": "string",
      "MedianLosingTradeDuration": "string",
      "MaxConsecutiveWinningTrades": 0,
      "MaxConsecutiveLosingTrades": 0,
      "ProfitLossRatio": 0,
      "WinLossRatio": 0,
      "WinRate": 0,
      "LossRate": 0,
      "AverageMAE": 0,
      "AverageMFE": 0,
      "LargestMAE": 0,
      "LargestMFE": 0,
      "MaximumClosedTradeDrawdown": 0,
      "MaximumIntraTradeDrawdown": 0,
      "ProfitLossStandardDeviation": 0,
      "ProfitLossDownsideDeviation": 0,
      "ProfitFactor": 0,
      "SharpeRatio": 0,
      "SortinoRatio": 0,
      "ProfitToMaxDrawdownRatio": 0,
      "MaximumEndTradeDrawdown": 0,
      "AverageEndTradeDrawdown": 0,
      "MaximumDrawdownDuration": "string",
      "TotalFees": 0
    },
    "PortfolioStatistics": {
      "RiskFreeRate": 0,
      "AverageWinRate": 0,
      "AverageLossRate": 0,
      "ProfitLossRatio": 0,
      "WinRate": 0,
      "LossRate": 0,
      "Expectancy": 0,
      "CompoundingAnnualReturn": 0,
      "Drawdown": 0,
      "TotalNetProfit": 0,
      "SharpeRatio": 0,
      "ProbabilisticSharpeRatio": 0,
      "Alpha": 0,
      "Beta": 0,
      "AnnualStandardDeviation": 0,
      "AnnualVariance": 0,
      "InformationRatio": 0,
      "TrackingError": 0,
      "TreynorRatio": 0
    },
    "ClosedTrades": [
      {
        "Symbol": {
          "Value": "string",
          "ID": "string",
          "Permtick": "string"
        },
        "EntryTime": "2021-11-26T15:18:27.693Z",
        "EntryPrice": 0,
        "Direction": "Long",
        "Quantity": 0,
        "ExitTime": "2021-11-26T15:18:27.693Z",
        "ExitPrice": 0,
        "ProfitLoss": 0,
        "TotalFees": 0,
        "MAE": 0,
        "MFE": 0,
        "Duration": "string",
        "EndTradeDrawdown": 0
      }
    ]
  },
  "TotalPerformance": {
    "TradeStatistics": {
      "StartDateTime": "2021-11-26T15:18:27.693Z",
      "EndDateTime": "2021-11-26T15:18:27.693Z",
      "TotalNumberOfTrades": 0,
      "NumberOfWinningTrades": 0,
      "NumberOfLosingTrades": 0,
      "TotalProfitLoss": 0,
      "TotalProfit": 0,
      "TotalLoss": 0,
      "LargestProfit": 0,
      "LargestLoss": 0,
      "AverageProfitLoss": 0,
      "AverageProfit": 0,
      "AverageLoss": 0,
      "AverageTradeDuration": "string",
      "AverageWinningTradeDuration": "string",
      "AverageLosingTradeDuration": "string",
      "MedianTradeDuration": "string",
      "MedianWinningTradeDuration": "string",
      "MedianLosingTradeDuration": "string",
      "MaxConsecutiveWinningTrades": 0,
      "MaxConsecutiveLosingTrades": 0,
      "ProfitLossRatio": 0,
      "WinLossRatio": 0,
      "WinRate": 0,
      "LossRate": 0,
      "AverageMAE": 0,
      "AverageMFE": 0,
      "LargestMAE": 0,
      "LargestMFE": 0,
      "MaximumClosedTradeDrawdown": 0,
      "MaximumIntraTradeDrawdown": 0,
      "ProfitLossStandardDeviation": 0,
      "ProfitLossDownsideDeviation": 0,
      "ProfitFactor": 0,
      "SharpeRatio": 0,
      "SortinoRatio": 0,
      "ProfitToMaxDrawdownRatio": 0,
      "MaximumEndTradeDrawdown": 0,
      "AverageEndTradeDrawdown": 0,
      "MaximumDrawdownDuration": "string",
      "TotalFees": 0
    },
    "PortfolioStatistics": {
      "RiskFreeRate": 0,
      "AverageWinRate": 0,
      "AverageLossRate": 0,
      "ProfitLossRatio": 0,
      "WinRate": 0,
      "LossRate": 0,
      "Expectancy": 0,
      "CompoundingAnnualReturn": 0,
      "Drawdown": 0,
      "TotalNetProfit": 0,
      "SharpeRatio": 0,
      "ProbabilisticSharpeRatio": 0,
      "Alpha": 0,
      "Beta": 0,
      "AnnualStandardDeviation": 0,
      "AnnualVariance": 0,
      "InformationRatio": 0,
      "TrackingError": 0,
      "TreynorRatio": 0
    },
    "ClosedTrades": [
      {
        "Symbol": {
          "Value": "string",
          "ID": "string",
          "Permtick": "string"
        },
        "EntryTime": "2021-11-26T15:18:27.693Z",
        "EntryPrice": 0,
        "Direction": "Long",
        "Quantity": 0,
        "ExitTime": "2021-11-26T15:18:27.693Z",
        "ExitPrice": 0,
        "ProfitLoss": 0,
        "TotalFees": 0,
        "MAE": 0,
        "MFE": 0,
        "Duration": "string",
        "EndTradeDrawdown": 0
      }
    ]
  },
  "AlphaRuntimeStatistics": {
    "MeanPopulationScore": {
      "UpdatedTimeUtc": "2021-11-26T15:18:27.693Z",
      "Direction": 0,
      "Magnitude": 0,
      "IsFinalScore": true
    },
    "RollingAveragedPopulationScore": {
      "UpdatedTimeUtc": "2021-11-26T15:18:27.693Z",
      "Direction": 0,
      "Magnitude": 0,
      "IsFinalScore": true
    },
    "LongCount": "string",
    "ShortCount": "string",
    "LongShortRatio": 0,
    "TotalAccumulatedEstimatedAlphaValue": 0,
    "KellyCriterionEstimate": 0,
    "KellyCriterionProbabilityValue": 0,
    "FitnessScore": 0,
    "PortfolioTurnover": 0,
    "ReturnOverMaxDrawdown": 0,
    "SortinoRatio": 0,
    "EstimatedMonthlyAlphaValue": 0,
    "TotalInsightsGenerated": "string",
    "TotalInsightsClosed": "string",
    "TotalInsightsAnalysisCompleted": "string",
    "MeanPopulationEstimatedInsightValue": 0
  },
  "Charts": {
    "Name": "string",
    "ChartType": "Overlay",
    "Series": {
      "Name": "string",
      "Unit": "string",
      "Index": 0,
      "Values": [
        {
          "x": "string",
          "y": 0
        }
      ],
      "SeriesType": "Line",
      "Color": "string",
      "ScatterMarkerSymbol": "none"
    }
  },
  "Orders": {
    "Id": 0,
    "ContingentId": 0,
    "BrokerId": [
      "string"
    ],
    "Symbol": {
      "Value": "string",
      "ID": "string",
      "Permtick": "string"
    },
    "Price": 0,
    "PriceCurrency": "string",
    "Time": "2021-11-26T15:18:27.693Z",
    "CreatedTime": "2021-11-26T15:18:27.693Z",
    "LastFillTime": "2021-11-26T15:18:27.693Z",
    "LastUpdateTime": "2021-11-26T15:18:27.693Z",
    "CanceledTime": "2021-11-26T15:18:27.693Z",
    "Quantity": 0,
    "Type": "Market",
    "Status": "New",
    "Tag": "string",
    "SecurityType": "Base",
    "Direction": "Buy",
    "Value": 0,
    "OrderSubmissionData": {
      "BidPrice": 0,
      "AskPrice": 0,
      "LastPrice": 0
    },
    "IsMarketable": true
  },
  "OrderEvents": [
    {
      "OrderId": 0,
      "Id": 0,
      "Symbol": {
        "Value": "string",
        "ID": "string",
        "Permtick": "string"
      },
      "UtcTime": "2021-11-26T15:18:27.693Z",
      "Status": {
        "OrderId": 0,
        "Id": 0,
        "Symbol": {
          "Value": "string",
          "ID": "string",
          "Permtick": "string"
        },
        "UtcTime": "2021-11-26T15:18:27.693Z",
        "Status": "New",
        "FillPrice": 0,
        "FillPriceCurrency": "string",
        "FillQuantity": 0,
        "Direction": "Buy",
        "Message": "string",
        "IsAssignment": true,
        "StopPrice": 0,
        "LimitPrice": 0,
        "Quantity": 0
      },
      "OrderFee": {
        "Value": {
          "Amount": 0,
          "Currency": "string"
        }
      },
      "FillPrice": 0,
      "FillPriceCurrency": "string",
      "FillQuantity": 0,
      "Direction": "Buy",
      "Message": "string",
      "IsAssignment": true,
      "StopPrice": 0,
      "LimitPrice": 0,
      "Quantity": 0
    }
  ],
  "ProfitLoss": "number",
  "Statistics": "string",
  "RuntimeStatistics": "string",
  "ServerStatistics": "string"
}
AlgorithmPerformance Model - The AlgorithmPerformance class is a wrapper for TradeStatistics and PortfolioStatistics.
TradeStatistics TradeStatistics object
A set of statistics calculated from a list of closed trades.
PortfolioStatistics PortfolioStatistics object
Represents a set of statistics calculated from equity and benchmark samples.
ClosedTrades Trade Array
The algorithm statistics on portfolio.
Example
{
  "TradeStatistics": {
    "StartDateTime": "2021-11-26T15:18:27.693Z",
    "EndDateTime": "2021-11-26T15:18:27.693Z",
    "TotalNumberOfTrades": 0,
    "NumberOfWinningTrades": 0,
    "NumberOfLosingTrades": 0,
    "TotalProfitLoss": 0,
    "TotalProfit": 0,
    "TotalLoss": 0,
    "LargestProfit": 0,
    "LargestLoss": 0,
    "AverageProfitLoss": 0,
    "AverageProfit": 0,
    "AverageLoss": 0,
    "AverageTradeDuration": "string",
    "AverageWinningTradeDuration": "string",
    "AverageLosingTradeDuration": "string",
    "MedianTradeDuration": "string",
    "MedianWinningTradeDuration": "string",
    "MedianLosingTradeDuration": "string",
    "MaxConsecutiveWinningTrades": 0,
    "MaxConsecutiveLosingTrades": 0,
    "ProfitLossRatio": 0,
    "WinLossRatio": 0,
    "WinRate": 0,
    "LossRate": 0,
    "AverageMAE": 0,
    "AverageMFE": 0,
    "LargestMAE": 0,
    "LargestMFE": 0,
    "MaximumClosedTradeDrawdown": 0,
    "MaximumIntraTradeDrawdown": 0,
    "ProfitLossStandardDeviation": 0,
    "ProfitLossDownsideDeviation": 0,
    "ProfitFactor": 0,
    "SharpeRatio": 0,
    "SortinoRatio": 0,
    "ProfitToMaxDrawdownRatio": 0,
    "MaximumEndTradeDrawdown": 0,
    "AverageEndTradeDrawdown": 0,
    "MaximumDrawdownDuration": "string",
    "TotalFees": 0
  },
  "PortfolioStatistics": {
    "RiskFreeRate": 0,
    "AverageWinRate": 0,
    "AverageLossRate": 0,
    "ProfitLossRatio": 0,
    "WinRate": 0,
    "LossRate": 0,
    "Expectancy": 0,
    "CompoundingAnnualReturn": 0,
    "Drawdown": 0,
    "TotalNetProfit": 0,
    "SharpeRatio": 0,
    "ProbabilisticSharpeRatio": 0,
    "Alpha": 0,
    "Beta": 0,
    "AnnualStandardDeviation": 0,
    "AnnualVariance": 0,
    "InformationRatio": 0,
    "TrackingError": 0,
    "TreynorRatio": 0
  },
  "ClosedTrades": [
    {
      "Symbol": {
        "Value": "string",
        "ID": "string",
        "Permtick": "string"
      },
      "EntryTime": "2021-11-26T15:18:27.693Z",
      "EntryPrice": 0,
      "Direction": "Long",
      "Quantity": 0,
      "ExitTime": "2021-11-26T15:18:27.693Z",
      "ExitPrice": 0,
      "ProfitLoss": 0,
      "TotalFees": 0,
      "MAE": 0,
      "MFE": 0,
      "Duration": "string",
      "EndTradeDrawdown": 0
    }
  ]
}
TradeStatistics Model - A set of statistics calculated from a list of closed trades.
StartDateTime string($date-time)
The entry date/time of the first trade.
EndDateTime string($date-time)
The exit date/time of the first trade.
TotalNumberOfTrades integer
The total number of trades.
NumberOfWinningTrades integer
The total number of winning trades.
NumberOfLosingTrades integer
The total number of losing trades.
TotalProfitLoss number
The total profit/loss for all trades (as symbol currency).
TotalProfit number
The total profit for all winning trades (as symbol currency).
TotalLoss number
The total loss for all losing trades (as symbol currency).
LargestProfit number
The largest profit in a single trade (as symbol currency).
LargestLoss number
The largest loss in a single trade (as symbol currency).
AverageProfitLoss number
The average profit/loss (a.k.a. Expectancy or Average Trade) for all trades (as symbol currency).
AverageProfit number
The average profit for all winning trades (as symbol currency).
AverageLoss number
The average loss for all winning trades (as symbol currency).
AverageTradeDuration string
The average duration for all trades.
AverageWinningTradeDuration string
The average duration for all winning trades.
AverageLosingTradeDuration string
The average duration for all losing trades.
MedianTradeDuration string
The median duration for all trades.
MedianWinningTradeDuration string
The median duration for all winning trades.
MedianLosingTradeDuration string
The median duration for all losing trades.
MaxConsecutiveWinningTrades integer
The maximum number of consecutive winning trades.
MaxConsecutiveLosingTrades integer
The maximum number of consecutive losing trades.
ProfitLossRatio number
The ratio of the average profit per trade to the average loss per trade.
WinLossRatio number
The ratio of the number of winning trades to the number of losing trades.
WinRate number
The ratio of the number of winning trades to the total number of trades.
LossRate number
The ratio of the number of losing trades to the total number of trades.
AverageMAE number
The average Maximum Adverse Excursion for all trades.
AverageMFE number
The average Maximum Adverse Excursion for all trades.
LargestMAE number
The average Maximum Favorable Excursion for all trades.
LargestMFE number
The largest Maximum Adverse Excursion in a single trade (as symbol currency).
MaximumClosedTradeDrawdown number
The maximum closed-trade drawdown for all trades (as symbol currency).
MaximumIntraTradeDrawdown number
The maximum intra-trade drawdown for all trades (as symbol currency).
ProfitLossStandardDeviation number
The standard deviation of the profits/losses for all trades (as symbol currency).
ProfitLossDownsideDeviation number
The downside deviation of the profits/losses for all trades (as symbol currency).
ProfitFactor number
The ratio of the total profit to the total loss.
SharpeRatio number
The ratio of the average profit/loss to the standard deviation.
SortinoRatio number
The ratio of the average profit/loss to the downside deviation.
ProfitToMaxDrawdownRatio number
The ratio of the total profit/loss to the maximum closed trade drawdown.
MaximumEndTradeDrawdown number
The maximum amount of profit given back by a single trade before exit (as symbol currency).
AverageEndTradeDrawdown number
The average amount of profit given back by all trades before exit (as symbol currency).
MaximumDrawdownDuration string
The maximum amount of time to recover from a drawdown (longest time between new equity highs or peaks).
TotalFees number
The sum of fees for all trades.
Example
{
  "StartDateTime": "2021-11-26T15:18:27.693Z",
  "EndDateTime": "2021-11-26T15:18:27.693Z",
  "TotalNumberOfTrades": 0,
  "NumberOfWinningTrades": 0,
  "NumberOfLosingTrades": 0,
  "TotalProfitLoss": 0,
  "TotalProfit": 0,
  "TotalLoss": 0,
  "LargestProfit": 0,
  "LargestLoss": 0,
  "AverageProfitLoss": 0,
  "AverageProfit": 0,
  "AverageLoss": 0,
  "AverageTradeDuration": "string",
  "AverageWinningTradeDuration": "string",
  "AverageLosingTradeDuration": "string",
  "MedianTradeDuration": "string",
  "MedianWinningTradeDuration": "string",
  "MedianLosingTradeDuration": "string",
  "MaxConsecutiveWinningTrades": 0,
  "MaxConsecutiveLosingTrades": 0,
  "ProfitLossRatio": 0,
  "WinLossRatio": 0,
  "WinRate": 0,
  "LossRate": 0,
  "AverageMAE": 0,
  "AverageMFE": 0,
  "LargestMAE": 0,
  "LargestMFE": 0,
  "MaximumClosedTradeDrawdown": 0,
  "MaximumIntraTradeDrawdown": 0,
  "ProfitLossStandardDeviation": 0,
  "ProfitLossDownsideDeviation": 0,
  "ProfitFactor": 0,
  "SharpeRatio": 0,
  "SortinoRatio": 0,
  "ProfitToMaxDrawdownRatio": 0,
  "MaximumEndTradeDrawdown": 0,
  "AverageEndTradeDrawdown": 0,
  "MaximumDrawdownDuration": "string",
  "TotalFees": 0
}
PortfolioStatistics Model - Represents a set of statistics calculated from equity and benchmark samples.
RiskFreeRate number
The current defined risk free annual return rate.
AverageWinRate number
The average rate of return for winning trades.
AverageLossRate number
The average rate of return for losing trades.
ProfitLossRatio number
The ratio of the average win rate to the average loss rate.
WinRate number
The ratio of the number of winning trades to the total number of trades.
LossRate number
The ratio of the number of losing trades to the total number of trades.
Expectancy number
The expected value of the rate of return.
CompoundingAnnualReturn number
Annual compounded returns statistic based on the final-starting capital and years.
Drawdown number
Drawdown maximum percentage.
TotalNetProfit number
The total net profit percentage.
SharpeRatio number
Sharpe ratio with respect to risk free rate: measures excess of return per unit of risk.
ProbabilisticSharpeRatio number
Probabilistic Sharpe Ratio is a probability measure associated with the Sharpe ratio. It informs us of the probability that the estimated Sharpe ratio is greater than a chosen benchmark.
Alpha number
Algorithm "Alpha" statistic - abnormal returns over the risk free rate and the relationshio (beta) with the benchmark returns.
Beta number
Algorithm beta statistic - the covariance between the algorithm and benchmark performance, divided by benchmark variance.
AnnualStandardDeviation number
Annualized standard deviation.
AnnualVariance number
Annualized variance statistic calculation using the daily performance variance and trading days per year.
InformationRatio number
Information ratio - risk adjusted return.
TrackingError number
Tracking error volatility (TEV) statistic - a measure of how closely a portfolio follows the index to which it is benchmarked.
TreynorRatio number
Treynor ratio statistic is a measurement of the returns earned in excess of that which could have been earned on an investment that has no diversifiable risk.
Example
{
  "RiskFreeRate": 0,
  "AverageWinRate": 0,
  "AverageLossRate": 0,
  "ProfitLossRatio": 0,
  "WinRate": 0,
  "LossRate": 0,
  "Expectancy": 0,
  "CompoundingAnnualReturn": 0,
  "Drawdown": 0,
  "TotalNetProfit": 0,
  "SharpeRatio": 0,
  "ProbabilisticSharpeRatio": 0,
  "Alpha": 0,
  "Beta": 0,
  "AnnualStandardDeviation": 0,
  "AnnualVariance": 0,
  "InformationRatio": 0,
  "TrackingError": 0,
  "TreynorRatio": 0
}
Trade Model - Represents a closed trade.
Symbol Symbol object
Represents a unique security identifier. This is made of two components, the unique SID and the Value. The value is the current ticker symbol while the SID is constant over the life of a security.
EntryTime string($date-time)
The date and time the trade was opened.
EntryPrice number
The price at which the trade was opened (or the average price if multiple entries).
Direction string Enum
Direction of a trade. Options : ['Long', 'Short']
Quantity number
The total unsigned quantity of the trade.
ExitTime string($date-time)
The date and time the trade was closed.
ExitPrice number
The price at which the trade was closed (or the average price if multiple exits).
ProfitLoss number
The gross profit/loss of the trade (as account currency).
TotalFees number
The total fees associated with the trade (always positive value) (as account currency).
MAE number
The Maximum Adverse Excursion (as account currency).
MFE number
The Maximum Favorable Excursion (as account currency).
Duration string
The duration of the trade.
EndTradeDrawdown number
The amount of profit given back before the trade was closed.
Example
{
  "Symbol": {
    "Value": "string",
    "ID": "string",
    "Permtick": "string"
  },
  "EntryTime": "2021-11-26T15:18:27.693Z",
  "EntryPrice": 0,
  "Direction": "Long",
  "Quantity": 0,
  "ExitTime": "2021-11-26T15:18:27.693Z",
  "ExitPrice": 0,
  "ProfitLoss": 0,
  "TotalFees": 0,
  "MAE": 0,
  "MFE": 0,
  "Duration": "string",
  "EndTradeDrawdown": 0
}
Symbol Model - Represents a unique security identifier. This is made of two components, the unique SID and the Value. The value is the current ticker symbol while the SID is constant over the life of a security.
Value string
The current symbol for this ticker.
ID string
The security identifier for this symbol.
Permtick string
The current symbol for this ticker.
Example
{
  "Value": "string",
  "ID": "string",
  "Permtick": "string"
}
TradeDirection Model - Direction of a trade.
TradeDirection string Enum
Direction of a trade. Options : ['Long', 'Short']
Example
{
  "TradeDirection": "Long"
}
AlphaRuntimeStatistics Model - Contains insight population run time statistics.
MeanPopulationScore InsightScore object
Defines the scores given to a particular insight.
RollingAveragedPopulationScore InsightScore object
Defines the scores given to a particular insight.
LongCount string
Gets the total number of insights with an up direction.
ShortCount string
Gets the total number of insights with a down direction.
LongShortRatio number
The ratio of InsightDirection.Up over InsightDirection.Down.
TotalAccumulatedEstimatedAlphaValue number
The total accumulated estimated value of trading all insights.
KellyCriterionEstimate number
Score of the strategy's insights predictive power.
KellyCriterionProbabilityValue number
The p-value or probability value of the KellyCriterionEstimate.
FitnessScore number
Score of the strategy's performance, and suitability for the Alpha Stream Market.
PortfolioTurnover number
Measurement of the strategies trading activity with respect to the portfolio value. Calculated as the sales volume with respect to the average total portfolio value.
ReturnOverMaxDrawdown number
Provides a risk adjusted way to factor in the returns and drawdown of the strategy. It is calculated by dividing the Portfolio Annualized Return by the Maximum Drawdown seen during the backtest.
SortinoRatio number
Gives a relative picture of the strategy volatility. It is calculated by taking a portfolio's annualized rate of return and subtracting the risk free rate of return.
EstimatedMonthlyAlphaValue number
Suggested Value of the Alpha On A Monthly Basis For Licensing.
TotalInsightsGenerated string
The total number of insight signals generated by the algorithm.
TotalInsightsClosed string
The total number of insight signals generated by the algorithm.
TotalInsightsAnalysisCompleted string
The total number of insight signals generated by the algorithm.
MeanPopulationEstimatedInsightValue number
Gets the mean estimated insight value.
Example
{
  "MeanPopulationScore": {
    "UpdatedTimeUtc": "2021-11-26T15:18:27.693Z",
    "Direction": 0,
    "Magnitude": 0,
    "IsFinalScore": true
  },
  "RollingAveragedPopulationScore": {
    "UpdatedTimeUtc": "2021-11-26T15:18:27.693Z",
    "Direction": 0,
    "Magnitude": 0,
    "IsFinalScore": true
  },
  "LongCount": "string",
  "ShortCount": "string",
  "LongShortRatio": 0,
  "TotalAccumulatedEstimatedAlphaValue": 0,
  "KellyCriterionEstimate": 0,
  "KellyCriterionProbabilityValue": 0,
  "FitnessScore": 0,
  "PortfolioTurnover": 0,
  "ReturnOverMaxDrawdown": 0,
  "SortinoRatio": 0,
  "EstimatedMonthlyAlphaValue": 0,
  "TotalInsightsGenerated": "string",
  "TotalInsightsClosed": "string",
  "TotalInsightsAnalysisCompleted": "string",
  "MeanPopulationEstimatedInsightValue": 0
}
InsightScore Model - Defines the scores given to a particular insight
UpdatedTimeUtc string($date-time)
The time these scores were last updated.
Direction number
The direction score.
Magnitude number
The magnitude score.
IsFinalScore boolean
Is the insight past its expiry time and score can be finalized.
Example
{
  "UpdatedTimeUtc": "2021-11-26T15:18:27.693Z",
  "Direction": 0,
  "Magnitude": 0,
  "IsFinalScore": true
}
Chart Model - Single Parent Chart Object for Custom Charting.
Name string
Name of the Chart.
ChartType string Enum
Type of the Chart, Overlayed or Stacked. Options : ['Overlay', 'Stacked']
Series Series object
List of Series Objects for this Chart.
Example
{
  "Name": "string",
  "ChartType": "Overlay",
  "Series": {
    "Name": "string",
    "Unit": "string",
    "Index": 0,
    "Values": [
      {
        "x": "string",
        "y": 0
      }
    ],
    "SeriesType": "Line",
    "Color": "string",
    "ScatterMarkerSymbol": "none"
  }
}
Series Model - Chart Series Object - Series data and properties for a chart.
Name string
Name of the series.
Unit string
Axis for the chart series.
Index integer
Index/position of the series on the chart.
Values ChartPoint Array
Values for the series plot. These values are assumed to be in ascending time order (first points earliest, last points latest).
SeriesType string Enum
Chart type for the series. Options : ['Line', 'Scatter', 'Candle', 'Bar', 'Flag', 'StackedArea', 'Pie', 'Treemap']
Color string
Color the series.
ScatterMarkerSymbol string Enum
Shape or symbol for the marker in a scatter plot. Options : ['none', 'circle', 'square', 'diamond', 'triangle', 'triangle-down']
Example
{
  "Name": "string",
  "Unit": "string",
  "Index": 0,
  "Values": [
    {
      "x": "string",
      "y": 0
    }
  ],
  "SeriesType": "Line",
  "Color": "string",
  "ScatterMarkerSymbol": "none"
}
ChartPoint Model - Location on a chart containing the X-Y location
x string
Time of this chart point: lower case for javascript encoding simplicty.
y number
Value of this chart point: lower case for javascript encoding simplicty.
Example
{
  "x": "string",
  "y": 0
}
Order Model - Order struct for placing new trade.
Id integer
Order ID.
ContingentId integer
Order Id to process before processing this order.
BrokerId string Array
Brokerage Id for this order for when the brokerage splits orders into multiple pieces.
Symbol Symbol object
Represents a unique security identifier. This is made of two components, the unique SID and the Value. The value is the current ticker symbol while the SID is constant over the life of a security.
Price number
Price of the Order.
PriceCurrency string
Currency for the order price.
Time string($date-time)
Gets the utc time the order was created.
CreatedTime string($date-time)
Gets the utc time this order was created. Alias for Time.
LastFillTime string($date-time)
Gets the utc time the last fill was received, or null if no fills have been received.
LastUpdateTime string($date-time)
Gets the utc time this order was last updated, or null if the order has not been updated.
CanceledTime string($date-time)
Gets the utc time this order was canceled, or null if the order was not canceled.
Quantity number
Number of shares to execute.
Type string Enum
Order type. Options : ['Market', 'Limit', 'StopMarket', 'StopLimit', 'MarketOnOpen', 'MarketOnClose', 'OptionExercise']
Status string Enum
Status of the Order. Options : ['New', 'Submitted', 'PartiallyFilled', 'Filled', 'Canceled', 'None', 'Invalid', 'CancelPending', 'UpdateSubmitted']
Tag string
Tag the order with some custom data.
SecurityType string Enum
Type of tradable security / underlying asset. Options : ['Base', 'Equity', 'Option', 'Commodity', 'Forex', 'Future', 'Cfd', 'Crypto']
Direction string Enum
Direction of the order. Options : ['Buy', 'Sell', 'Hold']
Value number
Gets the executed value of this order. If the order has not yet filled, then this will return zero.
OrderSubmissionData OrderSubmissionData object
Stores time and price information available at the time an order was submitted.
IsMarketable boolean
Returns true if the order is a marketable order.
Example
{
  "Id": 0,
  "ContingentId": 0,
  "BrokerId": [
    "string"
  ],
  "Symbol": {
    "Value": "string",
    "ID": "string",
    "Permtick": "string"
  },
  "Price": 0,
  "PriceCurrency": "string",
  "Time": "2021-11-26T15:18:27.693Z",
  "CreatedTime": "2021-11-26T15:18:27.693Z",
  "LastFillTime": "2021-11-26T15:18:27.693Z",
  "LastUpdateTime": "2021-11-26T15:18:27.693Z",
  "CanceledTime": "2021-11-26T15:18:27.693Z",
  "Quantity": 0,
  "Type": "Market",
  "Status": "New",
  "Tag": "string",
  "SecurityType": "Base",
  "Direction": "Buy",
  "Value": 0,
  "OrderSubmissionData": {
    "BidPrice": 0,
    "AskPrice": 0,
    "LastPrice": 0
  },
  "IsMarketable": true
}
SecurityType Model - Type of tradable security / underlying asset.
SecurityType string Enum
Type of tradable security / underlying asset. Options : ['Base', 'Equity', 'Option', 'Commodity', 'Forex', 'Future', 'Cfd', 'Crypto']
Example
{
  "SecurityType": "Base"
}
OrderDirection Model - Direction of the order.
OrderDirection string Enum
Direction of the order. Options : ['Buy', 'Sell', 'Hold']
Example
{
  "OrderDirection": "Buy"
}
OrderSubmissionData Model - Stores time and price information available at the time an order was submitted.
BidPrice number
The bid price at an order submission time.
AskPrice number
The ask price at an order submission time.
LastPrice number
The current price at an order submission time.
Example
{
  "BidPrice": 0,
  "AskPrice": 0,
  "LastPrice": 0
}
OrderEvent Model - Change in an order state applied to user algorithm portfolio
OrderId integer
Id of the order this event comes from.
Id integer
The unique order event Id for each order.
Symbol Symbol object
Represents a unique security identifier. This is made of two components, the unique SID and the Value. The value is the current ticker symbol while the SID is constant over the life of a security.
UtcTime string($date-time)
The date and time of this event (UTC).
Status OrderStatus object
Messaging class signifying a change in an order state and record the change in the users algorithm portfolio.
OrderFee OrderFee object
The order fee associated with the specified order.
FillPrice number
Fill price information about the order.
FillPriceCurrency string
Currency for the fill price.
FillQuantity number
Number of shares of the order that was filled in this event.
Direction string Enum
Direction of the order. Options : ['Buy', 'Sell', 'Hold']
Message string
Any message from the exchange.
IsAssignment boolean
True if the order event is an assignment.
StopPrice number
The current stop price.
LimitPrice number
The current limit price.
Quantity number
The current order quantity.
Example
{
  "OrderId": 0,
  "Id": 0,
  "Symbol": {
    "Value": "string",
    "ID": "string",
    "Permtick": "string"
  },
  "UtcTime": "2021-11-26T15:18:27.693Z",
  "Status": {
    "OrderId": 0,
    "Id": 0,
    "Symbol": {
      "Value": "string",
      "ID": "string",
      "Permtick": "string"
    },
    "UtcTime": "2021-11-26T15:18:27.693Z",
    "Status": "New",
    "FillPrice": 0,
    "FillPriceCurrency": "string",
    "FillQuantity": 0,
    "Direction": "Buy",
    "Message": "string",
    "IsAssignment": true,
    "StopPrice": 0,
    "LimitPrice": 0,
    "Quantity": 0
  },
  "OrderFee": {
    "Value": {
      "Amount": 0,
      "Currency": "string"
    }
  },
  "FillPrice": 0,
  "FillPriceCurrency": "string",
  "FillQuantity": 0,
  "Direction": "Buy",
  "Message": "string",
  "IsAssignment": true,
  "StopPrice": 0,
  "LimitPrice": 0,
  "Quantity": 0
}
OrderStatus Model - Messaging class signifying a change in an order state and record the change in the users algorithm portfolio.
OrderId integer
Id of the order this event comes from.
Id integer
The unique order event Id for this order.
Symbol Symbol object
Represents a unique security identifier. This is made of two components, the unique SID and the Value. The value is the current ticker symbol while the SID is constant over the life of a security.
UtcTime string($date-time)
The date and time of this event.
Status string Enum
Status of the Order. Options : ['New', 'Submitted', 'PartiallyFilled', 'Filled', 'Canceled', 'None', 'Invalid', 'CancelPending', 'UpdateSubmitted']
FillPrice number
Fill price information about the order.
FillPriceCurrency string
Currency for the fill price.
FillQuantity number
Number of shares of the order that was filled in this event.
Direction string Enum
Direction of the order. Options : ['Buy', 'Sell', 'Hold']
Message string
Any message from the exchange.
IsAssignment boolean
Order event is an allocation of trades from ITM option assignment.
StopPrice number
The current stop price.
LimitPrice number
The current limit price.
Quantity number
The current order quantity.
Example
{
  "OrderId": 0,
  "Id": 0,
  "Symbol": {
    "Value": "string",
    "ID": "string",
    "Permtick": "string"
  },
  "UtcTime": "2021-11-26T15:18:27.693Z",
  "Status": "New",
  "FillPrice": 0,
  "FillPriceCurrency": "string",
  "FillQuantity": 0,
  "Direction": "Buy",
  "Message": "string",
  "IsAssignment": true,
  "StopPrice": 0,
  "LimitPrice": 0,
  "Quantity": 0
}
Status Model - Status of the Order.
Status string Enum
Status of the Order. Options : ['New', 'Submitted', 'PartiallyFilled', 'Filled', 'Canceled', 'None', 'Invalid', 'CancelPending', 'UpdateSubmitted']
Example
{
  "Status": "New"
}
OrderFee Model - The order fee associated with the specified order.
Value CashAmount object
Represents a cash amount which can be converted to account currency using a currency converter.
Example
{
  "Value": {
    "Amount": 0,
    "Currency": "string"
  }
}
CashAmount Model - Represents a cash amount which can be converted to account currency using a currency converter.
Amount number
The amount of cash.
Currency string
The currency in which the cash amount is denominated.
Example
{
  "Amount": 0,
  "Currency": "string"
}

401 Authentication Error

UnauthorizedError Model - Unauthorized response from the API. Key is missing, invalid, or timestamp is too old for hash.
www_authenticate string
Header

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: