Skip to content

Commit

Permalink
Add Starting and Ending KPI's (QuantConnect#7811)
Browse files Browse the repository at this point in the history
* First draft of the solution

* Add missing changes

* Remove the new KPI's from report

* Fix bugs

* nit change

* Add improvements

* Fix regression tests

* Solve bugs in the regression algos

* Fix regression tests bugs

* Expand unit tests and add minor changes
  • Loading branch information
Marinovsky authored Mar 25, 2024
1 parent ca99f32 commit ead2efe
Show file tree
Hide file tree
Showing 479 changed files with 970 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "-12.611%"},
{"Drawdown", "0.200%"},
{"Expectancy", "-0.585"},
{"Start Equity", "100000"},
{"End Equity", "99827.80"},
{"Net Profit", "-0.172%"},
{"Sharpe Ratio", "-11.13"},
{"Sortino Ratio", "-16.704"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AddAlphaModelAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice data)
{"Compounding Annual Return", "184.364%"},
{"Drawdown", "1.700%"},
{"Expectancy", "1.781"},
{"Start Equity", "100000"},
{"End Equity", "101441.92"},
{"Net Profit", "1.442%"},
{"Sharpe Ratio", "4.836"},
{"Sortino Ratio", "10.481"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AddBetaIndicatorRegressionAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public override void OnOrderEvent(OrderEvent orderEvent)
{"Compounding Annual Return", "12.939%"},
{"Drawdown", "0.300%"},
{"Expectancy", "0"},
{"Start Equity", "10000"},
{"End Equity", "10028.93"},
{"Net Profit", "0.289%"},
{"Sharpe Ratio", "3.924"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
{"Compounding Annual Return", "-2.594%"},
{"Drawdown", "0.000%"},
{"Expectancy", "-1"},
{"Start Equity", "100000"},
{"End Equity", "99966.4"},
{"Net Profit", "-0.034%"},
{"Sharpe Ratio", "-10.666"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "5512.811%"},
{"Drawdown", "1.000%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "105332.8"},
{"Net Profit", "5.333%"},
{"Sharpe Ratio", "64.084"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public override void OnData(Slice data)
{"Compounding Annual Return", "386219349.202%"},
{"Drawdown", "5.200%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "111911.55"},
{"Net Profit", "11.912%"},
{"Sharpe Ratio", "1604181.904"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "347.065%"},
{"Drawdown", "0.900%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "101950.53"},
{"Net Profit", "1.951%"},
{"Sharpe Ratio", "15.402"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public override void OnData(Slice data)
{"Compounding Annual Return", "-4.619%"},
{"Drawdown", "0.300%"},
{"Expectancy", "-0.042"},
{"Start Equity", "100000"},
{"End Equity", "99668"},
{"Net Profit", "-0.332%"},
{"Sharpe Ratio", "-4.614"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "-15.596%"},
{"Drawdown", "0.200%"},
{"Expectancy", "-1"},
{"Start Equity", "100000"},
{"End Equity", "99768"},
{"Net Profit", "-0.232%"},
{"Sharpe Ratio", "-8.903"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AddOptionContractTwiceRegressionAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "-4.548%"},
{"Drawdown", "0.100%"},
{"Expectancy", "-1"},
{"Start Equity", "100000"},
{"End Equity", "99949"},
{"Net Profit", "-0.051%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "99079"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AddRemoveSecurityCacheRegressionAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public override void OnData(Slice data)
{"Compounding Annual Return", "271.720%"},
{"Drawdown", "2.500%"},
{"Expectancy", "-1"},
{"Start Equity", "100000"},
{"End Equity", "101753.84"},
{"Net Profit", "1.754%"},
{"Sharpe Ratio", "11.954"},
{"Sortino Ratio", "29.606"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AddRemoveSecurityRegressionAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public override void OnOrderEvent(OrderEvent orderEvent)
{"Compounding Annual Return", "296.356%"},
{"Drawdown", "1.400%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "101776.32"},
{"Net Profit", "1.776%"},
{"Sharpe Ratio", "12.966"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AddRiskManagementAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public override void Initialize()
{"Compounding Annual Return", "296.066%"},
{"Drawdown", "2.200%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "101775.37"},
{"Net Profit", "1.775%"},
{"Sharpe Ratio", "9.34"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "99930"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AddUniverseSelectionModelAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "-14.233%"},
{"Drawdown", "3.300%"},
{"Expectancy", "-1"},
{"Start Equity", "100000"},
{"End Equity", "99831.88"},
{"Net Profit", "-0.168%"},
{"Sharpe Ratio", "62.464"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AddUniverseSelectionModelCoarseAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "-75.275%"},
{"Drawdown", "5.800%"},
{"Expectancy", "-0.609"},
{"Start Equity", "100000"},
{"End Equity", "94419.21"},
{"Net Profit", "-5.581%"},
{"Sharpe Ratio", "-3.288"},
{"Sortino Ratio", "-3.828"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AdjustedVolumeRegressionAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public override void OnData(Slice data)
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100146.57"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/AlgorithmModeAndDeploymentTargetAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public override void Initialize()
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ public Dictionary<Symbol, long> AllShortableSymbols(DateTime localTime)
{"Compounding Annual Return", "19.147%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "10000000"},
{"End Equity", "10019217.27"},
{"Net Profit", "0.192%"},
{"Sharpe Ratio", "221.176"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public override void OnData(Slice slice)
{"Compounding Annual Return", "0.096%"},
{"Drawdown", "0.100%"},
{"Expectancy", "3.321"},
{"Start Equity", "100000"},
{"End Equity", "100089.09"},
{"Net Profit", "0.089%"},
{"Sharpe Ratio", "-8.214"},
{"Sortino Ratio", "-9.025"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ protected override decimal ComputeNextValue(QuoteBar input)
{"Compounding Annual Return", "733913.744%"},
{"Drawdown", "15.900%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "106827.7"},
{"Net Profit", "6.828%"},
{"Sharpe Ratio", "203744786353.299"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ protected override decimal ComputeNextValue(IReadOnlyWindow<IndicatorDataPoint>
{"Compounding Annual Return", "271.453%"},
{"Drawdown", "2.200%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "101691.92"},
{"Net Profit", "1.692%"},
{"Sharpe Ratio", "8.854"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BacktestingBrokerageRegressionAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ public override OrderEvent MarketFill(Security asset, MarketOrder order)
{"Compounding Annual Return", "-22.717%"},
{"Drawdown", "0.400%"},
{"Expectancy", "-1"},
{"Start Equity", "100000"},
{"End Equity", "99671.06"},
{"Net Profit", "-0.329%"},
{"Sharpe Ratio", "-14.095"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicSetAccountCurrencyAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public override void OnData(Slice data)
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "100000.00"},
{"End Equity", "92395.59"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public override void SetAccountCurrency()
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "200000.00"},
{"End Equity", "184791.19"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public override void OnData(Slice data)
{"Compounding Annual Return", "271.453%"},
{"Drawdown", "2.200%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "101691.92"},
{"Net Profit", "1.692%"},
{"Sharpe Ratio", "8.854"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateAxosAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public override void OnData(Slice data)
{"Compounding Annual Return", "39.143%"},
{"Drawdown", "0.500%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "100423.24"},
{"Net Profit", "0.423%"},
{"Sharpe Ratio", "5.498"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateContinuousFutureAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
{"Compounding Annual Return", "13.087%"},
{"Drawdown", "1.100%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "106387.1"},
{"Net Profit", "6.387%"},
{"Sharpe Ratio", "1.532"},
{"Sortino Ratio", "871.704"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
{"Compounding Annual Return", "8.423%"},
{"Drawdown", "0.800%"},
{"Expectancy", "8.202"},
{"Start Equity", "100000"},
{"End Equity", "104162.1"},
{"Net Profit", "4.162%"},
{"Sharpe Ratio", "0.951"},
{"Sortino Ratio", "2.8"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateCryptoAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ public override void OnEndOfAlgorithm()
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "31588.24"},
{"End Equity", "30866.71"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateCryptoFutureAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ public override void OnOrderEvent(OrderEvent orderEvent)
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "1000200.00"},
{"End Equity", "1000278.02"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateCryptoFutureHourlyAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ public override void OnOrderEvent(OrderEvent orderEvent)
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "1000200"},
{"End Equity", "1000189.47"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateDailyAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public override void OnData(Slice data)
{"Compounding Annual Return", "246.546%"},
{"Drawdown", "1.200%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "103463.69"},
{"Net Profit", "3.464%"},
{"Sharpe Ratio", "19.094"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateFrameworkAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public override void OnOrderEvent(OrderEvent orderEvent)
{"Compounding Annual Return", "261.134%"},
{"Drawdown", "2.200%"},
{"Expectancy", "-1"},
{"Start Equity", "100000"},
{"End Equity", "101655.30"},
{"Net Profit", "1.655%"},
{"Sharpe Ratio", "8.472"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateFutureRolloverAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public void Dispose()
{"Compounding Annual Return", "3.011%"},
{"Drawdown", "0.000%"},
{"Expectancy", "0"},
{"Start Equity", "1000000"},
{"End Equity", "1005283.2"},
{"Net Profit", "0.528%"},
{"Sharpe Ratio", "1.285"},
{"Sortino Ratio", "0"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateFuturesAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ public override void OnSecuritiesChanged(SecurityChanges changes)
{"Compounding Annual Return", "-99.777%"},
{"Drawdown", "4.400%"},
{"Expectancy", "-0.724"},
{"Start Equity", "1000000"},
{"End Equity", "955700.5"},
{"Net Profit", "-4.430%"},
{"Sharpe Ratio", "-31.63"},
{"Sortino Ratio", "-31.63"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateFuturesDailyAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ select futuresContract
{"Compounding Annual Return", "-0.071%"},
{"Drawdown", "0.400%"},
{"Expectancy", "-0.116"},
{"Start Equity", "1000000"},
{"End Equity", "999287.06"},
{"Net Profit", "-0.071%"},
{"Sharpe Ratio", "-1.999"},
{"Sortino Ratio", "-1.806"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateFuturesFrameworkAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public override IEnumerable<IPortfolioTarget> CreateTargets(QCAlgorithm algorith
{"Compounding Annual Return", "-81.734%"},
{"Drawdown", "4.100%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "97830.76"},
{"Net Profit", "-2.169%"},
{"Sharpe Ratio", "-10.299"},
{"Sortino Ratio", "-10.299"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class BasicTemplateFuturesFrameworkWithExtendedMarketAlgorithm : BasicTem
{"Compounding Annual Return", "-92.667%"},
{"Drawdown", "5.000%"},
{"Expectancy", "0"},
{"Start Equity", "100000"},
{"End Equity", "96685.76"},
{"Net Profit", "-3.314%"},
{"Sharpe Ratio", "-6.359"},
{"Sortino Ratio", "-11.237"},
Expand Down
2 changes: 2 additions & 0 deletions Algorithm.CSharp/BasicTemplateFuturesHistoryAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ public override void OnOrderEvent(OrderEvent orderEvent)
{"Compounding Annual Return", "0%"},
{"Drawdown", "0%"},
{"Expectancy", "0"},
{"Start Equity", "1000000"},
{"End Equity", "1000000"},
{"Net Profit", "0%"},
{"Sharpe Ratio", "0"},
{"Sortino Ratio", "0"},
Expand Down
Loading

0 comments on commit ead2efe

Please sign in to comment.