Compare commits
55 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6351773a01 | ||
|
|
bf4b08e202 | ||
|
|
fa9ff399cc | ||
|
|
16c4259342 | ||
|
|
724d0b06a5 | ||
|
|
ba7fe05574 | ||
|
|
50437946e2 | ||
|
|
418970bb48 | ||
|
|
bef045a360 | ||
|
|
49bf436aa2 | ||
|
|
e29bb2c5e0 | ||
|
|
8fcc9f7d4e | ||
|
|
5209332074 | ||
|
|
adfad475cc | ||
|
|
21fcadf0f8 | ||
|
|
e893e67e9b | ||
|
|
3b588d04fb | ||
|
|
e81bcbb987 | ||
|
|
96e91b446d | ||
|
|
403f0348bd | ||
|
|
eeeb310438 | ||
|
|
271f0bb08e | ||
|
|
3a09c70851 | ||
|
|
f31251732e | ||
|
|
9baacdbdd6 | ||
|
|
363d469d6a | ||
|
|
c186addf94 | ||
|
|
17049dcd56 | ||
|
|
d88387ac67 | ||
|
|
74c3501ed3 | ||
|
|
a543af71dc | ||
|
|
9b332c2149 | ||
|
|
1e620e54fe | ||
|
|
7879795207 | ||
|
|
d2d366e3f9 | ||
|
|
5226b7a468 | ||
|
|
1947a58541 | ||
|
|
1bca3f6081 | ||
|
|
2b1136e446 | ||
|
|
86fcc40c3e | ||
|
|
9eb484625d | ||
|
|
85ca5be258 | ||
|
|
9a84a6bd17 | ||
|
|
a46acef9f8 | ||
|
|
69fa2fd689 | ||
|
|
2df58bbca3 | ||
|
|
050030bca8 | ||
|
|
7e40b4f1ab | ||
|
|
229d636628 | ||
|
|
034bf3d8ae | ||
|
|
31b32442c8 | ||
|
|
9a92933397 | ||
|
|
97959d560a | ||
|
|
0352a0b07c | ||
|
|
bd87ba6f14 |
@@ -128,7 +128,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "9"},
|
||||
{"Average Win", "0.86%"},
|
||||
{"Average Loss", "-0.27%"},
|
||||
{"Compounding Annual Return", "184.364%"},
|
||||
{"Compounding Annual Return", "206.404%"},
|
||||
{"Drawdown", "1.700%"},
|
||||
{"Expectancy", "1.781"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -148,10 +148,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.532"},
|
||||
{"Treynor Ratio", "-1.174"},
|
||||
{"Total Fees", "$14.78"},
|
||||
{"Estimated Strategy Capacity", "$47000000.00"},
|
||||
{"Estimated Strategy Capacity", "$120000000.00"},
|
||||
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "41.18%"},
|
||||
{"OrderListHash", "d929e7959f079ad4fed42e8f3b35e39e"}
|
||||
{"OrderListHash", "713c956deb193bed2290e9f379c0f9f9"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
|
||||
|
||||
_contract = OptionChainProvider.GetOptionContractList(aapl, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
_contract = OptionChain(aapl)
|
||||
.OrderBy(x => x.ID.Symbol)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
AddOptionContract(_contract);
|
||||
@@ -90,7 +90,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var aapl = AddEquity("AAPL").Symbol;
|
||||
|
||||
_contract = OptionChainProvider.GetOptionContractList(aapl, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
_contract = OptionChain(aapl)
|
||||
.OrderBy(x => x.ID.Symbol)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
foreach (var contract in futuresContracts)
|
||||
{
|
||||
var option_contract_symbols = OptionChainProvider.GetOptionContractList(contract.Symbol, Time).ToList();
|
||||
var option_contract_symbols = OptionChain(contract.Symbol).ToList();
|
||||
if(option_contract_symbols.Count == 0)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -55,10 +55,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
_optionFilterRan = true;
|
||||
|
||||
var expiry = new HashSet<DateTime>(optionContracts.Select(x => x.Underlying.ID.Date)).SingleOrDefault();
|
||||
// Cast to IEnumerable<Symbol> because OptionFilterContract overrides some LINQ operators like `Select` and `Where`
|
||||
var expiry = new HashSet<DateTime>(optionContracts.Select(x => x.Symbol.Underlying.ID.Date)).SingleOrDefault();
|
||||
// Cast to List<Symbol> because OptionFilterContract overrides some LINQ operators like `Select` and `Where`
|
||||
// and cause it to mutate the underlying Symbol collection when using those operators.
|
||||
var symbol = new HashSet<Symbol>(((IEnumerable<Symbol>)optionContracts).Select(x => x.Underlying)).SingleOrDefault();
|
||||
var symbol = new HashSet<Symbol>(((List<Symbol>)optionContracts).Select(x => x.Underlying)).SingleOrDefault();
|
||||
|
||||
if (expiry == null || symbol == null)
|
||||
{
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
if (_option == null)
|
||||
{
|
||||
var option = OptionChainProvider.GetOptionContractList(_twx, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
var option = OptionChain(_twx)
|
||||
.OrderBy(x => x.ID.Symbol)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.Date == _expiration
|
||||
&& optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
@@ -122,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
@@ -110,14 +110,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
foreach (var addedSecurity in changes.AddedSecurities)
|
||||
{
|
||||
var option = OptionChainProvider.GetOptionContractList(addedSecurity.Symbol, Time)
|
||||
.OrderBy(symbol => symbol.ID.Symbol)
|
||||
var option = OptionChain(addedSecurity.Symbol)
|
||||
.OrderBy(contractData => contractData.ID.Symbol)
|
||||
.First(optionContract => optionContract.ID.Date == _expiration
|
||||
&& optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
AddOptionContract(option);
|
||||
|
||||
foreach (var symbol in new[] { option, option.Underlying })
|
||||
foreach (var symbol in new[] { option.Symbol, option.Underlying.Symbol })
|
||||
{
|
||||
var config = SubscriptionManager.SubscriptionDataConfigService.GetSubscriptionDataConfigs(symbol).ToList();
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 2;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
|
||||
@@ -39,12 +39,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
UniverseSettings.MinimumTimeInUniverse = TimeSpan.Zero;
|
||||
UniverseSettings.FillForward = false;
|
||||
|
||||
AddEquity("SPY", Resolution.Daily);
|
||||
AddEquity("SPY", Resolution.Hour);
|
||||
|
||||
var aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
|
||||
|
||||
_contract = OptionChainProvider.GetOptionContractList(aapl, Time)
|
||||
.OrderBy(symbol => symbol.ID.StrikePrice)
|
||||
_contract = OptionChain(aapl)
|
||||
.OrderBy(x => x.ID.StrikePrice)
|
||||
.FirstOrDefault(optionContract => optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American);
|
||||
AddOptionContract(_contract);
|
||||
@@ -116,12 +116,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 3930;
|
||||
public long DataPoints => 3814;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
@@ -135,13 +135,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.70%"},
|
||||
{"Compounding Annual Return", "-47.178%"},
|
||||
{"Average Loss", "-0.50%"},
|
||||
{"Compounding Annual Return", "-39.406%"},
|
||||
{"Drawdown", "0.700%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99303"},
|
||||
{"Net Profit", "-0.697%"},
|
||||
{"End Equity", "99498"},
|
||||
{"Net Profit", "-0.502%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
@@ -156,10 +156,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.008"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$6400000.00"},
|
||||
{"Estimated Strategy Capacity", "$5000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL VXBK4R62CXGM|AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "22.80%"},
|
||||
{"OrderListHash", "c2878a81bbb4e52c4fcd6a4f259abc3d"}
|
||||
{"Portfolio Turnover", "22.70%"},
|
||||
{"OrderListHash", "29fd1b75f6db05dd823a6db7e8bd90a9"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
@@ -59,19 +58,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var changeOptions = changes.AddedSecurities.Concat(changes.RemovedSecurities)
|
||||
.Where(s => s.Type == SecurityType.Option);
|
||||
|
||||
// Susbtract one minute to get the actual market open. If market open is at 9:30am, this will be invoked at 9:31am
|
||||
var expectedTime = Time.TimeOfDay - TimeSpan.FromMinutes(1);
|
||||
var allOptionsWereChangedOnMarketOpen = changeOptions.All(s =>
|
||||
if (Time != Time.Date)
|
||||
{
|
||||
var firstMarketSegment = s.Exchange.Hours.MarketHours[Time.DayOfWeek].Segments
|
||||
.First(segment => segment.State == MarketHoursState.Market);
|
||||
|
||||
return firstMarketSegment.Start == expectedTime;
|
||||
});
|
||||
|
||||
if (!allOptionsWereChangedOnMarketOpen)
|
||||
{
|
||||
throw new RegressionTestException("Expected options filter to be run only on market open");
|
||||
throw new RegressionTestException($"Expected options filter to be run only at midnight. Actual was {Time}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +77,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all time slices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 5952220;
|
||||
public long DataPoints => 470217;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -35,14 +35,15 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
private readonly HashSet<Symbol> _expectedData = new HashSet<Symbol>();
|
||||
private readonly HashSet<Symbol> _expectedUniverses = new HashSet<Symbol>();
|
||||
private bool _expectUniverseSubscription;
|
||||
private DateTime _universeSubscriptionTime;
|
||||
|
||||
// order of expected contract additions as price moves
|
||||
private int _expectedContractIndex;
|
||||
private readonly List<Symbol> _expectedContracts = new List<Symbol>
|
||||
{
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00747500"),
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00750000"),
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00752500")
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00752500"),
|
||||
SymbolRepresentation.ParseOptionTickerOSI("GOOG 151224P00755000")
|
||||
};
|
||||
|
||||
public override void Initialize()
|
||||
@@ -68,7 +69,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
Log($"SubscriptionManager.Subscriptions: {string.Join(" -- ", SubscriptionManager.Subscriptions)}");
|
||||
throw new RegressionTestException($"Unexpected {OptionChainSymbol} subscription presence");
|
||||
}
|
||||
if (!slice.ContainsKey(Underlying))
|
||||
if (Time != _universeSubscriptionTime && !slice.ContainsKey(Underlying))
|
||||
{
|
||||
// TODO : In fact, we're unable to properly detect whether or not we auto-added or it was manually added
|
||||
// this is because when we auto-add the underlying we don't mark it as an internal security like we do with other auto adds
|
||||
@@ -91,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var actual = string.Join(Environment.NewLine, UniverseManager.Keys.OrderBy(s => s.ToString()));
|
||||
throw new RegressionTestException($"{Time}:: Detected differences in expected and actual universes{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
|
||||
}
|
||||
if (_expectedData.AreDifferent(slice.Keys.ToHashSet()))
|
||||
if (Time != _universeSubscriptionTime && _expectedData.AreDifferent(slice.Keys.ToHashSet()))
|
||||
{
|
||||
var expected = string.Join(Environment.NewLine, _expectedData.OrderBy(s => s.ToString()));
|
||||
var actual = string.Join(Environment.NewLine, slice.Keys.OrderBy(s => s.ToString()));
|
||||
@@ -99,7 +100,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
|
||||
// 10AM add GOOG option chain
|
||||
if (Time.TimeOfDay.Hours == 10 && Time.TimeOfDay.Minutes == 0)
|
||||
if (Time.TimeOfDay.Hours == 10 && Time.TimeOfDay.Minutes == 0 && !_expectUniverseSubscription)
|
||||
{
|
||||
if (Securities.ContainsKey(OptionChainSymbol))
|
||||
{
|
||||
@@ -110,9 +111,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
googOptionChain.SetFilter(u =>
|
||||
{
|
||||
// we added the universe at 10, the universe selection data should not be from before
|
||||
if (u.Underlying.EndTime.Hour < 10)
|
||||
if (u.LocalTime.Hour < 10)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected underlying data point {u.Underlying.EndTime} {u.Underlying}");
|
||||
throw new RegressionTestException($"Unexpected selection time {u.LocalTime}");
|
||||
}
|
||||
// find first put above market price
|
||||
return u.IncludeWeeklys()
|
||||
@@ -124,6 +125,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
_expectedSecurities.Add(OptionChainSymbol);
|
||||
_expectedUniverses.Add(OptionChainSymbol);
|
||||
_expectUniverseSubscription = true;
|
||||
_universeSubscriptionTime = Time;
|
||||
}
|
||||
|
||||
// 11:30AM remove GOOG option chain
|
||||
@@ -151,7 +153,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var expectedContract = _expectedContracts[_expectedContractIndex];
|
||||
if (added.Symbol != expectedContract)
|
||||
{
|
||||
throw new RegressionTestException($"Expected option contract {expectedContract} to be added but received {added.Symbol}");
|
||||
throw new RegressionTestException($"Expected option contract {expectedContract.Value} to be added but received {added.Symbol}");
|
||||
}
|
||||
|
||||
_expectedContractIndex++;
|
||||
@@ -186,7 +188,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (Securities.ContainsKey(Underlying))
|
||||
{
|
||||
Console.WriteLine($"{Time:o}:: PRICE:: {Securities[Underlying].Price} CHANGES:: {changes}");
|
||||
Log($"{Time:o}:: PRICE:: {Securities[Underlying].Price} CHANGES:: {changes}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +205,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 200807;
|
||||
public long DataPoints => 3502;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -227,7 +229,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99079"},
|
||||
{"End Equity", "98784"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
@@ -243,10 +245,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$6.00"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV 305RBR0BSWIX2|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "1.49%"},
|
||||
{"OrderListHash", "bd115ec8bb7734b1561d6a6cc6c00039"}
|
||||
{"Estimated Strategy Capacity", "$4000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV 305RBQ2BZBZT2|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "2.58%"},
|
||||
{"OrderListHash", "09f766c470a8bcf4bb6862da52bf25a7"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var aapl = QuantConnect.Symbol.Create("AAPL", SecurityType.Equity, Market.USA);
|
||||
|
||||
var contracts = OptionChainProvider.GetOptionContractList(aapl, Time)
|
||||
.OrderBy(symbol => symbol.ID.StrikePrice)
|
||||
var contracts = OptionChain(aapl)
|
||||
.OrderBy(x => x.ID.StrikePrice)
|
||||
.Where(optionContract => optionContract.ID.OptionRight == OptionRight.Call
|
||||
&& optionContract.ID.OptionStyle == OptionStyle.American)
|
||||
.Take(2)
|
||||
@@ -106,7 +106,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 53;
|
||||
public long DataPoints => 50;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -98,33 +98,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "10"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-14.233%"},
|
||||
{"Drawdown", "3.300%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Total Orders", "6"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "1296.838%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99831.88"},
|
||||
{"Net Profit", "-0.168%"},
|
||||
{"Sharpe Ratio", "62.464"},
|
||||
{"End Equity", "102684.23"},
|
||||
{"Net Profit", "2.684%"},
|
||||
{"Sharpe Ratio", "34.319"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "1.117"},
|
||||
{"Beta", "1.19"},
|
||||
{"Annual Standard Deviation", "0.213"},
|
||||
{"Annual Variance", "0.046"},
|
||||
{"Information Ratio", "70.778"},
|
||||
{"Tracking Error", "0.043"},
|
||||
{"Treynor Ratio", "11.2"},
|
||||
{"Total Fees", "$22.21"},
|
||||
{"Estimated Strategy Capacity", "$340000000.00"},
|
||||
{"Alpha", "-5.738"},
|
||||
{"Beta", "1.381"},
|
||||
{"Annual Standard Deviation", "0.246"},
|
||||
{"Annual Variance", "0.06"},
|
||||
{"Information Ratio", "-26.937"},
|
||||
{"Tracking Error", "0.068"},
|
||||
{"Treynor Ratio", "6.106"},
|
||||
{"Total Fees", "$18.61"},
|
||||
{"Estimated Strategy Capacity", "$980000000.00"},
|
||||
{"Lowest Capacity Asset", "FB V6OIPNZEM8V9"},
|
||||
{"Portfolio Turnover", "26.92%"},
|
||||
{"OrderListHash", "3832790c7dd9d50805b6206129b01110"}
|
||||
{"Portfolio Turnover", "25.56%"},
|
||||
{"OrderListHash", "5ee20c8556d706ab0a63ae41b6579c62"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 234018;
|
||||
public long DataPoints => 234015;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -109,33 +109,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "23"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Total Orders", "21"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-75.275%"},
|
||||
{"Drawdown", "5.800%"},
|
||||
{"Expectancy", "-0.609"},
|
||||
{"Compounding Annual Return", "-77.566%"},
|
||||
{"Drawdown", "6.000%"},
|
||||
{"Expectancy", "-0.811"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "94419.21"},
|
||||
{"Net Profit", "-5.581%"},
|
||||
{"Sharpe Ratio", "-3.288"},
|
||||
{"Sortino Ratio", "-3.828"},
|
||||
{"Probabilistic Sharpe Ratio", "5.546%"},
|
||||
{"Loss Rate", "73%"},
|
||||
{"Win Rate", "27%"},
|
||||
{"Profit-Loss Ratio", "0.43"},
|
||||
{"Alpha", "-0.495"},
|
||||
{"Beta", "1.484"},
|
||||
{"Annual Standard Deviation", "0.196"},
|
||||
{"Annual Variance", "0.039"},
|
||||
{"Information Ratio", "-3.843"},
|
||||
{"Tracking Error", "0.141"},
|
||||
{"Treynor Ratio", "-0.435"},
|
||||
{"Total Fees", "$31.25"},
|
||||
{"Estimated Strategy Capacity", "$550000000.00"},
|
||||
{"End Equity", "94042.73"},
|
||||
{"Net Profit", "-5.957%"},
|
||||
{"Sharpe Ratio", "-3.345"},
|
||||
{"Sortino Ratio", "-3.766"},
|
||||
{"Probabilistic Sharpe Ratio", "4.557%"},
|
||||
{"Loss Rate", "89%"},
|
||||
{"Win Rate", "11%"},
|
||||
{"Profit-Loss Ratio", "0.70"},
|
||||
{"Alpha", "-0.519"},
|
||||
{"Beta", "1.491"},
|
||||
{"Annual Standard Deviation", "0.2"},
|
||||
{"Annual Variance", "0.04"},
|
||||
{"Information Ratio", "-3.878"},
|
||||
{"Tracking Error", "0.147"},
|
||||
{"Treynor Ratio", "-0.449"},
|
||||
{"Total Fees", "$29.11"},
|
||||
{"Estimated Strategy Capacity", "$680000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "7.33%"},
|
||||
{"OrderListHash", "2add92a1f922c6730d8c20ff65934a46"}
|
||||
{"Portfolio Turnover", "7.48%"},
|
||||
{"OrderListHash", "2c814c55e7d7c56482411c065b861b33"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 37748;
|
||||
public long DataPoints => 36573;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -255,33 +255,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Total Orders", "8"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "19.147%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Compounding Annual Return", "11.027%"},
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "10000000"},
|
||||
{"End Equity", "10019217.27"},
|
||||
{"Net Profit", "0.192%"},
|
||||
{"Sharpe Ratio", "15.743"},
|
||||
{"End Equity", "10011469.88"},
|
||||
{"Net Profit", "0.115%"},
|
||||
{"Sharpe Ratio", "11.963"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.17"},
|
||||
{"Beta", "0.037"},
|
||||
{"Annual Standard Deviation", "0.01"},
|
||||
{"Alpha", "0.07"},
|
||||
{"Beta", "-0.077"},
|
||||
{"Annual Standard Deviation", "0.008"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "5"},
|
||||
{"Tracking Error", "0.094"},
|
||||
{"Treynor Ratio", "4.278"},
|
||||
{"Total Fees", "$307.50"},
|
||||
{"Estimated Strategy Capacity", "$2600000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "10.61%"},
|
||||
{"OrderListHash", "854d4ba6a4ae39f9be2f9a10c8544fe5"}
|
||||
{"Information Ratio", "3.876"},
|
||||
{"Tracking Error", "0.105"},
|
||||
{"Treynor Ratio", "-1.215"},
|
||||
{"Total Fees", "$282.50"},
|
||||
{"Estimated Strategy Capacity", "$61000000000.00"},
|
||||
{"Lowest Capacity Asset", "NB R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "3.62%"},
|
||||
{"OrderListHash", "0ea806c53bfa2bdca2504ba7155ef130"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,33 +93,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "52"},
|
||||
{"Total Orders", "53"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Average Loss", "0.00%"},
|
||||
{"Compounding Annual Return", "0.096%"},
|
||||
{"Compounding Annual Return", "0.076%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "3.321"},
|
||||
{"Expectancy", "2.933"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100089.09"},
|
||||
{"Net Profit", "0.089%"},
|
||||
{"Sharpe Ratio", "-8.214"},
|
||||
{"Sortino Ratio", "-9.025"},
|
||||
{"Probabilistic Sharpe Ratio", "40.893%"},
|
||||
{"Loss Rate", "24%"},
|
||||
{"Win Rate", "76%"},
|
||||
{"Profit-Loss Ratio", "4.67"},
|
||||
{"End Equity", "100070.90"},
|
||||
{"Net Profit", "0.071%"},
|
||||
{"Sharpe Ratio", "-9.164"},
|
||||
{"Sortino Ratio", "-9.852"},
|
||||
{"Probabilistic Sharpe Ratio", "36.417%"},
|
||||
{"Loss Rate", "27%"},
|
||||
{"Win Rate", "73%"},
|
||||
{"Profit-Loss Ratio", "4.41"},
|
||||
{"Alpha", "-0.008"},
|
||||
{"Beta", "0.008"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.961"},
|
||||
{"Tracking Error", "0.092"},
|
||||
{"Treynor Ratio", "-0.826"},
|
||||
{"Total Fees", "$52.00"},
|
||||
{"Estimated Strategy Capacity", "$32000000000.00"},
|
||||
{"Treynor Ratio", "-0.911"},
|
||||
{"Total Fees", "$53.00"},
|
||||
{"Estimated Strategy Capacity", "$16000000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.02%"},
|
||||
{"OrderListHash", "fab920b5fc92a6e14d8128564249fbfa"}
|
||||
{"OrderListHash", "685c37df6e4c49b75792c133be189094"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1267414;
|
||||
public long DataPoints => 27071;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -316,7 +316,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "3"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.40%"},
|
||||
{"Compounding Annual Return", "-22.717%"},
|
||||
{"Compounding Annual Return", "-21.378%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
|
||||
@@ -136,32 +136,32 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "2.90%"},
|
||||
{"Average Win", "2.48%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "13.087%"},
|
||||
{"Drawdown", "1.100%"},
|
||||
{"Compounding Annual Return", "11.325%"},
|
||||
{"Drawdown", "1.500%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "106387.1"},
|
||||
{"Net Profit", "6.387%"},
|
||||
{"Sharpe Ratio", "1.532"},
|
||||
{"Sortino Ratio", "871.704"},
|
||||
{"Probabilistic Sharpe Ratio", "90.613%"},
|
||||
{"End Equity", "105549.6"},
|
||||
{"Net Profit", "5.550%"},
|
||||
{"Sharpe Ratio", "1.332"},
|
||||
{"Sortino Ratio", "879.904"},
|
||||
{"Probabilistic Sharpe Ratio", "79.894%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.088"},
|
||||
{"Beta", "-0.022"},
|
||||
{"Annual Standard Deviation", "0.054"},
|
||||
{"Alpha", "0.075"},
|
||||
{"Beta", "-0.017"},
|
||||
{"Annual Standard Deviation", "0.053"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "-1.35"},
|
||||
{"Tracking Error", "0.1"},
|
||||
{"Treynor Ratio", "-3.781"},
|
||||
{"Information Ratio", "-1.48"},
|
||||
{"Tracking Error", "0.099"},
|
||||
{"Treynor Ratio", "-4.187"},
|
||||
{"Total Fees", "$10.75"},
|
||||
{"Estimated Strategy Capacity", "$1100000000.00"},
|
||||
{"Estimated Strategy Capacity", "$7100000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "2.32%"},
|
||||
{"OrderListHash", "2f6afca6b20a56eea9dd327dcb401682"}
|
||||
{"Portfolio Turnover", "2.33%"},
|
||||
{"OrderListHash", "9c524830ffc7354327638142ae62acd2"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,32 +141,32 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "4.45%"},
|
||||
{"Average Loss", "-0.26%"},
|
||||
{"Compounding Annual Return", "8.423%"},
|
||||
{"Drawdown", "0.800%"},
|
||||
{"Expectancy", "8.202"},
|
||||
{"Average Win", "2.86%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "12.959%"},
|
||||
{"Drawdown", "1.100%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "104162.1"},
|
||||
{"Net Profit", "4.162%"},
|
||||
{"Sharpe Ratio", "0.951"},
|
||||
{"Sortino Ratio", "2.8"},
|
||||
{"Probabilistic Sharpe Ratio", "53.568%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "17.40"},
|
||||
{"Alpha", "0.053"},
|
||||
{"Beta", "-0.005"},
|
||||
{"Annual Standard Deviation", "0.054"},
|
||||
{"End Equity", "106337.1"},
|
||||
{"Net Profit", "6.337%"},
|
||||
{"Sharpe Ratio", "1.41"},
|
||||
{"Sortino Ratio", "1.242"},
|
||||
{"Probabilistic Sharpe Ratio", "77.992%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.071"},
|
||||
{"Beta", "0.054"},
|
||||
{"Annual Standard Deviation", "0.059"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "-1.681"},
|
||||
{"Tracking Error", "0.099"},
|
||||
{"Treynor Ratio", "-10.255"},
|
||||
{"Information Ratio", "-1.392"},
|
||||
{"Tracking Error", "0.097"},
|
||||
{"Treynor Ratio", "1.518"},
|
||||
{"Total Fees", "$10.75"},
|
||||
{"Estimated Strategy Capacity", "$190000000.00"},
|
||||
{"Estimated Strategy Capacity", "$890000000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "2.34%"},
|
||||
{"OrderListHash", "f34d9277d1d81a8125879f5ff8202626"}
|
||||
{"Portfolio Turnover", "2.32%"},
|
||||
{"OrderListHash", "f60fc7dcba2c1ff077afeb191aee5008"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 73;
|
||||
public long DataPoints => 72;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -86,30 +86,30 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "246.546%"},
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Compounding Annual Return", "424.375%"},
|
||||
{"Drawdown", "0.800%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "103463.69"},
|
||||
{"Net Profit", "3.464%"},
|
||||
{"Sharpe Ratio", "19.094"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "97.754%"},
|
||||
{"End Equity", "104486.22"},
|
||||
{"Net Profit", "4.486%"},
|
||||
{"Sharpe Ratio", "17.304"},
|
||||
{"Sortino Ratio", "35.217"},
|
||||
{"Probabilistic Sharpe Ratio", "96.835%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.005"},
|
||||
{"Beta", "0.998"},
|
||||
{"Annual Standard Deviation", "0.138"},
|
||||
{"Annual Variance", "0.019"},
|
||||
{"Information Ratio", "-34.028"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "2.644"},
|
||||
{"Total Fees", "$3.45"},
|
||||
{"Estimated Strategy Capacity", "$970000000.00"},
|
||||
{"Alpha", "-0.249"},
|
||||
{"Beta", "1.015"},
|
||||
{"Annual Standard Deviation", "0.141"},
|
||||
{"Annual Variance", "0.02"},
|
||||
{"Information Ratio", "-19"},
|
||||
{"Tracking Error", "0.011"},
|
||||
{"Treynor Ratio", "2.403"},
|
||||
{"Total Fees", "$3.49"},
|
||||
{"Estimated Strategy Capacity", "$1200000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "10.09%"},
|
||||
{"OrderListHash", "39a84b9f15bb4e8ead0f0ecb59f28562"}
|
||||
{"Portfolio Turnover", "10.01%"},
|
||||
{"OrderListHash", "70f21e930175a2ec9d465b21edc1b6d9"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
239
Algorithm.CSharp/BasicTemplateEurexFuturesAlgorithm.cs
Normal file
239
Algorithm.CSharp/BasicTemplateEurexFuturesAlgorithm.cs
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Securities;
|
||||
using QuantConnect.Securities.Future;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// This algorithm tests and demonstrates EUREX futures subscription and trading:
|
||||
/// - It tests contracts rollover by adding a continuous future and asserting that mapping happens at some point.
|
||||
/// - It tests basic trading by buying a contract and holding it until expiration.
|
||||
/// - It tests delisting and asserts the holdings are liquidated after that.
|
||||
/// </summary>
|
||||
public class BasicTemplateEurexFuturesAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Future _continuousContract;
|
||||
private Symbol _mappedSymbol;
|
||||
private Symbol _contractToTrade;
|
||||
private int _mappingsCount;
|
||||
private decimal _boughtQuantity;
|
||||
private decimal _liquidatedQuantity;
|
||||
private bool _delisted;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2024, 5, 30);
|
||||
SetEndDate(2024, 6, 23);
|
||||
|
||||
SetAccountCurrency(Currencies.EUR);
|
||||
SetCash(1000000);
|
||||
|
||||
_continuousContract = AddFuture(Futures.Indices.EuroStoxx50, Resolution.Minute,
|
||||
dataNormalizationMode: DataNormalizationMode.BackwardsRatio,
|
||||
dataMappingMode: DataMappingMode.FirstDayMonth,
|
||||
contractDepthOffset: 0);
|
||||
_continuousContract.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(180));
|
||||
_mappedSymbol = _continuousContract.Mapped;
|
||||
|
||||
var benchmark = AddIndex("SX5E", market: Market.EUREX);
|
||||
SetBenchmark(benchmark.Symbol);
|
||||
|
||||
var seeder = new FuncSecuritySeeder(GetLastKnownPrices);
|
||||
SetSecurityInitializer(security => seeder.SeedSecurity(security));
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
foreach (var changedEvent in slice.SymbolChangedEvents.Values)
|
||||
{
|
||||
if (++_mappingsCount > 1)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected number of symbol changed events (mappings): {_mappingsCount}. " +
|
||||
$"Expected only 1.");
|
||||
}
|
||||
|
||||
Debug($"{Time} - SymbolChanged event: {changedEvent}");
|
||||
|
||||
if (changedEvent.OldSymbol != _mappedSymbol.ID.ToString())
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected symbol changed event old symbol: {changedEvent}");
|
||||
}
|
||||
|
||||
if (changedEvent.NewSymbol != _continuousContract.Mapped.ID.ToString())
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected symbol changed event new symbol: {changedEvent}");
|
||||
}
|
||||
|
||||
// Let's trade the previous mapped contract, so we can hold it until expiration for testing
|
||||
// (will be sooner than the new mapped contract)
|
||||
_contractToTrade = _mappedSymbol;
|
||||
_mappedSymbol = _continuousContract.Mapped;
|
||||
}
|
||||
|
||||
// Let's trade after the mapping is done
|
||||
if (_contractToTrade != null && _boughtQuantity == 0 && Securities[_contractToTrade].Exchange.ExchangeOpen)
|
||||
{
|
||||
Buy(_contractToTrade, 1);
|
||||
}
|
||||
|
||||
if (_contractToTrade != null && slice.Delistings.TryGetValue(_contractToTrade, out var delisting))
|
||||
{
|
||||
if (delisting.Type == DelistingType.Delisted)
|
||||
{
|
||||
_delisted = true;
|
||||
|
||||
if (Portfolio.Invested)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Portfolio should not be invested after the traded contract is delisted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOrderEvent(OrderEvent orderEvent)
|
||||
{
|
||||
if (orderEvent.Symbol != _contractToTrade)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected order event symbol: {orderEvent.Symbol}. Expected {_contractToTrade}");
|
||||
}
|
||||
|
||||
if (orderEvent.Direction == OrderDirection.Buy)
|
||||
{
|
||||
if (orderEvent.Status == OrderStatus.Filled)
|
||||
{
|
||||
if (_boughtQuantity != 0 && _liquidatedQuantity != 0)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected buy order event status: {orderEvent.Status}");
|
||||
}
|
||||
_boughtQuantity = orderEvent.Quantity;
|
||||
}
|
||||
}
|
||||
else if (orderEvent.Direction == OrderDirection.Sell)
|
||||
{
|
||||
if (orderEvent.Status == OrderStatus.Filled)
|
||||
{
|
||||
if (_boughtQuantity <= 0 && _liquidatedQuantity != 0)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected sell order event status: {orderEvent.Status}");
|
||||
}
|
||||
_liquidatedQuantity = orderEvent.Quantity;
|
||||
|
||||
if (_liquidatedQuantity != -_boughtQuantity)
|
||||
{
|
||||
throw new RegressionTestException($"{Time} - Unexpected liquidated quantity: {_liquidatedQuantity}. Expected: {-_boughtQuantity}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
foreach (var addedSecurity in changes.AddedSecurities)
|
||||
{
|
||||
if (addedSecurity.Symbol.SecurityType == SecurityType.Future && addedSecurity.Symbol.IsCanonical())
|
||||
{
|
||||
_mappedSymbol = _continuousContract.Mapped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (_mappingsCount == 0)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected number of symbol changed events (mappings): {_mappingsCount}. Expected 1.");
|
||||
}
|
||||
|
||||
if (!_delisted)
|
||||
{
|
||||
throw new RegressionTestException("Contract was not delisted");
|
||||
}
|
||||
|
||||
// Make sure we traded and that the position was liquidated on delisting
|
||||
if (_boughtQuantity <= 0 || _liquidatedQuantity >= 0)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected sold quantity: {_boughtQuantity} and liquidated quantity: {_liquidatedQuantity}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 133945;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 26;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.11%"},
|
||||
{"Compounding Annual Return", "-1.667%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "998849.48"},
|
||||
{"Net Profit", "-0.115%"},
|
||||
{"Sharpe Ratio", "-34.455"},
|
||||
{"Sortino Ratio", "-57.336"},
|
||||
{"Probabilistic Sharpe Ratio", "0.002%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.002"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-6.176"},
|
||||
{"Tracking Error", "0.002"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "€1.02"},
|
||||
{"Estimated Strategy Capacity", "€2300000000.00"},
|
||||
{"Lowest Capacity Asset", "FESX YJHOAMPYKRS5"},
|
||||
{"Portfolio Turnover", "0.40%"},
|
||||
{"OrderListHash", "54040d29a467becaedcf59d79323321b"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
@@ -41,8 +42,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">TradeBars IDictionary object with your stock data</param>
|
||||
public void OnData(TradeBars data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
|
||||
@@ -176,12 +176,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1325;
|
||||
public long DataPoints => 1190;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 4;
|
||||
public int AlgorithmHistoryDataPoints => 2;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
@@ -193,33 +193,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0.53%"},
|
||||
{"Total Orders", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "3.011%"},
|
||||
{"Compounding Annual Return", "-0.010%"},
|
||||
{"Drawdown", "0.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "1005283.2"},
|
||||
{"Net Profit", "0.528%"},
|
||||
{"Sharpe Ratio", "1.285"},
|
||||
{"End Equity", "999983.2"},
|
||||
{"Net Profit", "-0.002%"},
|
||||
{"Sharpe Ratio", "-225.214"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "83.704%"},
|
||||
{"Probabilistic Sharpe Ratio", "0.135%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.015"},
|
||||
{"Beta", "-0.004"},
|
||||
{"Annual Standard Deviation", "0.011"},
|
||||
{"Alpha", "-0.008"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-4.774"},
|
||||
{"Tracking Error", "0.084"},
|
||||
{"Treynor Ratio", "-3.121"},
|
||||
{"Total Fees", "$4.30"},
|
||||
{"Estimated Strategy Capacity", "$5900000000.00"},
|
||||
{"Information Ratio", "-5.146"},
|
||||
{"Tracking Error", "0.083"},
|
||||
{"Treynor Ratio", "-542.359"},
|
||||
{"Total Fees", "$2.15"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "0.27%"},
|
||||
{"OrderListHash", "90f952729deb9cb20be75867576e5b87"}
|
||||
{"Portfolio Turnover", "0.13%"},
|
||||
{"OrderListHash", "273dd05b937c075b75baf8af46d3c7de"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// if found, trade it.
|
||||
// Also check if exchange is open for regular or extended hours. Since daily data comes at 8PM, this allows us prevent the
|
||||
// algorithm from trading on friday when there is not after-market.
|
||||
if (contract != null && Securities[contract.Symbol].Exchange.Hours.IsOpen(Time, true))
|
||||
if (contract != null)
|
||||
{
|
||||
MarketOrder(contract.Symbol, 1);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 13934;
|
||||
public virtual long DataPoints => 12452;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -134,33 +134,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public virtual Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "128"},
|
||||
{"Average Win", "0.26%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-0.071%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-0.116"},
|
||||
{"Total Orders", "32"},
|
||||
{"Average Win", "0.33%"},
|
||||
{"Average Loss", "-0.04%"},
|
||||
{"Compounding Annual Return", "0.110%"},
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "0.184"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "999287.06"},
|
||||
{"Net Profit", "-0.071%"},
|
||||
{"Sharpe Ratio", "-1.999"},
|
||||
{"Sortino Ratio", "-1.806"},
|
||||
{"Probabilistic Sharpe Ratio", "10.091%"},
|
||||
{"Loss Rate", "97%"},
|
||||
{"Win Rate", "3%"},
|
||||
{"Profit-Loss Ratio", "27.29"},
|
||||
{"Alpha", "-0.008"},
|
||||
{"Beta", "0.001"},
|
||||
{"End Equity", "1001108"},
|
||||
{"Net Profit", "0.111%"},
|
||||
{"Sharpe Ratio", "-1.688"},
|
||||
{"Sortino Ratio", "-0.772"},
|
||||
{"Probabilistic Sharpe Ratio", "14.944%"},
|
||||
{"Loss Rate", "88%"},
|
||||
{"Win Rate", "12%"},
|
||||
{"Profit-Loss Ratio", "8.47"},
|
||||
{"Alpha", "-0.007"},
|
||||
{"Beta", "0.002"},
|
||||
{"Annual Standard Deviation", "0.004"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.367"},
|
||||
{"Information Ratio", "-1.353"},
|
||||
{"Tracking Error", "0.089"},
|
||||
{"Treynor Ratio", "-5.445"},
|
||||
{"Total Fees", "$285.44"},
|
||||
{"Estimated Strategy Capacity", "$1000.00"},
|
||||
{"Treynor Ratio", "-4.099"},
|
||||
{"Total Fees", "$72.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "ES VRJST036ZY0X"},
|
||||
{"Portfolio Turnover", "3.41%"},
|
||||
{"OrderListHash", "394c47e4e0f54c5981d7c8aa99e9bc83"}
|
||||
{"Portfolio Turnover", "0.87%"},
|
||||
{"OrderListHash", "168731c8f3a19f230cc1410818b3b573"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,33 +48,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "638"},
|
||||
{"Average Win", "0.02%"},
|
||||
{"Total Orders", "716"},
|
||||
{"Average Win", "0.03%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-1.610%"},
|
||||
{"Drawdown", "1.600%"},
|
||||
{"Expectancy", "-0.841"},
|
||||
{"Compounding Annual Return", "-1.716%"},
|
||||
{"Drawdown", "1.700%"},
|
||||
{"Expectancy", "-0.770"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "983783.82"},
|
||||
{"Net Profit", "-1.622%"},
|
||||
{"Sharpe Ratio", "-8.787"},
|
||||
{"Sortino Ratio", "-5.428"},
|
||||
{"End Equity", "982718.38"},
|
||||
{"Net Profit", "-1.728%"},
|
||||
{"Sharpe Ratio", "-8.845"},
|
||||
{"Sortino Ratio", "-5.449"},
|
||||
{"Probabilistic Sharpe Ratio", "0.000%"},
|
||||
{"Loss Rate", "96%"},
|
||||
{"Win Rate", "4%"},
|
||||
{"Profit-Loss Ratio", "3.21"},
|
||||
{"Profit-Loss Ratio", "4.89"},
|
||||
{"Alpha", "-0.018"},
|
||||
{"Beta", "-0.003"},
|
||||
{"Beta", "-0.002"},
|
||||
{"Annual Standard Deviation", "0.002"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.473"},
|
||||
{"Information Ratio", "-1.483"},
|
||||
{"Tracking Error", "0.089"},
|
||||
{"Treynor Ratio", "5.593"},
|
||||
{"Total Fees", "$1456.18"},
|
||||
{"Estimated Strategy Capacity", "$9000.00"},
|
||||
{"Treynor Ratio", "9.102"},
|
||||
{"Total Fees", "$1634.12"},
|
||||
{"Estimated Strategy Capacity", "$8000.00"},
|
||||
{"Lowest Capacity Asset", "ES VP274HSU1AF5"},
|
||||
{"Portfolio Turnover", "17.91%"},
|
||||
{"OrderListHash", "b5214a0fcd0694093aa2a478a983de1a"}
|
||||
{"Portfolio Turnover", "20.10%"},
|
||||
{"OrderListHash", "aa7e574f86b70428ca0afae381be80ba"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,40 +43,40 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 16161;
|
||||
public override long DataPoints => 14790;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "156"},
|
||||
{"Average Win", "0.31%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-0.024%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-0.035"},
|
||||
{"Total Orders", "36"},
|
||||
{"Average Win", "0.33%"},
|
||||
{"Average Loss", "-0.03%"},
|
||||
{"Compounding Annual Return", "0.102%"},
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "0.171"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "999754.94"},
|
||||
{"Net Profit", "-0.025%"},
|
||||
{"Sharpe Ratio", "-1.602"},
|
||||
{"Sortino Ratio", "-1.913"},
|
||||
{"Probabilistic Sharpe Ratio", "11.172%"},
|
||||
{"Loss Rate", "97%"},
|
||||
{"Win Rate", "3%"},
|
||||
{"Profit-Loss Ratio", "36.65"},
|
||||
{"End Equity", "1001024.4"},
|
||||
{"Net Profit", "0.102%"},
|
||||
{"Sharpe Ratio", "-1.702"},
|
||||
{"Sortino Ratio", "-0.836"},
|
||||
{"Probabilistic Sharpe Ratio", "14.653%"},
|
||||
{"Loss Rate", "89%"},
|
||||
{"Win Rate", "11%"},
|
||||
{"Profit-Loss Ratio", "9.54"},
|
||||
{"Alpha", "-0.007"},
|
||||
{"Beta", "-0.001"},
|
||||
{"Annual Standard Deviation", "0.005"},
|
||||
{"Beta", "0.002"},
|
||||
{"Annual Standard Deviation", "0.004"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.359"},
|
||||
{"Information Ratio", "-1.353"},
|
||||
{"Tracking Error", "0.089"},
|
||||
{"Treynor Ratio", "8.008"},
|
||||
{"Total Fees", "$347.56"},
|
||||
{"Estimated Strategy Capacity", "$1000.00"},
|
||||
{"Treynor Ratio", "-4.126"},
|
||||
{"Total Fees", "$80.60"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "ES VRJST036ZY0X"},
|
||||
{"Portfolio Turnover", "4.16%"},
|
||||
{"OrderListHash", "52580f1e94ab1875301d3bbd157f4580"}
|
||||
{"Portfolio Turnover", "0.97%"},
|
||||
{"OrderListHash", "52c852d720692fab1e12212b2aba03d4"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,17 +48,17 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "1990"},
|
||||
{"Total Orders", "1992"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "-0.01%"},
|
||||
{"Compounding Annual Return", "-4.683%"},
|
||||
{"Compounding Annual Return", "-4.687%"},
|
||||
{"Drawdown", "4.700%"},
|
||||
{"Expectancy", "-0.911"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "952831.02"},
|
||||
{"Net Profit", "-4.717%"},
|
||||
{"Sharpe Ratio", "-7.178"},
|
||||
{"Sortino Ratio", "-5.126"},
|
||||
{"End Equity", "952789.22"},
|
||||
{"Net Profit", "-4.721%"},
|
||||
{"Sharpe Ratio", "-7.183"},
|
||||
{"Sortino Ratio", "-5.14"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "97%"},
|
||||
{"Win Rate", "3%"},
|
||||
@@ -69,12 +69,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.702"},
|
||||
{"Tracking Error", "0.09"},
|
||||
{"Treynor Ratio", "5.049"},
|
||||
{"Total Fees", "$4538.98"},
|
||||
{"Treynor Ratio", "5.054"},
|
||||
{"Total Fees", "$4543.28"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Lowest Capacity Asset", "ES VP274HSU1AF5"},
|
||||
{"Portfolio Turnover", "56.68%"},
|
||||
{"OrderListHash", "60f85901ecc345e597c0153506792285"}
|
||||
{"Portfolio Turnover", "56.73%"},
|
||||
{"OrderListHash", "424536177e9be5895bab50638ef43a9d"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
AddIndexOptionContract(SpxOption, Resolution);
|
||||
|
||||
_emaSlow = EMA(Spx, 80);
|
||||
_emaFast = EMA(Spx, 200);
|
||||
_emaSlow = EMA(Spx, Resolution > Resolution.Minute ? 6 : 80);
|
||||
_emaFast = EMA(Spx, Resolution > Resolution.Minute ? 2 : 200);
|
||||
|
||||
Settings.DailyPreciseEndTime = true;
|
||||
}
|
||||
@@ -93,12 +93,25 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts indicators are ready
|
||||
/// </summary>
|
||||
/// <exception cref="RegressionTestException"></exception>
|
||||
protected void AssertIndicators()
|
||||
{
|
||||
if (!_emaSlow.IsReady || !_emaFast.IsReady)
|
||||
{
|
||||
throw new RegressionTestException("Indicators are not ready!");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (Portfolio[Spx].TotalSaleVolume > 0)
|
||||
{
|
||||
throw new RegressionTestException("Index is not tradable.");
|
||||
}
|
||||
AssertIndicators();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
throw new ArgumentException($"Bar Count {BarCounter} is not expected count of {ExpectedBarCount}");
|
||||
}
|
||||
AssertIndicators();
|
||||
|
||||
if (Resolution != Resolution.Daily)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using QuantConnect.Data;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Indicators;
|
||||
@@ -48,8 +47,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
var spxOptions = AddIndexOption(_spx, Resolution);
|
||||
spxOptions.SetFilter(filterFunc => filterFunc.CallsOnly());
|
||||
|
||||
_emaSlow = EMA(_spx, 80);
|
||||
_emaFast = EMA(_spx, 200);
|
||||
_emaSlow = EMA(_spx, Resolution > Resolution.Minute ? 6 : 80);
|
||||
_emaFast = EMA(_spx, Resolution > Resolution.Minute ? 2 : 200);
|
||||
|
||||
Settings.DailyPreciseEndTime = true;
|
||||
}
|
||||
@@ -110,6 +109,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
throw new RegressionTestException("Trade volume should be greater than zero by the end of this algorithm");
|
||||
}
|
||||
AssertIndicators();
|
||||
}
|
||||
|
||||
public Symbol InvertOption(Symbol symbol)
|
||||
@@ -123,6 +123,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
symbol.ID.Date);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts indicators are ready
|
||||
/// </summary>
|
||||
/// <exception cref="RegressionTestException"></exception>
|
||||
protected void AssertIndicators()
|
||||
{
|
||||
if (!_emaSlow.IsReady || !_emaFast.IsReady)
|
||||
{
|
||||
throw new RegressionTestException("Indicators are not ready!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 378;
|
||||
public override long DataPoints => 356;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 2163;
|
||||
public override long DataPoints => 1269;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 471135;
|
||||
public long DataPoints => 15023;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -142,7 +142,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$26.00"},
|
||||
{"Estimated Strategy Capacity", "$70000.00"},
|
||||
{"Estimated Strategy Capacity", "$69000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZERHAOVVQ|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "61.31%"},
|
||||
{"OrderListHash", "35d406df401e5b27244e20f5ec57346e"}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 471124;
|
||||
public long DataPoints => 15130;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -152,7 +152,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$543.40"},
|
||||
{"Estimated Strategy Capacity", "$3000.00"},
|
||||
{"Estimated Strategy Capacity", "$4000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZFMEBBB2E|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "338.60%"},
|
||||
{"OrderListHash", "301c15063f6e269023d144ca69a765da"}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 471124;
|
||||
public long DataPoints => 15012;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -34,21 +34,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <meta name="tag" content="filter selection" />
|
||||
public class BasicTemplateOptionsDailyAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private const string UnderlyingTicker = "GOOG";
|
||||
private const string UnderlyingTicker = "AAPL";
|
||||
private Symbol _optionSymbol;
|
||||
private bool _optionExpired;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2015, 12, 23);
|
||||
SetEndDate(2016, 1, 20);
|
||||
SetStartDate(2015, 12, 15);
|
||||
SetEndDate(2016, 2, 1);
|
||||
SetCash(100000);
|
||||
|
||||
var equity = AddEquity(UnderlyingTicker, Resolution.Daily);
|
||||
var option = AddOption(UnderlyingTicker, Resolution.Daily);
|
||||
_optionSymbol = option.Symbol;
|
||||
|
||||
option.SetFilter(x => x.CallsOnly().Strikes(0, 1).Expiration(0, 30));
|
||||
option.SetFilter(x => x.CallsOnly().Expiration(0, 60));
|
||||
|
||||
// use the underlying equity as the benchmark
|
||||
SetBenchmark(equity.Symbol);
|
||||
@@ -122,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 36834;
|
||||
public long DataPoints => 308;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -141,31 +141,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-1.31%"},
|
||||
{"Compounding Annual Return", "-15.304%"},
|
||||
{"Drawdown", "1.300%"},
|
||||
{"Average Loss", "-1.16%"},
|
||||
{"Compounding Annual Return", "-8.351%"},
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "98689"},
|
||||
{"Net Profit", "-1.311%"},
|
||||
{"Sharpe Ratio", "-3.607"},
|
||||
{"Sortino Ratio", "-1.188"},
|
||||
{"Probabilistic Sharpe Ratio", "0.035%"},
|
||||
{"End Equity", "98844"},
|
||||
{"Net Profit", "-1.156%"},
|
||||
{"Sharpe Ratio", "-4.04"},
|
||||
{"Sortino Ratio", "-2.422"},
|
||||
{"Probabilistic Sharpe Ratio", "0.099%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0.034"},
|
||||
{"Annual Variance", "0.001"},
|
||||
{"Information Ratio", "-3.31"},
|
||||
{"Tracking Error", "0.034"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Alpha", "-0.058"},
|
||||
{"Beta", "0.021"},
|
||||
{"Annual Standard Deviation", "0.017"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "1.49"},
|
||||
{"Tracking Error", "0.289"},
|
||||
{"Treynor Ratio", "-3.212"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZFMML01JA|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "0.05%"},
|
||||
{"OrderListHash", "e188868e048fab6b6a0481b4479e97f9"}
|
||||
{"Estimated Strategy Capacity", "$72000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL W78ZEO2985GM|AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.02%"},
|
||||
{"OrderListHash", "b3125e0af79da0f5eea4cfda09806324"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
@@ -100,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1252633;
|
||||
public long DataPoints => 12290;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -120,7 +119,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.40%"},
|
||||
{"Compounding Annual Return", "-21.622%"},
|
||||
{"Compounding Annual Return", "-20.338%"},
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1847643;
|
||||
public long DataPoints => 17486;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -157,32 +157,32 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "0.14%"},
|
||||
{"Average Loss", "-0.28%"},
|
||||
{"Compounding Annual Return", "-47.543%"},
|
||||
{"Average Win", "0.13%"},
|
||||
{"Average Loss", "-0.30%"},
|
||||
{"Compounding Annual Return", "-46.395%"},
|
||||
{"Drawdown", "1.600%"},
|
||||
{"Expectancy", "0.502"},
|
||||
{"Expectancy", "0.429"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99178.50"},
|
||||
{"Net Profit", "-0.821%"},
|
||||
{"Sharpe Ratio", "-4.136"},
|
||||
{"End Equity", "99149.50"},
|
||||
{"Net Profit", "-0.850%"},
|
||||
{"Sharpe Ratio", "-4.298"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "17.155%"},
|
||||
{"Probabilistic Sharpe Ratio", "15.319%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0.50"},
|
||||
{"Alpha", "-0.855"},
|
||||
{"Beta", "1.047"},
|
||||
{"Annual Standard Deviation", "0.099"},
|
||||
{"Profit-Loss Ratio", "0.43"},
|
||||
{"Alpha", "-0.84"},
|
||||
{"Beta", "0.986"},
|
||||
{"Annual Standard Deviation", "0.098"},
|
||||
{"Annual Variance", "0.01"},
|
||||
{"Information Ratio", "-9.141"},
|
||||
{"Information Ratio", "-9.299"},
|
||||
{"Tracking Error", "0.091"},
|
||||
{"Treynor Ratio", "-0.392"},
|
||||
{"Treynor Ratio", "-0.428"},
|
||||
{"Total Fees", "$4.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "13.49%"},
|
||||
{"OrderListHash", "2722fee93126736e03d66d7ab880b537"}
|
||||
{"Portfolio Turnover", "13.50%"},
|
||||
{"OrderListHash", "cf14a7ce9c86e6844051820fd4c9394c"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 32351;
|
||||
public long DataPoints => 9504;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -129,7 +129,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.07%"},
|
||||
{"Compounding Annual Return", "-12.496%"},
|
||||
{"Compounding Annual Return", "-11.517%"},
|
||||
{"Drawdown", "0.200%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
|
||||
@@ -43,14 +43,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetEndDate(2021, 1, 10);
|
||||
SetCash(1000000);
|
||||
|
||||
var spx = AddIndex("SPX").Symbol;
|
||||
|
||||
// regular option SPX contracts
|
||||
var spxOptions = AddIndexOption(spx);
|
||||
var spxOptions = AddIndexOption("SPX");
|
||||
spxOptions.SetFilter(u => u.Strikes(0, 1).Expiration(0, 30));
|
||||
|
||||
// weekly option SPX contracts
|
||||
var spxw = AddIndexOption(spx, "SPXW");
|
||||
var spxw = AddIndexOption("SPX", "SPXW");
|
||||
spxw.SetFilter(u => u.Strikes(0, 1)
|
||||
// single week ahead since there are many SPXW contracts and we want to preserve performance
|
||||
.Expiration(0, 7)
|
||||
@@ -105,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 57869;
|
||||
public virtual long DataPoints => 21467;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -125,29 +123,29 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "5"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.69%"},
|
||||
{"Compounding Annual Return", "59.804%"},
|
||||
{"Compounding Annual Return", "54.478%"},
|
||||
{"Drawdown", "0.400%"},
|
||||
{"Expectancy", "-0.5"},
|
||||
{"Start Equity", "1000000"},
|
||||
{"End Equity", "1006025"},
|
||||
{"Net Profit", "0.602%"},
|
||||
{"Sharpe Ratio", "3.01"},
|
||||
{"Sharpe Ratio", "2.62"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "62.865%"},
|
||||
{"Probabilistic Sharpe Ratio", "63.221%"},
|
||||
{"Loss Rate", "50%"},
|
||||
{"Win Rate", "50%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.249"},
|
||||
{"Beta", "-0.033"},
|
||||
{"Alpha", "0.067"},
|
||||
{"Beta", "-0.013"},
|
||||
{"Annual Standard Deviation", "0.004"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-99.414"},
|
||||
{"Tracking Error", "0.072"},
|
||||
{"Treynor Ratio", "-0.382"},
|
||||
{"Information Ratio", "-50.808"},
|
||||
{"Tracking Error", "0.086"},
|
||||
{"Treynor Ratio", "-0.725"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$580000.00"},
|
||||
{"Lowest Capacity Asset", "SPXW 31K54PVWHUJHQ|SPX 31"},
|
||||
{"Portfolio Turnover", "0.48%"},
|
||||
{"Portfolio Turnover", "0.40%"},
|
||||
{"OrderListHash", "07a085baedb37bb7c8d460558ea77e88"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 40968;
|
||||
public virtual long DataPoints => 16680;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Fundamental;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
@@ -68,8 +69,8 @@ namespace QuantConnect.Algorithm.CSharp.Benchmarks
|
||||
return topFine.Select(x => x.Symbol);
|
||||
}
|
||||
|
||||
//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
|
||||
public void OnData(TradeBars data)
|
||||
//Data Event Handler: New data arrives here.
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
// if we have no changes, do nothing
|
||||
if (_changes == SecurityChanges.None) return;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Indicators;
|
||||
|
||||
@@ -58,7 +59,7 @@ namespace QuantConnect.Algorithm.CSharp.Benchmarks
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
public void OnData(TradeBars data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
// wait for our entire ribbon to be ready
|
||||
if (!_ribbon.All(x => x.IsReady)) return;
|
||||
|
||||
@@ -93,33 +93,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "14"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.23%"},
|
||||
{"Compounding Annual Return", "63.336%"},
|
||||
{"Total Orders", "22"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Average Loss", "-0.14%"},
|
||||
{"Compounding Annual Return", "71.152%"},
|
||||
{"Drawdown", "1.100%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Expectancy", "-0.797"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100674.37"},
|
||||
{"Net Profit", "0.674%"},
|
||||
{"Sharpe Ratio", "3.986"},
|
||||
{"End Equity", "100738.86"},
|
||||
{"Net Profit", "0.739%"},
|
||||
{"Sharpe Ratio", "4.46"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "58.892%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.595"},
|
||||
{"Beta", "0.57"},
|
||||
{"Probabilistic Sharpe Ratio", "60.106%"},
|
||||
{"Loss Rate", "80%"},
|
||||
{"Win Rate", "20%"},
|
||||
{"Profit-Loss Ratio", "0.02"},
|
||||
{"Alpha", "-0.552"},
|
||||
{"Beta", "0.579"},
|
||||
{"Annual Standard Deviation", "0.133"},
|
||||
{"Annual Variance", "0.018"},
|
||||
{"Information Ratio", "-13.918"},
|
||||
{"Tracking Error", "0.104"},
|
||||
{"Treynor Ratio", "0.93"},
|
||||
{"Total Fees", "$40.20"},
|
||||
{"Estimated Strategy Capacity", "$4400000.00"},
|
||||
{"Information Ratio", "-13.953"},
|
||||
{"Tracking Error", "0.099"},
|
||||
{"Treynor Ratio", "1.024"},
|
||||
{"Total Fees", "$46.24"},
|
||||
{"Estimated Strategy Capacity", "$2600000.00"},
|
||||
{"Lowest Capacity Asset", "AIG R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "64.47%"},
|
||||
{"OrderListHash", "fa0af3b345296ccc41e25c0b6c30fc96"}
|
||||
{"Portfolio Turnover", "69.06%"},
|
||||
{"OrderListHash", "44a85134cd1c91c9720549bc0e007f80"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
using QuantConnect.Brokerages;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Securities;
|
||||
@@ -58,8 +59,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">TradeBars IDictionary object with your stock data</param>
|
||||
public void OnData(TradeBars data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
|
||||
@@ -116,9 +116,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// New TradeBar data for our assets.
|
||||
/// New data for our assets.
|
||||
/// </summary>
|
||||
public void OnData(TradeBars data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Orders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm to test we can liquidate our portfolio holdings using order properties
|
||||
/// </summary>
|
||||
public class CanLiquidateWithOrderPropertiesRegressionAlgorithm: QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private readonly DateTime _openExchange = new (2014, 6, 6, 10, 0, 0);
|
||||
private readonly DateTime _closeExchange = new(2014, 6, 6, 16, 0, 0);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2014, 6, 5);
|
||||
SetEndDate(2014, 6, 6);
|
||||
|
||||
AddEquity("AAPL", Resolution.Minute);
|
||||
}
|
||||
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (Time > _openExchange && Time < _closeExchange)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
MarketOrder("AAPL", 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
var orderProperties = new OrderProperties() { TimeInForce = TimeInForce.Day };
|
||||
var tickets = Liquidate(asynchronous: true, orderProperties: orderProperties);
|
||||
foreach (var ticket in tickets)
|
||||
{
|
||||
if (ticket.SubmitRequest.OrderProperties.TimeInForce != TimeInForce.Day)
|
||||
{
|
||||
throw new RegressionTestException("The TimeInForce for all orders should be daily, but it was {ticket.SubmitRequest.OrderProperties.TimeInForce}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp, Language.Python };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1583;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "359"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99637.08"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "0"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$359.00"},
|
||||
{"Estimated Strategy Capacity", "$130000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "37.56%"},
|
||||
{"OrderListHash", "e9e8a07dc58bff7198181f9fafb58834"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
using QuantConnect.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Consolidators;
|
||||
using QuantConnect.Data.Market;
|
||||
|
||||
@@ -71,7 +72,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// We're doing our analysis in the OnRenkoBar method, but the framework verifies that this method exists, so we define it.
|
||||
/// </summary>
|
||||
public void OnData(TradeBars data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "29"},
|
||||
{"Average Win", "1.85%"},
|
||||
{"Average Loss", "-1.49%"},
|
||||
{"Compounding Annual Return", "7.817%"},
|
||||
{"Compounding Annual Return", "7.824%"},
|
||||
{"Drawdown", "6.800%"},
|
||||
{"Expectancy", "0.281"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -154,10 +155,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.083"},
|
||||
{"Treynor Ratio", "0.118"},
|
||||
{"Total Fees", "$129.34"},
|
||||
{"Estimated Strategy Capacity", "$1000000000.00"},
|
||||
{"Estimated Strategy Capacity", "$2500000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "7.91%"},
|
||||
{"OrderListHash", "cb118f22e33089e9ab4af8514e4f2b5f"}
|
||||
{"OrderListHash", "2668157409450ab9949a71716a5dbc2e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Fundamental;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
@@ -80,8 +81,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
return topFine.Select(x => x.Symbol);
|
||||
}
|
||||
|
||||
//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
|
||||
public void OnData(TradeBars data)
|
||||
//Data Event Handler: New data arrives here.
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
// if we have no changes, do nothing
|
||||
if (_changes == SecurityChanges.None) return;
|
||||
|
||||
@@ -177,32 +177,32 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "1.16%"},
|
||||
{"Average Win", "1.39%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "32.505%"},
|
||||
{"Compounding Annual Return", "40.025%"},
|
||||
{"Drawdown", "1.400%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "50000"},
|
||||
{"End Equity", "50581.67"},
|
||||
{"Net Profit", "1.163%"},
|
||||
{"Sharpe Ratio", "2.666"},
|
||||
{"Sortino Ratio", "19.179"},
|
||||
{"Probabilistic Sharpe Ratio", "64.748%"},
|
||||
{"End Equity", "50696.56"},
|
||||
{"Net Profit", "1.393%"},
|
||||
{"Sharpe Ratio", "3.192"},
|
||||
{"Sortino Ratio", "4.952"},
|
||||
{"Probabilistic Sharpe Ratio", "68.664%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.272"},
|
||||
{"Beta", "0.436"},
|
||||
{"Annual Standard Deviation", "0.086"},
|
||||
{"Annual Variance", "0.007"},
|
||||
{"Information Ratio", "3.572"},
|
||||
{"Tracking Error", "0.092"},
|
||||
{"Treynor Ratio", "0.523"},
|
||||
{"Alpha", "0.328"},
|
||||
{"Beta", "0.474"},
|
||||
{"Annual Standard Deviation", "0.088"},
|
||||
{"Annual Variance", "0.008"},
|
||||
{"Information Ratio", "4.219"},
|
||||
{"Tracking Error", "0.09"},
|
||||
{"Treynor Ratio", "0.59"},
|
||||
{"Total Fees", "$2.00"},
|
||||
{"Estimated Strategy Capacity", "$49000000.00"},
|
||||
{"Estimated Strategy Capacity", "$81000000.00"},
|
||||
{"Lowest Capacity Asset", "IBM R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "6.64%"},
|
||||
{"OrderListHash", "69614ad86028ebc190bff5fb42795a3f"}
|
||||
{"Portfolio Turnover", "6.65%"},
|
||||
{"OrderListHash", "4eaacdd341a5be0d04cb32647d931471"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
UniverseSettings.Resolution = Resolution.Minute;
|
||||
|
||||
SetStartDate(2014, 06, 04);
|
||||
SetEndDate(2014, 06, 06);
|
||||
// TWX is selected the 4th and 5th and aapl after that.
|
||||
// If the algo ends on the 6th, TWX subscriptions will not be removed before OnEndOfAlgorithm is called:
|
||||
// - 6th: AAPL is selected, TWX is removed but subscriptions are not removed because the securities are invested.
|
||||
// - TWX and its options are liquidated.
|
||||
// - 7th: Since options universe selection is daily now, TWX subscriptions are removed the next day (7th)
|
||||
SetEndDate(2014, 06, 07);
|
||||
|
||||
var selectionUniverse = AddUniverse(enumerable => new[] { Time.Date <= new DateTime(2014, 6, 5) ? _twx : _aapl },
|
||||
enumerable => new[] { Time.Date <= new DateTime(2014, 6, 5) ? _twx : _aapl });
|
||||
@@ -157,7 +162,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 998464;
|
||||
public long DataPoints => 18993;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -197,8 +202,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.048"},
|
||||
{"Treynor Ratio", "0.172"},
|
||||
{"Total Fees", "$16.10"},
|
||||
{"Estimated Strategy Capacity", "$3100000.00"},
|
||||
{"Lowest Capacity Asset", "AOL VRKS95ENLBYE|AOL R735QTJ8XC9X"},
|
||||
{"Estimated Strategy Capacity", "$5000000.00"},
|
||||
{"Lowest Capacity Asset", "AOL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "17.64%"},
|
||||
{"OrderListHash", "a8605c1f5a9c67f60f1ddc963ec45542"}
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 35405;
|
||||
public long DataPoints => 35402;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 78091;
|
||||
public long DataPoints => 78088;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -136,32 +136,32 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "12"},
|
||||
{"Average Win", "0.55%"},
|
||||
{"Average Loss", "-0.26%"},
|
||||
{"Compounding Annual Return", "16.717%"},
|
||||
{"Drawdown", "1.700%"},
|
||||
{"Expectancy", "0.850"},
|
||||
{"Average Win", "0.63%"},
|
||||
{"Average Loss", "-0.49%"},
|
||||
{"Compounding Annual Return", "-35.851%"},
|
||||
{"Drawdown", "2.700%"},
|
||||
{"Expectancy", "-0.542"},
|
||||
{"Start Equity", "50000"},
|
||||
{"End Equity", "50318.65"},
|
||||
{"Net Profit", "0.637%"},
|
||||
{"Sharpe Ratio", "1.024"},
|
||||
{"Sortino Ratio", "2.169"},
|
||||
{"Probabilistic Sharpe Ratio", "50.223%"},
|
||||
{"Loss Rate", "40%"},
|
||||
{"Win Rate", "60%"},
|
||||
{"Profit-Loss Ratio", "2.08"},
|
||||
{"Alpha", "0.196"},
|
||||
{"Beta", "0.741"},
|
||||
{"Annual Standard Deviation", "0.118"},
|
||||
{"Annual Variance", "0.014"},
|
||||
{"Information Ratio", "2.294"},
|
||||
{"Tracking Error", "0.097"},
|
||||
{"Treynor Ratio", "0.163"},
|
||||
{"Total Fees", "$27.94"},
|
||||
{"Estimated Strategy Capacity", "$200000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "26.69%"},
|
||||
{"OrderListHash", "82ca991c660ecefbcbdf0b4cc90ddd67"}
|
||||
{"End Equity", "49096.01"},
|
||||
{"Net Profit", "-1.808%"},
|
||||
{"Sharpe Ratio", "-1.989"},
|
||||
{"Sortino Ratio", "-3.359"},
|
||||
{"Probabilistic Sharpe Ratio", "23.898%"},
|
||||
{"Loss Rate", "80%"},
|
||||
{"Win Rate", "20%"},
|
||||
{"Profit-Loss Ratio", "1.29"},
|
||||
{"Alpha", "-0.172"},
|
||||
{"Beta", "1.068"},
|
||||
{"Annual Standard Deviation", "0.141"},
|
||||
{"Annual Variance", "0.02"},
|
||||
{"Information Ratio", "-1.865"},
|
||||
{"Tracking Error", "0.096"},
|
||||
{"Treynor Ratio", "-0.263"},
|
||||
{"Total Fees", "$26.72"},
|
||||
{"Estimated Strategy Capacity", "$630000000.00"},
|
||||
{"Lowest Capacity Asset", "FB V6OIPNZEM8V9"},
|
||||
{"Portfolio Turnover", "24.59%"},
|
||||
{"OrderListHash", "90b57d40d047eedbff7111d2a73a1290"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 70952;
|
||||
public long DataPoints => 70951;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -13,12 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
@@ -30,7 +29,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class CoarseSelectionTimeRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private Symbol _spy;
|
||||
private decimal _historyCoarseSpyPrice;
|
||||
private decimal _spyPrice;
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
@@ -53,7 +52,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
.Where(fundamental => fundamental.Symbol != _spy) // ignore spy
|
||||
.Take(1);
|
||||
|
||||
_historyCoarseSpyPrice = History(_spy, 1).First().Close;
|
||||
var historyCoarseSpyPrice = History(_spy, 1).First().Close;
|
||||
if (_spyPrice != 0 && (historyCoarseSpyPrice == 0 || historyCoarseSpyPrice != _spyPrice))
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected SPY price: {historyCoarseSpyPrice}");
|
||||
}
|
||||
_spyPrice = 0;
|
||||
|
||||
return top.Select(x => x.Symbol);
|
||||
}
|
||||
@@ -72,12 +76,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected ActiveSecurities count: {ActiveSecurities.Count}");
|
||||
}
|
||||
// the price obtained by the previous coarse selection should be the same as the current price
|
||||
if (_historyCoarseSpyPrice != 0 && _historyCoarseSpyPrice != Securities[_spy].Price)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected SPY price: {_historyCoarseSpyPrice}");
|
||||
}
|
||||
_historyCoarseSpyPrice = 0;
|
||||
|
||||
// we get the data at 4PM, selection happening at midnight
|
||||
_spyPrice = Securities[_spy].Price;
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
SetHoldings(_spy, 1);
|
||||
@@ -98,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 49662;
|
||||
public long DataPoints => 49660;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -118,30 +119,30 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "57.657%"},
|
||||
{"Drawdown", "1.000%"},
|
||||
{"Compounding Annual Return", "36.033%"},
|
||||
{"Drawdown", "1.300%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "101002.81"},
|
||||
{"Net Profit", "1.003%"},
|
||||
{"Sharpe Ratio", "5.273"},
|
||||
{"Sortino Ratio", "7.973"},
|
||||
{"Probabilistic Sharpe Ratio", "69.521%"},
|
||||
{"End Equity", "100676.75"},
|
||||
{"Net Profit", "0.677%"},
|
||||
{"Sharpe Ratio", "2.646"},
|
||||
{"Sortino Ratio", "2.77"},
|
||||
{"Probabilistic Sharpe Ratio", "58.013%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "1.003"},
|
||||
{"Annual Standard Deviation", "0.087"},
|
||||
{"Annual Variance", "0.007"},
|
||||
{"Information Ratio", "6.477"},
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0.455"},
|
||||
{"Total Fees", "$3.08"},
|
||||
{"Estimated Strategy Capacity", "$720000000.00"},
|
||||
{"Alpha", "-0.264"},
|
||||
{"Beta", "1.183"},
|
||||
{"Annual Standard Deviation", "0.103"},
|
||||
{"Annual Variance", "0.011"},
|
||||
{"Information Ratio", "-8.158"},
|
||||
{"Tracking Error", "0.022"},
|
||||
{"Treynor Ratio", "0.231"},
|
||||
{"Total Fees", "$3.07"},
|
||||
{"Estimated Strategy Capacity", "$930000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "12.54%"},
|
||||
{"OrderListHash", "472e90ba189aaf55e0edab9087c3d8e7"}
|
||||
{"Portfolio Turnover", "12.65%"},
|
||||
{"OrderListHash", "87438e51988f37757a2d7f97389483ea"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 471135;
|
||||
public override long DataPoints => 15023;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 471135;
|
||||
public override long DataPoints => 15023;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 471135;
|
||||
public override long DataPoints => 15023;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -92,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$26.00"},
|
||||
{"Estimated Strategy Capacity", "$70000.00"},
|
||||
{"Estimated Strategy Capacity", "$69000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV W78ZERHAOVVQ|GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "30.35%"},
|
||||
{"OrderListHash", "615c795b0c450cb8e4c3cba803ebb180"}
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 471135;
|
||||
public long DataPoints => 15023;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -86,33 +86,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "14"},
|
||||
{"Average Win", "0.00%"},
|
||||
{"Average Loss", "-0.23%"},
|
||||
{"Compounding Annual Return", "-36.885%"},
|
||||
{"Drawdown", "1.800%"},
|
||||
{"Expectancy", "-0.549"},
|
||||
{"Total Orders", "16"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Average Loss", "-0.18%"},
|
||||
{"Compounding Annual Return", "-35.728%"},
|
||||
{"Drawdown", "1.700%"},
|
||||
{"Expectancy", "-0.690"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99413.33"},
|
||||
{"Net Profit", "-0.587%"},
|
||||
{"Sharpe Ratio", "-2.494"},
|
||||
{"Sortino Ratio", "-3.393"},
|
||||
{"Probabilistic Sharpe Ratio", "34.321%"},
|
||||
{"Loss Rate", "56%"},
|
||||
{"Win Rate", "44%"},
|
||||
{"Profit-Loss Ratio", "0.01"},
|
||||
{"Alpha", "-0.888"},
|
||||
{"Beta", "0.349"},
|
||||
{"Annual Standard Deviation", "0.08"},
|
||||
{"Annual Variance", "0.006"},
|
||||
{"Information Ratio", "-14.897"},
|
||||
{"Tracking Error", "0.146"},
|
||||
{"Treynor Ratio", "-0.568"},
|
||||
{"Total Fees", "$37.79"},
|
||||
{"End Equity", "99436.42"},
|
||||
{"Net Profit", "-0.564%"},
|
||||
{"Sharpe Ratio", "-2.767"},
|
||||
{"Sortino Ratio", "-3.388"},
|
||||
{"Probabilistic Sharpe Ratio", "32.568%"},
|
||||
{"Loss Rate", "70%"},
|
||||
{"Win Rate", "30%"},
|
||||
{"Profit-Loss Ratio", "0.03"},
|
||||
{"Alpha", "-0.771"},
|
||||
{"Beta", "0.296"},
|
||||
{"Annual Standard Deviation", "0.068"},
|
||||
{"Annual Variance", "0.005"},
|
||||
{"Information Ratio", "-13.734"},
|
||||
{"Tracking Error", "0.157"},
|
||||
{"Treynor Ratio", "-0.632"},
|
||||
{"Total Fees", "$39.85"},
|
||||
{"Estimated Strategy Capacity", "$4700000.00"},
|
||||
{"Lowest Capacity Asset", "AIG R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "60.65%"},
|
||||
{"OrderListHash", "d84db24a398d074200c5ed979c4410f3"}
|
||||
{"Portfolio Turnover", "60.79%"},
|
||||
{"OrderListHash", "7a65de0f613e5c6161e410d499f45445"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetHoldings("SPY", 1);
|
||||
}
|
||||
});
|
||||
_consolidationDaily.Enqueue(new DateTime(2013, 10, 8, 0, 0, 0));
|
||||
_consolidationDaily.Enqueue(new DateTime(2013, 10, 9, 0, 0, 0));
|
||||
_consolidationDaily.Enqueue(new DateTime(2013, 10, 10, 0, 0, 0));
|
||||
_consolidationDaily.Enqueue(new DateTime(2013, 10, 7, 16, 0, 0));
|
||||
_consolidationDaily.Enqueue(new DateTime(2013, 10, 8, 16, 0, 0));
|
||||
_consolidationDaily.Enqueue(new DateTime(2013, 10, 9, 16, 0, 0));
|
||||
_consolidationDaily.Enqueue(new DateTime(2013, 10, 10, 16, 0, 0));
|
||||
|
||||
Consolidate("SPY", TimeSpan.FromHours(3), (TradeBar bar) =>
|
||||
{
|
||||
@@ -153,7 +154,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$130000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "25.24%"},
|
||||
{"OrderListHash", "faeb006f6e2015131523994ae78d4eb7"}
|
||||
{"OrderListHash", "bbda6d0a04ae0b87b2fa10e036296cbb"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,11 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public class ConsolidatorAnIdentityIndicatorRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private readonly Dictionary<DateTime, decimal> _expectedValues = new Dictionary<DateTime, decimal> {
|
||||
{ new DateTime(2013, 10, 8), 144.75578537200m },
|
||||
{ new DateTime(2013, 10, 9), 143.07840976800m },
|
||||
{ new DateTime(2013, 10, 10), 143.15622616200m },
|
||||
{ new DateTime(2013, 10, 11), 146.32940578400m }
|
||||
{ new DateTime(2013, 10, 7, 16, 0, 0), 144.75578537200m },
|
||||
{ new DateTime(2013, 10, 8, 16, 0, 0), 143.07840976800m },
|
||||
{ new DateTime(2013, 10, 9, 16, 0, 0), 143.15622616200m },
|
||||
{ new DateTime(2013, 10, 10, 16, 0, 0), 146.32940578400m },
|
||||
{ new DateTime(2013, 10, 11, 16, 0, 0), 147.24590998000m }
|
||||
};
|
||||
private Identity _identity;
|
||||
private int _assertCount;
|
||||
@@ -80,9 +81,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (_assertCount != 12)
|
||||
if (_assertCount != 15)
|
||||
{
|
||||
throw new RegressionTestException($"IUnexpected assertiong count: {_assertCount}");
|
||||
throw new RegressionTestException($"Unexpected asserting count: {_assertCount}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,23 +113,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
throw new RegressionTestException($"Unexpected data count, step: {_step}");
|
||||
}
|
||||
}
|
||||
else if (_step == 5)
|
||||
{
|
||||
if (!slice.ContainsKey(_fb)
|
||||
|| !slice.ContainsKey(_spy))
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected symbols found, step: {_step}");
|
||||
}
|
||||
if (slice.Count != 2)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected data count, step: {_step}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (_step != 5)
|
||||
// First selection is on the midnight of the 8th, start getting data from the 8th to the 11th
|
||||
if (_step != 4)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected step count: {_step}");
|
||||
}
|
||||
@@ -139,12 +128,12 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
foreach (var added in changes.AddedSecurities)
|
||||
{
|
||||
Log($"AddedSecurities {added}");
|
||||
Log($"{Time} AddedSecurities {added}");
|
||||
}
|
||||
|
||||
foreach (var removed in changes.RemovedSecurities)
|
||||
{
|
||||
Log($"RemovedSecurities {removed} {_step}");
|
||||
Log($"{Time} RemovedSecurities {removed} {_step}");
|
||||
// we are currently notifying the removal of AAPl twice,
|
||||
// when deselected and when finally removed (since it stayed pending)
|
||||
if (removed.Symbol == _appl && _step != 1 && _step != 2
|
||||
@@ -168,7 +157,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 52;
|
||||
public long DataPoints => 50;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -186,32 +175,32 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.54%"},
|
||||
{"Compounding Annual Return", "-32.671%"},
|
||||
{"Drawdown", "0.900%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Average Win", "0.68%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "70.501%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "99459.59"},
|
||||
{"Net Profit", "-0.540%"},
|
||||
{"Sharpe Ratio", "-3.436"},
|
||||
{"End Equity", "100684.53"},
|
||||
{"Net Profit", "0.685%"},
|
||||
{"Sharpe Ratio", "13.41"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "25.715%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Probabilistic Sharpe Ratio", "99.997%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.73"},
|
||||
{"Beta", "0.22"},
|
||||
{"Annual Standard Deviation", "0.086"},
|
||||
{"Annual Variance", "0.007"},
|
||||
{"Information Ratio", "-12.125"},
|
||||
{"Tracking Error", "0.187"},
|
||||
{"Treynor Ratio", "-1.338"},
|
||||
{"Total Fees", "$32.32"},
|
||||
{"Estimated Strategy Capacity", "$95000000.00"},
|
||||
{"Alpha", "0.235"},
|
||||
{"Beta", "0.15"},
|
||||
{"Annual Standard Deviation", "0.04"},
|
||||
{"Annual Variance", "0.002"},
|
||||
{"Information Ratio", "-7.587"},
|
||||
{"Tracking Error", "0.19"},
|
||||
{"Treynor Ratio", "3.546"},
|
||||
{"Total Fees", "$32.77"},
|
||||
{"Estimated Strategy Capacity", "$230000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "20.06%"},
|
||||
{"OrderListHash", "2271d307c23224ed7abc7fc852a51f24"}
|
||||
{"Portfolio Turnover", "20.15%"},
|
||||
{"OrderListHash", "d269ebced0796dde34f9eb775772e027"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public virtual long DataPoints => 9956;
|
||||
public virtual long DataPoints => 9951;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -34,6 +34,6 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 15820;
|
||||
public override long DataPoints => 15813;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1361;
|
||||
public long DataPoints => 1267;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 22137;
|
||||
public long DataPoints => 22136;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -168,10 +168,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.23"},
|
||||
{"Treynor Ratio", "0.351"},
|
||||
{"Total Fees", "$797.27"},
|
||||
{"Estimated Strategy Capacity", "$1200000000.00"},
|
||||
{"Estimated Strategy Capacity", "$1400000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "4.23%"},
|
||||
{"OrderListHash", "1291b6615d6301b487f409a5e0ea475d"}
|
||||
{"OrderListHash", "0422632afa17df1379757085f951de7b"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 4490;
|
||||
public override long DataPoints => 2298;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 4490;
|
||||
public override long DataPoints => 2298;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 463141;
|
||||
public long DataPoints => 7029;
|
||||
|
||||
/// </summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
using System;
|
||||
using QuantConnect.Brokerages;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Interfaces;
|
||||
|
||||
@@ -39,7 +40,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
SetBrokerageMessageHandler(new CustomBrokerageMessageHandler(this));
|
||||
}
|
||||
|
||||
public void OnData(TradeBars data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (Portfolio.HoldStock) return;
|
||||
Order("SPY", 100);
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "19.594%"},
|
||||
{"Compounding Annual Return", "21.133%"},
|
||||
{"Drawdown", "0.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -173,10 +173,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.19"},
|
||||
{"Treynor Ratio", "1.104"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$4100000000.00"},
|
||||
{"Estimated Strategy Capacity", "$5300000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "2.90%"},
|
||||
{"OrderListHash", "2fceb6050a91cafd083d19579e482b82"}
|
||||
{"OrderListHash", "4e8e27d7546eced2ef3512fcc840a634"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
|
||||
{
|
||||
var source = Path.Combine(Globals.DataFolder, "equity", "usa", config.Resolution.ToString().ToLower(), LeanData.GenerateZipFileName(config.Symbol, date, config.Resolution, config.TickType));
|
||||
return new SubscriptionDataSource(source, SubscriptionTransportMedium.LocalFile, FileFormat.Csv);
|
||||
return new SubscriptionDataSource(source);
|
||||
}
|
||||
|
||||
public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public class CustomDataUniverseRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private HashSet<Symbol> _currentUnderlyingSymbols = new();
|
||||
private readonly Queue<DateTime> _selectionTime = new (new[] {
|
||||
new DateTime(2014, 03, 24, 0, 0, 0),
|
||||
new DateTime(2014, 03, 25, 0, 0, 0),
|
||||
@@ -71,14 +72,20 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
var customData = slice.Get<CustomData>();
|
||||
var symbols = slice.Keys.Where(symbol => symbol.SecurityType != SecurityType.Base).ToList();
|
||||
foreach (var symbol in symbols)
|
||||
if (customData.Count > 0)
|
||||
{
|
||||
SetHoldings(symbol, 1m / symbols.Count);
|
||||
|
||||
if (!customData.Any(custom => custom.Key.Underlying == symbol))
|
||||
foreach (var symbol in _currentUnderlyingSymbols.OrderBy(x => x.ID.Symbol))
|
||||
{
|
||||
throw new RegressionTestException($"Custom data was not found for underlying symbol {symbol}");
|
||||
if (!Securities[symbol].HasData)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SetHoldings(symbol, 1m / _currentUnderlyingSymbols.Count);
|
||||
|
||||
if (!customData.Any(custom => custom.Key.Underlying == symbol))
|
||||
{
|
||||
throw new RegressionTestException($"Custom data was not found for underlying symbol {symbol}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +99,18 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSecuritiesChanged(SecurityChanges changes)
|
||||
{
|
||||
foreach(var security in changes.AddedSecurities.Where(sec => sec.Symbol.SecurityType != SecurityType.Base))
|
||||
{
|
||||
_currentUnderlyingSymbols.Add(security.Symbol);
|
||||
}
|
||||
foreach (var security in changes.RemovedSecurities.Where(sec => sec.Symbol.SecurityType != SecurityType.Base))
|
||||
{
|
||||
_currentUnderlyingSymbols.Remove(security.Symbol);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
@@ -105,7 +124,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 42633;
|
||||
public long DataPoints => 42622;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -122,33 +141,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "7"},
|
||||
{"Total Orders", "6"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "-65.130%"},
|
||||
{"Drawdown", "2.900%"},
|
||||
{"Compounding Annual Return", "-50.796%"},
|
||||
{"Drawdown", "1.900%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "97717.31"},
|
||||
{"Net Profit", "-2.283%"},
|
||||
{"Sharpe Ratio", "-4.298"},
|
||||
{"Sortino Ratio", "-4.067"},
|
||||
{"Probabilistic Sharpe Ratio", "5.388%"},
|
||||
{"End Equity", "98457.63"},
|
||||
{"Net Profit", "-1.542%"},
|
||||
{"Sharpe Ratio", "-4.343"},
|
||||
{"Sortino Ratio", "-3.19"},
|
||||
{"Probabilistic Sharpe Ratio", "4.159%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-1.062"},
|
||||
{"Beta", "1.336"},
|
||||
{"Annual Standard Deviation", "0.132"},
|
||||
{"Annual Variance", "0.018"},
|
||||
{"Information Ratio", "-12.03"},
|
||||
{"Tracking Error", "0.078"},
|
||||
{"Treynor Ratio", "-0.426"},
|
||||
{"Total Fees", "$13.87"},
|
||||
{"Estimated Strategy Capacity", "$430000000.00"},
|
||||
{"Lowest Capacity Asset", "NB R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "12.54%"},
|
||||
{"OrderListHash", "fae1a7c34d640dfa020330f24378bcf7"}
|
||||
{"Alpha", "-0.804"},
|
||||
{"Beta", "1.002"},
|
||||
{"Annual Standard Deviation", "0.1"},
|
||||
{"Annual Variance", "0.01"},
|
||||
{"Information Ratio", "-14.419"},
|
||||
{"Tracking Error", "0.056"},
|
||||
{"Treynor Ratio", "-0.433"},
|
||||
{"Total Fees", "$7.86"},
|
||||
{"Estimated Strategy Capacity", "$1200000000.00"},
|
||||
{"Lowest Capacity Asset", "GOOG T1AZ164W5VTX"},
|
||||
{"Portfolio Turnover", "7.58%"},
|
||||
{"OrderListHash", "fd3e6e9f401bc140d6b7cc8f1df8e46a"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public class CustomDataUniverseScheduledRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private List<Symbol> _currentUnderlyingSymbols = new();
|
||||
private readonly Queue<DateTime> _selectionTime = new(new[] {
|
||||
new DateTime(2014, 03, 25, 0, 0, 0),
|
||||
new DateTime(2014, 03, 27, 0, 0, 0),
|
||||
@@ -72,17 +73,21 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
var customData = slice.Get<CustomData>();
|
||||
var symbols = slice.Keys.Where(symbol => symbol.SecurityType != SecurityType.Base).ToList();
|
||||
foreach (var symbol in symbols)
|
||||
if (customData.Count > 0)
|
||||
{
|
||||
SetHoldings(symbol, 1m / symbols.Count);
|
||||
|
||||
if (!customData.Any(custom => custom.Key.Underlying == symbol))
|
||||
foreach (var symbol in _currentUnderlyingSymbols)
|
||||
{
|
||||
throw new RegressionTestException($"Custom data was not found for underlying symbol {symbol}");
|
||||
SetHoldings(symbol, 1m / _currentUnderlyingSymbols.Count);
|
||||
|
||||
if (!customData.Any(custom => custom.Key.Underlying == symbol))
|
||||
{
|
||||
throw new RegressionTestException($"Custom data was not found for underlying symbol {symbol}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// equity daily data arrives at 16 pm but custom data is set to arrive at midnight
|
||||
_currentUnderlyingSymbols = slice.Keys.Where(symbol => symbol.SecurityType != SecurityType.Base).ToList();
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
@@ -106,7 +111,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 21382;
|
||||
public long DataPoints => 21374;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -126,30 +131,30 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "7"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "-65.130%"},
|
||||
{"Drawdown", "2.900%"},
|
||||
{"Compounding Annual Return", "-65.964%"},
|
||||
{"Drawdown", "3.000%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "97717.31"},
|
||||
{"Net Profit", "-2.283%"},
|
||||
{"Sharpe Ratio", "-4.298"},
|
||||
{"Sortino Ratio", "-4.067"},
|
||||
{"Probabilistic Sharpe Ratio", "5.388%"},
|
||||
{"End Equity", "97665.47"},
|
||||
{"Net Profit", "-2.335%"},
|
||||
{"Sharpe Ratio", "-3.693"},
|
||||
{"Sortino Ratio", "-2.881"},
|
||||
{"Probabilistic Sharpe Ratio", "6.625%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-1.062"},
|
||||
{"Beta", "1.336"},
|
||||
{"Annual Standard Deviation", "0.132"},
|
||||
{"Annual Variance", "0.018"},
|
||||
{"Information Ratio", "-12.03"},
|
||||
{"Tracking Error", "0.078"},
|
||||
{"Treynor Ratio", "-0.426"},
|
||||
{"Total Fees", "$13.87"},
|
||||
{"Estimated Strategy Capacity", "$430000000.00"},
|
||||
{"Alpha", "-1.175"},
|
||||
{"Beta", "1.621"},
|
||||
{"Annual Standard Deviation", "0.156"},
|
||||
{"Annual Variance", "0.024"},
|
||||
{"Information Ratio", "-9.977"},
|
||||
{"Tracking Error", "0.095"},
|
||||
{"Treynor Ratio", "-0.355"},
|
||||
{"Total Fees", "$13.86"},
|
||||
{"Estimated Strategy Capacity", "$510000000.00"},
|
||||
{"Lowest Capacity Asset", "NB R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "12.54%"},
|
||||
{"OrderListHash", "fae1a7c34d640dfa020330f24378bcf7"}
|
||||
{"Portfolio Turnover", "12.76%"},
|
||||
{"OrderListHash", "4668d7bd05e2db15ff41d4e1aac621ab"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
AddSecurity(SecurityType.Equity, "SPY", Resolution.Hour);
|
||||
}
|
||||
|
||||
public void OnData(TradeBars data)
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (!Portfolio.Invested)
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
public long? ShortableQuantity(Symbol symbol, DateTime localTime)
|
||||
{
|
||||
if (localTime < new DateTime(2013, 10, 5))
|
||||
if (localTime < new DateTime(2013, 10, 4, 16, 0, 0))
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 17;
|
||||
public long DataPoints => 16;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -149,7 +149,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"OrderListHash", "65ce55aaad2f4a722858d84995fb7030"}
|
||||
{"OrderListHash", "22bda6f4ef08246dbab1a43f97de6b68"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,10 +121,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.087"},
|
||||
{"Treynor Ratio", "-0.653"},
|
||||
{"Total Fees", "$2.89"},
|
||||
{"Estimated Strategy Capacity", "$1600000000.00"},
|
||||
{"Estimated Strategy Capacity", "$2000000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.67%"},
|
||||
{"OrderListHash", "d0880701c833c9b8521d634b7e1edf4d"}
|
||||
{"OrderListHash", "6198706fef1ce2a60e8f16e7ab1485c1"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "240.939%"},
|
||||
{"Compounding Annual Return", "272.157%"},
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -121,10 +121,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.001"},
|
||||
{"Treynor Ratio", "1.922"},
|
||||
{"Total Fees", "$3.45"},
|
||||
{"Estimated Strategy Capacity", "$970000000.00"},
|
||||
{"Estimated Strategy Capacity", "$1300000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "20.19%"},
|
||||
{"OrderListHash", "39a84b9f15bb4e8ead0f0ecb59f28562"}
|
||||
{"OrderListHash", "ec0cf7d19c005d7d23452f96761ad014"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Securities;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
@@ -70,7 +69,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasHistory) throw new RegressionTestException($"No {symbol} data on the eve of {Time} {Time.DayOfWeek}");
|
||||
if (!hasHistory)
|
||||
{
|
||||
throw new RegressionTestException($"No {symbol} data on the eve of {Time} {Time.DayOfWeek}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 42660;
|
||||
public int AlgorithmHistoryDataPoints => 43089;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using QuantConnect.Interfaces;
|
||||
using QuantConnect.Data.Market;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm asserting behavior of consolidators while using daily strict end time
|
||||
/// </summary>
|
||||
public class DailyStrictEndTimeConsolidatorsRegressionAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
|
||||
{
|
||||
private int _consolidatorsDataResolutionCount;
|
||||
private int _consolidatorsDataTimeSpanCount;
|
||||
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2013, 10, 07);
|
||||
SetEndDate(2013, 10, 11);
|
||||
|
||||
AddEquity("SPY", Resolution.Minute);
|
||||
AddEquity("AAPL", Resolution.Daily, fillForward: false);
|
||||
|
||||
Consolidate("AAPL", Resolution.Daily, AssertResolutionBasedDailyBars);
|
||||
Consolidate("SPY", Resolution.Daily, AssertResolutionBasedDailyBars);
|
||||
|
||||
Consolidate("AAPL", QuantConnect.Time.OneDay, AssertTimeSpanBasedDailyBars);
|
||||
Consolidate("SPY", QuantConnect.Time.OneDay, AssertTimeSpanBasedDailyBars);
|
||||
}
|
||||
|
||||
protected virtual void AssertResolutionBasedDailyBars(TradeBar bar)
|
||||
{
|
||||
Debug($"AssertResolutionBasedDailyBars({Time}): {bar}");
|
||||
_consolidatorsDataResolutionCount++;
|
||||
AssertDailyBar(bar);
|
||||
}
|
||||
|
||||
protected virtual void AssertTimeSpanBasedDailyBars(TradeBar bar)
|
||||
{
|
||||
Debug($"AssertTimeSpanBasedDailyBars({Time}): {bar}");
|
||||
_consolidatorsDataTimeSpanCount++;
|
||||
if (bar.Symbol == "AAPL")
|
||||
{
|
||||
// underlying is daily, passes through, it will be daily strict end times, even if created as a timespan
|
||||
AssertDailyBar(bar);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bar.EndTime.Hour != 0 || bar.Period != QuantConnect.Time.OneDay)
|
||||
{
|
||||
throw new RegressionTestException($"{Time}: Unexpected daily time span based bar span {bar.EndTime}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AssertDailyBar(TradeBar bar)
|
||||
{
|
||||
if (Settings.DailyPreciseEndTime)
|
||||
{
|
||||
if (bar.EndTime.Hour != 16 || bar.Period != TimeSpan.FromHours(6.5))
|
||||
{
|
||||
throw new RegressionTestException($"{Time}: Unexpected daily resolution based bar span {bar.EndTime}!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bar.EndTime.Hour != 0 || bar.Period != QuantConnect.Time.OneDay)
|
||||
{
|
||||
throw new RegressionTestException($"{Time}: Unexpected daily resolution based bar span {bar.EndTime}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEndOfAlgorithm()
|
||||
{
|
||||
if (_consolidatorsDataTimeSpanCount != 9)
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected consolidator time span data count {_consolidatorsDataTimeSpanCount}!");
|
||||
}
|
||||
if (_consolidatorsDataResolutionCount != (9 + (Settings.DailyPreciseEndTime ? 1 : 0)))
|
||||
{
|
||||
throw new RegressionTestException($"Unexpected consolidator resolution data count {_consolidatorsDataResolutionCount}!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
|
||||
/// </summary>
|
||||
public bool CanRunLocally { get; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate which languages this algorithm is written in.
|
||||
/// </summary>
|
||||
public List<Language> Languages { get; } = new() { Language.CSharp };
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 3948;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
/// </summary>
|
||||
public AlgorithmStatus AlgorithmStatus => AlgorithmStatus.Completed;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "0"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "0%"},
|
||||
{"Drawdown", "0%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100000"},
|
||||
{"Net Profit", "0%"},
|
||||
{"Sharpe Ratio", "0"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "0%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0"},
|
||||
{"Beta", "0"},
|
||||
{"Annual Standard Deviation", "0"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-8.91"},
|
||||
{"Tracking Error", "0.223"},
|
||||
{"Treynor Ratio", "0"},
|
||||
{"Total Fees", "$0.00"},
|
||||
{"Estimated Strategy Capacity", "$0"},
|
||||
{"Lowest Capacity Asset", ""},
|
||||
{"Portfolio Turnover", "0%"},
|
||||
{"OrderListHash", "d41d8cd98f00b204e9800998ecf8427e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
||||
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Regression algorithm asserting behavior of consolidators while daily strict end time disabled
|
||||
/// </summary>
|
||||
public class DailyStrictEndTimeDisabledConsolidatorsRegressionAlgorithm : DailyStrictEndTimeConsolidatorsRegressionAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
Settings.DailyPreciseEndTime = false;
|
||||
base.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Consolidators;
|
||||
using QuantConnect.Data.Market;
|
||||
|
||||
@@ -123,8 +124,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="bars">TradeBars IDictionary object with your stock data</param>
|
||||
public void OnData(TradeBars bars)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
// we need to declare this method
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 5280;
|
||||
public long DataPoints => 2862;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
var equity = AddEquity("GOOG");
|
||||
|
||||
_optionSymbol = OptionChainProvider.GetOptionContractList(equity.Symbol, Time)
|
||||
.OrderBy(symbol => symbol.ID.StrikePrice)
|
||||
.ThenByDescending(symbol => symbol.ID.Date)
|
||||
_optionSymbol = OptionChain(equity.Symbol)
|
||||
.OrderBy(x => x.ID.StrikePrice)
|
||||
.ThenByDescending(x => x.ID.Date)
|
||||
.First(optionContract => optionContract.ID.OptionRight == OptionRight.Call);
|
||||
var option = AddOptionContract(_optionSymbol);
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 1806;
|
||||
public override long DataPoints => 1679;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -38,30 +38,30 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "7.78%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "38.033%"},
|
||||
{"Compounding Annual Return", "38.564%"},
|
||||
{"Drawdown", "0.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "107779.1"},
|
||||
{"Net Profit", "7.779%"},
|
||||
{"Sharpe Ratio", "3.107"},
|
||||
{"Sharpe Ratio", "3.132"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "99.459%"},
|
||||
{"Probabilistic Sharpe Ratio", "99.474%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.143"},
|
||||
{"Alpha", "0.145"},
|
||||
{"Beta", "0.271"},
|
||||
{"Annual Standard Deviation", "0.08"},
|
||||
{"Annual Standard Deviation", "0.081"},
|
||||
{"Annual Variance", "0.006"},
|
||||
{"Information Ratio", "-1.446"},
|
||||
{"Tracking Error", "0.098"},
|
||||
{"Treynor Ratio", "0.918"},
|
||||
{"Information Ratio", "-1.459"},
|
||||
{"Tracking Error", "0.099"},
|
||||
{"Treynor Ratio", "0.932"},
|
||||
{"Total Fees", "$2.15"},
|
||||
{"Estimated Strategy Capacity", "$60000000000.00"},
|
||||
{"Estimated Strategy Capacity", "$150000000000.00"},
|
||||
{"Lowest Capacity Asset", "ES VMKLFZIH2MTD"},
|
||||
{"Portfolio Turnover", "1.96%"},
|
||||
{"OrderListHash", "7ba852ca7413743ca2be8310611f14d1"}
|
||||
{"Portfolio Turnover", "1.98%"},
|
||||
{"OrderListHash", "b337ac27f46a6298dd4e9f0f04b49427"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
|
||||
if (_addOption)
|
||||
{
|
||||
var contracts = OptionChainProvider.GetOptionContractList(_spx, Time);
|
||||
contracts = contracts.Where(x =>
|
||||
x.ID.OptionRight == OptionRight.Put &&
|
||||
x.ID.Date.Date == new DateTime(2021, 1, 15));
|
||||
var contracts = OptionChain(_spx).Where(x => x.ID.OptionRight == OptionRight.Put && x.ID.Date.Date == new DateTime(2021, 1, 15));
|
||||
|
||||
var option = AddIndexOptionContract(contracts.First(), Resolution.Minute);
|
||||
_optionExpiry = option.Expiry;
|
||||
@@ -128,7 +125,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
/// </summary>
|
||||
public int AlgorithmHistoryDataPoints => 0;
|
||||
public int AlgorithmHistoryDataPoints => 1;
|
||||
|
||||
/// <summary>
|
||||
/// Final status of the algorithm
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Orders;
|
||||
using QuantConnect.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
@@ -43,7 +41,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
SetStartDate(2007, 05, 16); //Set Start Date
|
||||
SetStartDate(2007, 05, 15); //Set Start Date
|
||||
SetEndDate(2007, 05, 25); //Set End Date
|
||||
SetCash(100000); //Set Strategy Cash
|
||||
// Find more symbols here: http://quantconnect.com/data
|
||||
@@ -155,7 +153,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 79;
|
||||
public long DataPoints => 86;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -175,30 +173,30 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "2"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-5.58%"},
|
||||
{"Compounding Annual Return", "-87.694%"},
|
||||
{"Compounding Annual Return", "-85.973%"},
|
||||
{"Drawdown", "5.600%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "94421.6"},
|
||||
{"Net Profit", "-5.578%"},
|
||||
{"Sharpe Ratio", "-5.122"},
|
||||
{"Sortino Ratio", "-6.562"},
|
||||
{"Probabilistic Sharpe Ratio", "0.008%"},
|
||||
{"Sharpe Ratio", "-5.495"},
|
||||
{"Sortino Ratio", "-10.306"},
|
||||
{"Probabilistic Sharpe Ratio", "0.000%"},
|
||||
{"Loss Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.739"},
|
||||
{"Beta", "-0.877"},
|
||||
{"Annual Standard Deviation", "0.142"},
|
||||
{"Annual Variance", "0.02"},
|
||||
{"Information Ratio", "-3.844"},
|
||||
{"Tracking Error", "0.186"},
|
||||
{"Treynor Ratio", "0.83"},
|
||||
{"Alpha", "-0.585"},
|
||||
{"Beta", "-1.085"},
|
||||
{"Annual Standard Deviation", "0.15"},
|
||||
{"Annual Variance", "0.023"},
|
||||
{"Information Ratio", "-5.081"},
|
||||
{"Tracking Error", "0.206"},
|
||||
{"Treynor Ratio", "0.76"},
|
||||
{"Total Fees", "$36.70"},
|
||||
{"Estimated Strategy Capacity", "$65000.00"},
|
||||
{"Estimated Strategy Capacity", "$110000.00"},
|
||||
{"Lowest Capacity Asset", "AAA SEVKGI6HF885"},
|
||||
{"Portfolio Turnover", "20.16%"},
|
||||
{"OrderListHash", "e956792307b884e3c46e95b29c1563f6"}
|
||||
{"Portfolio Turnover", "18.33%"},
|
||||
{"OrderListHash", "1450ea23a3a1ef4ee2398ec757c39223"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 13033;
|
||||
public override long DataPoints => 12251;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -45,8 +45,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Start Equity", "10000000"},
|
||||
{"End Equity", "9988860.24"},
|
||||
{"Net Profit", "-0.111%"},
|
||||
{"Sharpe Ratio", "-10.266"},
|
||||
{"Sortino Ratio", "-0.941"},
|
||||
{"Sharpe Ratio", "-10.243"},
|
||||
{"Sortino Ratio", "-0.942"},
|
||||
{"Probabilistic Sharpe Ratio", "0.000%"},
|
||||
{"Loss Rate", "80%"},
|
||||
{"Win Rate", "20%"},
|
||||
@@ -55,14 +55,14 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Beta", "-0.001"},
|
||||
{"Annual Standard Deviation", "0.001"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-1.073"},
|
||||
{"Information Ratio", "-1.076"},
|
||||
{"Tracking Error", "0.107"},
|
||||
{"Treynor Ratio", "14.418"},
|
||||
{"Treynor Ratio", "14.429"},
|
||||
{"Total Fees", "$19.76"},
|
||||
{"Estimated Strategy Capacity", "$2300000.00"},
|
||||
{"Estimated Strategy Capacity", "$5900000.00"},
|
||||
{"Lowest Capacity Asset", "DC V5E8PHPRCHJ8|DC V5E8P9SH0U0X"},
|
||||
{"Portfolio Turnover", "0.00%"},
|
||||
{"OrderListHash", "9521f1fae55a3ffab939592b9ae04855"}
|
||||
{"OrderListHash", "069941549b3386b9f33320aef06537bc"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,11 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Indicators;
|
||||
using QuantConnect.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
@@ -86,7 +85,13 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
// only once per day
|
||||
if (_previous.Date == Time.Date) return;
|
||||
|
||||
Plot("Ribbon", "Price", slice[_spy].Price);
|
||||
var data = slice[_spy];
|
||||
if (data == null)
|
||||
{
|
||||
// at midnight we can get dividend call, not price data
|
||||
return;
|
||||
}
|
||||
Plot("Ribbon", "Price", data.Price);
|
||||
Plot("Ribbon", _ribbon);
|
||||
|
||||
|
||||
@@ -165,7 +170,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 12074;
|
||||
public long DataPoints => 12073;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -185,7 +190,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "7"},
|
||||
{"Average Win", "19.17%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "16.729%"},
|
||||
{"Compounding Annual Return", "16.731%"},
|
||||
{"Drawdown", "12.400%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -205,10 +210,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.105"},
|
||||
{"Treynor Ratio", "0.221"},
|
||||
{"Total Fees", "$49.40"},
|
||||
{"Estimated Strategy Capacity", "$740000000.00"},
|
||||
{"Estimated Strategy Capacity", "$1100000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.32%"},
|
||||
{"OrderListHash", "62d1401e91275f777d0865a13906e7c8"}
|
||||
{"OrderListHash", "1ea790ca8afdcad02b98c70e89652562"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.015"},
|
||||
{"Alpha", "-0.016"},
|
||||
{"Beta", "0.521"},
|
||||
{"Annual Standard Deviation", "0.083"},
|
||||
{"Annual Variance", "0.007"},
|
||||
@@ -144,10 +144,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.076"},
|
||||
{"Treynor Ratio", "-0.01"},
|
||||
{"Total Fees", "$2.56"},
|
||||
{"Estimated Strategy Capacity", "$24000000.00"},
|
||||
{"Estimated Strategy Capacity", "$36000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "0.02%"},
|
||||
{"OrderListHash", "efe1c97f2ebdd14ee72b57b1b44a8f7a"}
|
||||
{"OrderListHash", "8068ff5f4917787e48d90fda94de340c"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 5282;
|
||||
public long DataPoints => 5269;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -218,33 +218,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "6441"},
|
||||
{"Total Orders", "6415"},
|
||||
{"Average Win", "0.07%"},
|
||||
{"Average Loss", "-0.07%"},
|
||||
{"Compounding Annual Return", "15.505%"},
|
||||
{"Compounding Annual Return", "15.655%"},
|
||||
{"Drawdown", "10.500%"},
|
||||
{"Expectancy", "0.070"},
|
||||
{"Expectancy", "0.071"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "115414.22"},
|
||||
{"Net Profit", "15.414%"},
|
||||
{"Sharpe Ratio", "0.846"},
|
||||
{"Sortino Ratio", "0.789"},
|
||||
{"Probabilistic Sharpe Ratio", "48.709%"},
|
||||
{"End Equity", "115562.68"},
|
||||
{"Net Profit", "15.563%"},
|
||||
{"Sharpe Ratio", "0.844"},
|
||||
{"Sortino Ratio", "0.788"},
|
||||
{"Probabilistic Sharpe Ratio", "48.632%"},
|
||||
{"Loss Rate", "46%"},
|
||||
{"Win Rate", "54%"},
|
||||
{"Profit-Loss Ratio", "0.98"},
|
||||
{"Alpha", "0.008"},
|
||||
{"Beta", "0.987"},
|
||||
{"Beta", "0.986"},
|
||||
{"Annual Standard Deviation", "0.11"},
|
||||
{"Annual Variance", "0.012"},
|
||||
{"Information Ratio", "0.161"},
|
||||
{"Information Ratio", "0.155"},
|
||||
{"Tracking Error", "0.041"},
|
||||
{"Treynor Ratio", "0.094"},
|
||||
{"Total Fees", "$7489.03"},
|
||||
{"Estimated Strategy Capacity", "$220000.00"},
|
||||
{"Total Fees", "$7460.54"},
|
||||
{"Estimated Strategy Capacity", "$450000.00"},
|
||||
{"Lowest Capacity Asset", "BNO UN3IMQ2JU1YD"},
|
||||
{"Portfolio Turnover", "136.17%"},
|
||||
{"OrderListHash", "58d2d8c130dd4279876077eaa00056a7"}
|
||||
{"Portfolio Turnover", "135.63%"},
|
||||
{"OrderListHash", "29c715831bd675f04226f9fd8855a52e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 5291;
|
||||
public long DataPoints => 5278;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -178,31 +178,31 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{
|
||||
{"Total Orders", "5059"},
|
||||
{"Average Win", "0.08%"},
|
||||
{"Average Loss", "-0.08%"},
|
||||
{"Compounding Annual Return", "15.960%"},
|
||||
{"Drawdown", "10.400%"},
|
||||
{"Expectancy", "0.079"},
|
||||
{"Average Loss", "-0.07%"},
|
||||
{"Compounding Annual Return", "16.423%"},
|
||||
{"Drawdown", "10.500%"},
|
||||
{"Expectancy", "0.081"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "115960.04"},
|
||||
{"Net Profit", "15.960%"},
|
||||
{"Sharpe Ratio", "0.865"},
|
||||
{"Sortino Ratio", "0.809"},
|
||||
{"Probabilistic Sharpe Ratio", "49.486%"},
|
||||
{"Loss Rate", "45%"},
|
||||
{"Win Rate", "55%"},
|
||||
{"Profit-Loss Ratio", "0.96"},
|
||||
{"Alpha", "0.015"},
|
||||
{"Beta", "0.985"},
|
||||
{"End Equity", "116400.57"},
|
||||
{"Net Profit", "16.401%"},
|
||||
{"Sharpe Ratio", "0.891"},
|
||||
{"Sortino Ratio", "0.831"},
|
||||
{"Probabilistic Sharpe Ratio", "50.543%"},
|
||||
{"Loss Rate", "47%"},
|
||||
{"Win Rate", "53%"},
|
||||
{"Profit-Loss Ratio", "1.03"},
|
||||
{"Alpha", "0.018"},
|
||||
{"Beta", "0.984"},
|
||||
{"Annual Standard Deviation", "0.11"},
|
||||
{"Annual Variance", "0.012"},
|
||||
{"Information Ratio", "0.348"},
|
||||
{"Information Ratio", "0.416"},
|
||||
{"Tracking Error", "0.041"},
|
||||
{"Treynor Ratio", "0.096"},
|
||||
{"Total Fees", "$5870.38"},
|
||||
{"Estimated Strategy Capacity", "$320000.00"},
|
||||
{"Treynor Ratio", "0.099"},
|
||||
{"Total Fees", "$5848.25"},
|
||||
{"Estimated Strategy Capacity", "$510000.00"},
|
||||
{"Lowest Capacity Asset", "BNO UN3IMQ2JU1YD"},
|
||||
{"Portfolio Turnover", "107.21%"},
|
||||
{"OrderListHash", "a7da6309cc1fb69e6f197ec9eb152a67"}
|
||||
{"Portfolio Turnover", "106.75%"},
|
||||
{"OrderListHash", "5499e61404d453274cee78904d4c0e92"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 66;
|
||||
public long DataPoints => 65;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -118,30 +118,30 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "28.411%"},
|
||||
{"Drawdown", "0.100%"},
|
||||
{"Compounding Annual Return", "-4.847%"},
|
||||
{"Drawdown", "0.300%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "100618.5"},
|
||||
{"Net Profit", "0.618%"},
|
||||
{"Sharpe Ratio", "8.473"},
|
||||
{"Sortino Ratio", "0"},
|
||||
{"Probabilistic Sharpe Ratio", "99.065%"},
|
||||
{"End Equity", "99882.1"},
|
||||
{"Net Profit", "-0.118%"},
|
||||
{"Sharpe Ratio", "-2.151"},
|
||||
{"Sortino Ratio", "-1.743"},
|
||||
{"Probabilistic Sharpe Ratio", "30.061%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.114"},
|
||||
{"Beta", "0.143"},
|
||||
{"Annual Standard Deviation", "0.022"},
|
||||
{"Alpha", "0.008"},
|
||||
{"Beta", "-0.104"},
|
||||
{"Annual Standard Deviation", "0.02"},
|
||||
{"Annual Variance", "0"},
|
||||
{"Information Ratio", "-3.746"},
|
||||
{"Tracking Error", "0.084"},
|
||||
{"Treynor Ratio", "1.296"},
|
||||
{"Information Ratio", "-5.063"},
|
||||
{"Tracking Error", "0.108"},
|
||||
{"Treynor Ratio", "0.423"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$1000000000.00"},
|
||||
{"Estimated Strategy Capacity", "$1600000000.00"},
|
||||
{"Lowest Capacity Asset", "GOOG T1AZ164W5VTX"},
|
||||
{"Portfolio Turnover", "0.75%"},
|
||||
{"OrderListHash", "37cbc41970d27793ec2d1c401529cf05"}
|
||||
{"Portfolio Turnover", "0.83%"},
|
||||
{"OrderListHash", "ffab48ec7d6bf58aae9377c4bdf3be02"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public long DataPoints => 1072;
|
||||
public long DataPoints => 1068;
|
||||
|
||||
/// <summary>
|
||||
/// Data Points count of the algorithm history
|
||||
@@ -80,33 +80,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
|
||||
{
|
||||
{"Total Orders", "9"},
|
||||
{"Average Win", "0.01%"},
|
||||
{"Total Orders", "8"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "250.805%"},
|
||||
{"Compounding Annual Return", "64.993%"},
|
||||
{"Drawdown", "0.900%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "102436.17"},
|
||||
{"Net Profit", "2.436%"},
|
||||
{"Sharpe Ratio", "3.837"},
|
||||
{"Sortino Ratio", "10.614"},
|
||||
{"Probabilistic Sharpe Ratio", "63.620%"},
|
||||
{"End Equity", "100918.77"},
|
||||
{"Net Profit", "0.919%"},
|
||||
{"Sharpe Ratio", "4.7"},
|
||||
{"Sortino Ratio", "14.706"},
|
||||
{"Probabilistic Sharpe Ratio", "67.449%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "100%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "0.5"},
|
||||
{"Beta", "-0.357"},
|
||||
{"Annual Standard Deviation", "0.091"},
|
||||
{"Annual Variance", "0.008"},
|
||||
{"Information Ratio", "-0.581"},
|
||||
{"Tracking Error", "0.12"},
|
||||
{"Treynor Ratio", "-0.981"},
|
||||
{"Total Fees", "$9.05"},
|
||||
{"Estimated Strategy Capacity", "$400000000.00"},
|
||||
{"Alpha", "0.618"},
|
||||
{"Beta", "-0.348"},
|
||||
{"Annual Standard Deviation", "0.1"},
|
||||
{"Annual Variance", "0.01"},
|
||||
{"Information Ratio", "0.41"},
|
||||
{"Tracking Error", "0.127"},
|
||||
{"Treynor Ratio", "-1.358"},
|
||||
{"Total Fees", "$7.02"},
|
||||
{"Estimated Strategy Capacity", "$440000000.00"},
|
||||
{"Lowest Capacity Asset", "GOOCV VP83T1ZUHROL"},
|
||||
{"Portfolio Turnover", "14.29%"},
|
||||
{"OrderListHash", "a11cb12dabe993c7989036e299f3f028"}
|
||||
{"Portfolio Turnover", "13.71%"},
|
||||
{"OrderListHash", "21aeef113b8d043e018967d7c1916e5f"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Indicators;
|
||||
|
||||
@@ -82,8 +83,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">TradeBars IDictionary object with your stock data</param>
|
||||
public void OnData(TradeBars data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -130,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
}
|
||||
catch (RegressionTestException ex)
|
||||
{
|
||||
Error("OnTradeBar: " + ex.Message + "\r\n\r\n" + ex.StackTrace);
|
||||
Error("OnData: " + ex.Message + "\r\n\r\n" + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,33 +45,33 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> ExpectedStatistics => new()
|
||||
{
|
||||
{"Total Orders", "31"},
|
||||
{"Average Win", "0.44%"},
|
||||
{"Total Orders", "38"},
|
||||
{"Average Win", "0.36%"},
|
||||
{"Average Loss", "-0.17%"},
|
||||
{"Compounding Annual Return", "61.576%"},
|
||||
{"Compounding Annual Return", "68.881%"},
|
||||
{"Drawdown", "0.900%"},
|
||||
{"Expectancy", "1.747"},
|
||||
{"Expectancy", "1.552"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "104022.40"},
|
||||
{"Net Profit", "4.022%"},
|
||||
{"Sharpe Ratio", "7.552"},
|
||||
{"Sortino Ratio", "14.355"},
|
||||
{"Probabilistic Sharpe Ratio", "97.071%"},
|
||||
{"Loss Rate", "23%"},
|
||||
{"Win Rate", "77%"},
|
||||
{"Profit-Loss Ratio", "2.57"},
|
||||
{"Alpha", "0.323"},
|
||||
{"Beta", "0.419"},
|
||||
{"Annual Standard Deviation", "0.053"},
|
||||
{"End Equity", "104401.15"},
|
||||
{"Net Profit", "4.401%"},
|
||||
{"Sharpe Ratio", "8.193"},
|
||||
{"Sortino Ratio", "16.18"},
|
||||
{"Probabilistic Sharpe Ratio", "97.920%"},
|
||||
{"Loss Rate", "19%"},
|
||||
{"Win Rate", "81%"},
|
||||
{"Profit-Loss Ratio", "2.14"},
|
||||
{"Alpha", "0.371"},
|
||||
{"Beta", "0.406"},
|
||||
{"Annual Standard Deviation", "0.055"},
|
||||
{"Annual Variance", "0.003"},
|
||||
{"Information Ratio", "3.736"},
|
||||
{"Tracking Error", "0.057"},
|
||||
{"Treynor Ratio", "0.962"},
|
||||
{"Total Fees", "$73.33"},
|
||||
{"Information Ratio", "4.394"},
|
||||
{"Tracking Error", "0.059"},
|
||||
{"Treynor Ratio", "1.106"},
|
||||
{"Total Fees", "$80.35"},
|
||||
{"Estimated Strategy Capacity", "$9600000.00"},
|
||||
{"Lowest Capacity Asset", "AIG R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "16.84%"},
|
||||
{"OrderListHash", "757d4ceeedcb454aa0d629eed8e8af18"}
|
||||
{"Portfolio Turnover", "17.26%"},
|
||||
{"OrderListHash", "90302b5e51106c74b6efdc0ca42fcb55"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using QuantConnect.Data;
|
||||
using QuantConnect.Data.Market;
|
||||
using QuantConnect.Data.UniverseSelection;
|
||||
using QuantConnect.Indicators;
|
||||
@@ -98,8 +99,8 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
/// </summary>
|
||||
/// <param name="data">TradeBars dictionary object keyed by symbol containing the stock data</param>
|
||||
public void OnData(TradeBars data)
|
||||
/// <param name="slice">Slice object keyed by symbol containing the stock data</param>
|
||||
public override void OnData(Slice slice)
|
||||
{
|
||||
if (_changes == SecurityChanges.None) return;
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "6"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "-0.02%"},
|
||||
{"Compounding Annual Return", "-72.241%"},
|
||||
{"Compounding Annual Return", "-74.669%"},
|
||||
{"Drawdown", "2.900%"},
|
||||
{"Expectancy", "-1"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -153,10 +153,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.445"},
|
||||
{"Treynor Ratio", "0.672"},
|
||||
{"Total Fees", "$19.23"},
|
||||
{"Estimated Strategy Capacity", "$540000000.00"},
|
||||
{"Estimated Strategy Capacity", "$1200000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "100.02%"},
|
||||
{"OrderListHash", "2f1cb4d9ca245eeab8ff432e85b4f221"}
|
||||
{"OrderListHash", "094cbf077486ed2ec2558a2255a385c2"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "6"},
|
||||
{"Average Win", "0.94%"},
|
||||
{"Average Loss", "-0.98%"},
|
||||
{"Compounding Annual Return", "-47.257%"},
|
||||
{"Compounding Annual Return", "-49.613%"},
|
||||
{"Drawdown", "1.200%"},
|
||||
{"Expectancy", "-0.021"},
|
||||
{"Start Equity", "100000"},
|
||||
@@ -145,10 +145,10 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Tracking Error", "0.137"},
|
||||
{"Treynor Ratio", "-0.686"},
|
||||
{"Total Fees", "$17.19"},
|
||||
{"Estimated Strategy Capacity", "$640000000.00"},
|
||||
{"Estimated Strategy Capacity", "$1600000000.00"},
|
||||
{"Lowest Capacity Asset", "SPY R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "100.44%"},
|
||||
{"OrderListHash", "32a8e55f26c040495123e0bc93b35ba7"}
|
||||
{"OrderListHash", "54c868bc2bc19b62922c1fec8c1d327e"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
/// <summary>
|
||||
/// Data Points count of all timeslices of algorithm
|
||||
/// </summary>
|
||||
public override long DataPoints => 51;
|
||||
public override long DataPoints => 50;
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
|
||||
@@ -38,30 +38,30 @@ namespace QuantConnect.Algorithm.CSharp
|
||||
{"Total Orders", "1"},
|
||||
{"Average Win", "0%"},
|
||||
{"Average Loss", "0%"},
|
||||
{"Compounding Annual Return", "-58.177%"},
|
||||
{"Compounding Annual Return", "-44.829%"},
|
||||
{"Drawdown", "2.200%"},
|
||||
{"Expectancy", "0"},
|
||||
{"Start Equity", "100000"},
|
||||
{"End Equity", "98342.10"},
|
||||
{"Net Profit", "-1.658%"},
|
||||
{"Sharpe Ratio", "-3.992"},
|
||||
{"Sortino Ratio", "-4.263"},
|
||||
{"Probabilistic Sharpe Ratio", "11.588%"},
|
||||
{"End Equity", "98919.60"},
|
||||
{"Net Profit", "-1.080%"},
|
||||
{"Sharpe Ratio", "-2.862"},
|
||||
{"Sortino Ratio", "-3.355"},
|
||||
{"Probabilistic Sharpe Ratio", "23.493%"},
|
||||
{"Loss Rate", "0%"},
|
||||
{"Win Rate", "0%"},
|
||||
{"Profit-Loss Ratio", "0"},
|
||||
{"Alpha", "-0.447"},
|
||||
{"Beta", "-0.255"},
|
||||
{"Annual Standard Deviation", "0.118"},
|
||||
{"Annual Variance", "0.014"},
|
||||
{"Information Ratio", "-4.413"},
|
||||
{"Tracking Error", "0.129"},
|
||||
{"Treynor Ratio", "1.854"},
|
||||
{"Alpha", "-0.395"},
|
||||
{"Beta", "0.265"},
|
||||
{"Annual Standard Deviation", "0.129"},
|
||||
{"Annual Variance", "0.017"},
|
||||
{"Information Ratio", "-3.531"},
|
||||
{"Tracking Error", "0.132"},
|
||||
{"Treynor Ratio", "-1.392"},
|
||||
{"Total Fees", "$1.00"},
|
||||
{"Estimated Strategy Capacity", "$280000000.00"},
|
||||
{"Estimated Strategy Capacity", "$370000000.00"},
|
||||
{"Lowest Capacity Asset", "AAPL R735QTJ8XC9X"},
|
||||
{"Portfolio Turnover", "14.24%"},
|
||||
{"OrderListHash", "459f761c23b79553705da7bed8807937"}
|
||||
{"Portfolio Turnover", "14.20%"},
|
||||
{"OrderListHash", "6ea9aed8840dc08f9290028271750dcf"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user