Compare commits

...

38 Commits
11142 ... 11368

Author SHA1 Message Date
Martin-Molinero
d94a1d09a4 Remove unrequired references 2021-04-12 16:05:01 -03:00
Martin-Molinero
2c843cae9e Fix rebase
- Fix ambiguous Index
- Remove StrategyCapacity.cs
- Update System.Threading.Tasks.Extensionsy
2021-04-12 15:09:34 -03:00
Stefano Raggi
039fdf7e4a Upgrade IBAutomater to v1.0.51
ignored, and an empty message aborts the commit.
2021-04-12 15:09:33 -03:00
Martin Molinero
2c63546c37 Remove FXCM 2021-04-12 15:09:33 -03:00
Martin Molinero
58682e1bbd Fix ambiguous errors. Add IBAutomator net5 2021-04-12 15:09:33 -03:00
Gerardo Salazar
d11a375fdb Update projects to use .NET 5.0, the successor to .NET Core 2021-04-12 15:09:33 -03:00
Martin-Molinero
6ab91a13e1 Add note for TimeZoneOffsetProvider StartTime (#5469) 2021-04-08 18:00:17 -03:00
Colton Sellers
beaa705646 Loader Support Full Algorithm Name (#5467)
* Apply fix

* Address possible mismatching subset of name
2021-04-08 17:59:08 -03:00
Colton Sellers
4c830c8235 Fix Breaking Unit Test (#5466)
* Adjust Timeout; Reduce time advance

* Move logging of EndTime above asserts
2021-04-07 21:09:56 -03:00
Colton Sellers
395c1123da Remove Obsolete QCAlgorithm.OnEndOfDay() (#5441)
* Remove and replace OnEndOfDay() ref

* Restore functionality of obsolete EOD, waiting for deprecation in August 2021

* Cleanup

* Adjustments to only post message when using obsolete EOD

* nit, extra space

* Address review

* Adjust test to reflect new behaviour

* Move GetPythonArgCount to an extension method

* Add unit test

* nit accidental import

* Refactor broken test

* Use Py.GIL() state for extension
2021-04-07 13:39:49 -03:00
Martin-Molinero
8e50645640 Update System.Threading.Tasks.Extensions (#5340) 2021-04-07 12:36:22 -03:00
Colton Sellers
68ca504d3a Apply fixes (#5464) 2021-04-07 11:46:31 -03:00
Jasper van Merle
12df1c9a31 Fix drawdown plotting failing on single equity point (#5461) 2021-04-06 16:30:23 -07:00
Aaron Janeiro Stone
4de25b6cd4 _lastLow and _lastHigh are given resets under DeM's Reset method (#5449) 2021-04-06 10:15:16 -03:00
dependabot[bot]
cdef9e709a Bump System.Net.Security from 4.3.0 to 4.3.1 in /Tests (#5453)
Bumps System.Net.Security from 4.3.0 to 4.3.1.

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-06 10:11:43 -03:00
Colton Sellers
3579fecc58 Live Consolidator Bug Fix (#5429)
* Set _lastEmit before emitting, otherwise _workingBar is always null

* Aggregate bars if the data endTime is past lastEmit

* Add unit test

* Address Review

* Clean up unit tests

* Refactor solution to set consistent _lastEmit behaviour

* Add another unit test

* Make fixture non-parallelizable

* Undo last change, and adjust breaking test directly
2021-04-05 17:05:53 -07:00
Stefano Raggi
3a390cfa9f Add IB brokerage message event filtering (#5452) 2021-04-05 17:17:14 -03:00
Stefano Raggi
58dae061e7 Add REST API exception logging in Tradier brokerage (#5454) 2021-04-05 17:14:52 -03:00
Martin-Molinero
3f2479393f Update clr-loader and remove workaround (#5451) 2021-04-05 14:25:19 -03:00
Jasper van Merle
4849588c3b Fix flipped operator in random data generator (#5446) 2021-04-05 11:07:51 -03:00
Martin-Molinero
3d84c76abb Add missing timedelta import in python custom data regression algorithms. Relate to https://github.com/QuantConnect/Lean/pull/5426/files (#5450) 2021-04-05 10:26:51 -03:00
Colton Sellers
1c3d849ad5 Fix Warnings V2 (#5436)
* Reconcile duplicated code

* Add License header

* CS0219 Fixes: Value assigned, but never used

* CA1507: Use nameof in place of string literals

* CS0108 : Hides Inherited Member; Use new keyword to overwrite formally

* CS0114: Hides inherited member; use override keyword

* CS0168: Variable is declared but never used

* Tests CS1062; using obsolete implicit Symbol -> String; fix via .ToString()

* CS0472: Non Nullable Obj getting Null Checked

* CS0067 Member not used; ignore all cases for future use

* CS00162 : Unreachable code; either removed or ignored for debugging and test cases

* CS0169 Remove non-used fields; ignore those that may be used in future

* CS0414; Field is assigned but never used.

* CS0618; Obsolete properties and members; Only fixes simple ones, rest will have to broken up

* CS0649; Field never assigned too

* CS0659 & CS0661 ; Overwrite operators and equals but not hashcode; I don't really override it but just call base

* Small comment fix

* Cleanup pragma statement
2021-04-02 11:20:01 -07:00
Jasper van Merle
271220083b Fix various map file generation issues (#5443) 2021-04-02 11:08:02 -07:00
Stefano Raggi
b29d0cbfaf Tradier Brokerage Updates (#5445)
* Tradier brokerage updates

- Add missing status check after REST API calls
- Initialize DataQueueHandler on-demand (on first subscribe call)

* Trigger build
2021-04-02 10:58:27 -07:00
Tomas Rampas
27a25cd663 The null value parameter removed from call of OandaBrokerage c'tor from OandaDownloader class (#5430)
Co-authored-by: rampasto <tomas.rampas@outlook.com>
2021-03-30 15:25:54 -07:00
Derek Melchin
5ed61db2bb Fix timestamps in custom data algorithms (#5426)
* Correct custom data timestamp and match performance across languages

* Add EndTime property

* Add comment for crypto SetHoldings
2021-03-30 14:48:59 -07:00
Colton Sellers
4a1485a291 QB Fundamental Test Fix (#5437)
* Use only 1 QB instance for fundamental tests, (want to see github workflow result)

* Fix small bug in test
2021-03-30 06:42:39 -07:00
Alexandre Catarino
d6072c88a5 Fixes LiveOptionChainProvider.FindOptionContracts (#5434)
`LiveOptionChainProvider.FindOptionContracts` handles the following data format:
`SPY  2021 03 26 190 000 C P  0 612 360000000`
where both existing `OptionRight.Call` and `OptionRight.Put` are declared in the same line.
2021-03-29 13:39:41 -07:00
Colton Sellers
20910ca2dc Broken Regressions Fixes (#5421)
* Remove regression references to non-existant Python versions

* Adjust regressions estimated capacity not adjusted by #5389

* Adjusts regression algorithms so that they pass (Index/Index Options)

  * Changes start/end date on BasicTemplateIndexAlgorithm
  * Changes option pricing model to BlackScholes in
    IndexOptionCallITMGreeksExpiryRegressionAlgorithm

    - The root cause of why there are no greeks at times for these
      options was identified. It is most likely due to the underlying's
      VolatilityModel not having had enough data to be "warmed up",
      which means it will return a standard deviation of zero to the
      option pricing model, rendering most metrics as NaN.

* Adds missing index/index options regression algorithms

  - Regression algorithms are now 1-1 between C# and Python for
    Indexes/Index options. All regression tests are now passing

* Fixes broken BasicTemplateIndex regression algorithm

  * Previously traded SPY, but because we have no SPY data in Lean
    master, I instead opted for index options, since data for those
    dates is already included

* Deal with weekend for breaking test case

* Adjust DefaultEndDate test to always pass

* Check todays date for open

Co-authored-by: Gerardo Salazar <gsalaz9800@gmail.com>
2021-03-29 13:35:03 -07:00
Jasper van Merle
c333ccdc4a Check whether storage directory exists before enumerating it (#5432) 2021-03-29 13:32:28 -07:00
Christian Korn
88c4a332bc Update PearsonCorrelationPairsTradingAlphaModel.cs (#5428)
Fix index of out bounds (#5427)
2021-03-26 10:55:19 -07:00
Colton Sellers
5d762d16b2 GetFundamental Default End Date (#5401)
* Change default end date for GetFundamental

* Add DefaultEndDate test
2021-03-23 14:18:07 -07:00
Colton Sellers
e2a0873b7c Fix Lean Warnings V1 (#5408)
Cleanup all non-breaking warnings
2021-03-22 11:08:48 -07:00
Gerardo Salazar
31ebaaeaa9 Fixes live BTC futures contract crashing in IB brokerage (#5409) 2021-03-22 08:48:58 -07:00
Jared
7625e232f4 Update readme.md 2021-03-19 14:53:46 -07:00
Alexandre Catarino
63f3af7afe Remove decimal.py (#5406)
* Removes decimal.py

* Removes References to Decimal in Examples
2021-03-19 14:17:05 -07:00
Colton Sellers
87b42f6fb5 Named Args Unit Tests (#5381)
Add regression and unit test
2021-03-16 16:53:02 -07:00
Gerardo Salazar
f9dc38efab Use trades per period instead of days for capacity calculation (#5389)
Use trades per period instead of days for capacity calculation
Updates regression algorithms
2021-03-16 16:30:49 -07:00
425 changed files with 3468 additions and 5108 deletions

View File

@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.212"},
{"Treynor Ratio", "-2.13"},
{"Total Fees", "$199.00"},
{"Estimated Strategy Capacity", "$280000000.00"},
{"Estimated Strategy Capacity", "$23000000.00"},
{"Fitness Score", "0.002"},
{"Kelly Criterion Estimate", "38.64"},
{"Kelly Criterion Probability Value", "0.229"},

View File

@@ -130,7 +130,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.367"},
{"Treynor Ratio", "-4.079"},
{"Total Fees", "$14.33"},
{"Estimated Strategy Capacity", "$29000000.00"},
{"Estimated Strategy Capacity", "$38000000.00"},
{"Fitness Score", "0.408"},
{"Kelly Criterion Estimate", "16.447"},
{"Kelly Criterion Probability Value", "0.315"},

View File

@@ -139,7 +139,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.058"},
{"Treynor Ratio", "2.133"},
{"Total Fees", "$2.00"},
{"Estimated Strategy Capacity", "$6400000.00"},
{"Estimated Strategy Capacity", "$45000000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -191,7 +191,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.042"},
{"Treynor Ratio", "0.286"},
{"Total Fees", "$2.00"},
{"Estimated Strategy Capacity", "$1400000.00"},
{"Estimated Strategy Capacity", "$2800000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -79,19 +79,19 @@ namespace QuantConnect.Algorithm.CSharp
// things like manually added, auto added, internal, and any other boolean state we need to track against a single security)
throw new Exception("The underlying equity data should NEVER be removed in this algorithm because it was manually added");
}
if (_expectedSecurities.AreDifferent(LinqExtensions.ToHashSet(Securities.Keys)))
if (_expectedSecurities.AreDifferent(Securities.Keys.ToHashSet()))
{
var expected = string.Join(Environment.NewLine, _expectedSecurities.OrderBy(s => s.ToString()));
var actual = string.Join(Environment.NewLine, Securities.Keys.OrderBy(s => s.ToString()));
throw new Exception($"{Time}:: Detected differences in expected and actual securities{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
}
if (_expectedUniverses.AreDifferent(LinqExtensions.ToHashSet(UniverseManager.Keys)))
if (_expectedUniverses.AreDifferent(Securities.Keys.ToHashSet()))
{
var expected = string.Join(Environment.NewLine, _expectedUniverses.OrderBy(s => s.ToString()));
var actual = string.Join(Environment.NewLine, UniverseManager.Keys.OrderBy(s => s.ToString()));
throw new Exception($"{Time}:: Detected differences in expected and actual universes{Environment.NewLine}Expected:{Environment.NewLine}{expected}{Environment.NewLine}Actual:{Environment.NewLine}{actual}");
}
if (_expectedData.AreDifferent(LinqExtensions.ToHashSet(data.Keys)))
if (_expectedData.AreDifferent(Securities.Keys.ToHashSet()))
{
var expected = string.Join(Environment.NewLine, _expectedData.OrderBy(s => s.ToString()));
var actual = string.Join(Environment.NewLine, data.Keys.OrderBy(s => s.ToString()));
@@ -183,7 +183,7 @@ namespace QuantConnect.Algorithm.CSharp
if (changes.RemovedSecurities
.Where(x => x.Symbol.SecurityType == SecurityType.Option)
.ToHashSet(s => s.Symbol)
.AreDifferent(LinqExtensions.ToHashSet(_expectedContracts)))
.AreDifferent(_expectedContracts.ToHashSet()))
{
throw new Exception("Expected removed securities to equal expected contracts added");
}
@@ -230,7 +230,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$6.00"},
{"Estimated Strategy Capacity", "$3000.00"},
{"Estimated Strategy Capacity", "$1500.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -131,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.072"},
{"Treynor Ratio", "2.933"},
{"Total Fees", "$26.39"},
{"Estimated Strategy Capacity", "$2200000.00"},
{"Estimated Strategy Capacity", "$4400000.00"},
{"Fitness Score", "0.374"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -84,7 +84,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.006"},
{"Treynor Ratio", "2.029"},
{"Total Fees", "$9.77"},
{"Estimated Strategy Capacity", "$28000000.00"},
{"Estimated Strategy Capacity", "$37000000.00"},
{"Fitness Score", "0.747"},
{"Kelly Criterion Estimate", "38.64"},
{"Kelly Criterion Probability Value", "0.229"},

View File

@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.376"},
{"Treynor Ratio", "-0.084"},
{"Total Fees", "$13.98"},
{"Estimated Strategy Capacity", "$31000000.00"},
{"Estimated Strategy Capacity", "$61000000.00"},
{"Fitness Score", "0.146"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "1"},

View File

@@ -110,7 +110,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.194"},
{"Treynor Ratio", "-0.962"},
{"Total Fees", "$25.92"},
{"Estimated Strategy Capacity", "$16000000.00"},
{"Estimated Strategy Capacity", "$69000000.00"},
{"Fitness Score", "0.004"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "1"},

View File

@@ -211,7 +211,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.068"},
{"Treynor Ratio", "1.722"},
{"Total Fees", "$307.50"},
{"Estimated Strategy Capacity", "$710000.00"},
{"Estimated Strategy Capacity", "$2800000.00"},
{"Fitness Score", "0.173"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -98,7 +98,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.099"},
{"Treynor Ratio", "-5.187"},
{"Total Fees", "$65.00"},
{"Estimated Strategy Capacity", "$2300000000.00"},
{"Estimated Strategy Capacity", "$16000000000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -130,7 +130,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.001"},
{"Treynor Ratio", "1.922"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$15000000.00"},
{"Estimated Strategy Capacity", "$58000000.00"},
{"Fitness Score", "0.248"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -97,7 +97,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.001"},
{"Treynor Ratio", "1.922"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$15000000.00"},
{"Estimated Strategy Capacity", "$58000000.00"},
{"Fitness Score", "0.248"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -88,7 +88,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.221"},
{"Treynor Ratio", "-13.568"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$130000000.00"},
{"Estimated Strategy Capacity", "$890000000.00"},
{"Fitness Score", "0.111"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -109,7 +109,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.002"},
{"Treynor Ratio", "1.839"},
{"Total Fees", "$9.77"},
{"Estimated Strategy Capacity", "$20000000.00"},
{"Estimated Strategy Capacity", "$27000000.00"},
{"Fitness Score", "0.747"},
{"Kelly Criterion Estimate", "38.64"},
{"Kelly Criterion Probability Value", "0.229"},

View File

@@ -147,7 +147,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.504"},
{"Treynor Ratio", "1.011"},
{"Total Fees", "$15207.00"},
{"Estimated Strategy Capacity", "$8800000.00"},
{"Estimated Strategy Capacity", "$7700.00"},
{"Fitness Score", "0.033"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -155,7 +155,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.188"},
{"Treynor Ratio", "-3.318"},
{"Total Fees", "$3.70"},
{"Estimated Strategy Capacity", "$13000000.00"},
{"Estimated Strategy Capacity", "$52000000.00"},
{"Fitness Score", "0.009"},
{"Kelly Criterion Estimate", "-112.972"},
{"Kelly Criterion Probability Value", "0.671"},

View File

@@ -31,7 +31,7 @@ namespace QuantConnect.Algorithm.CSharp
public class BasicTemplateIndexAlgorithm : QCAlgorithm, IRegressionAlgorithmDefinition
{
private Symbol _spx;
private Symbol _spy;
private Symbol _spxOption;
private ExponentialMovingAverage _emaSlow;
private ExponentialMovingAverage _emaFast;
@@ -40,17 +40,26 @@ namespace QuantConnect.Algorithm.CSharp
/// </summary>
public override void Initialize()
{
SetStartDate(2021, 2, 25);
SetEndDate(2021, 3, 3);
SetStartDate(2021, 1, 4);
SetEndDate(2021, 1, 15);
SetCash(1000000);
// Use indicator for signal; but it cannot be traded
_spx = AddIndex("SPX", Resolution.Minute).Symbol;
// Trade on SPX ITM calls
_spxOption = QuantConnect.Symbol.CreateOption(
_spx,
Market.USA,
OptionStyle.European,
OptionRight.Call,
3200m,
new DateTime(2021, 1, 15));
AddIndexOptionContract(_spxOption, Resolution.Minute);
_emaSlow = EMA(_spx, 80);
_emaFast = EMA(_spx, 200);
// Trade on SPY
_spy = AddEquity("SPY", Resolution.Minute).Symbol;
}
/// <summary>
@@ -58,7 +67,7 @@ namespace QuantConnect.Algorithm.CSharp
/// </summary>
public override void OnData(Slice slice)
{
if (!slice.Bars.ContainsKey(_spx) || !slice.Bars.ContainsKey(_spy))
if (!slice.Bars.ContainsKey(_spx) || !slice.Bars.ContainsKey(_spxOption))
{
return;
}
@@ -71,7 +80,7 @@ namespace QuantConnect.Algorithm.CSharp
if (_emaFast > _emaSlow)
{
SetHoldings(_spy, 1);
SetHoldings(_spxOption, 1);
}
else
{
@@ -102,33 +111,33 @@ namespace QuantConnect.Algorithm.CSharp
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "8220"},
{"Average Win", "0.00%"},
{"Average Loss", "0.00%"},
{"Compounding Annual Return", "-100.000%"},
{"Drawdown", "13.500%"},
{"Expectancy", "-0.818"},
{"Net Profit", "-13.517%"},
{"Sharpe Ratio", "-2.678"},
{"Probabilistic Sharpe Ratio", "0%"},
{"Loss Rate", "89%"},
{"Win Rate", "11%"},
{"Profit-Loss Ratio", "0.69"},
{"Alpha", "4.398"},
{"Beta", "-0.989"},
{"Annual Standard Deviation", "0.373"},
{"Annual Variance", "0.139"},
{"Information Ratio", "-12.816"},
{"Tracking Error", "0.504"},
{"Treynor Ratio", "1.011"},
{"Total Fees", "$15207.00"},
{"Estimated Strategy Capacity", "$8800000.00"},
{"Fitness Score", "0.033"},
{"Total Trades", "4"},
{"Average Win", "0%"},
{"Average Loss", "-53.10%"},
{"Compounding Annual Return", "-96.172%"},
{"Drawdown", "10.100%"},
{"Expectancy", "-1"},
{"Net Profit", "-9.915%"},
{"Sharpe Ratio", "-4.217"},
{"Probabilistic Sharpe Ratio", "0.052%"},
{"Loss Rate", "100%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0.139"},
{"Annual Variance", "0.019"},
{"Information Ratio", "-4.217"},
{"Tracking Error", "0.139"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$14000000.00"},
{"Fitness Score", "0.044"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-8.62"},
{"Return Over Maximum Drawdown", "-7.81"},
{"Portfolio Turnover", "302.321"},
{"Sortino Ratio", "-1.96"},
{"Return Over Maximum Drawdown", "-10.171"},
{"Portfolio Turnover", "0.34"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -142,7 +151,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "35b3f4b7a225468d42ca085386a2383e"}
{"OrderListHash", "52521ab779446daf4d38a7c9bbbdd893"}
};
}
}

View File

@@ -134,7 +134,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$778.00"},
{"Estimated Strategy Capacity", "$180000.00"},
{"Estimated Strategy Capacity", "$720.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -131,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$2.00"},
{"Estimated Strategy Capacity", "$2600000.00"},
{"Estimated Strategy Capacity", "$1300000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -28,11 +28,11 @@ namespace QuantConnect.Algorithm.CSharp.Benchmarks
_symbol = AddEquity("SPY").Symbol;
}
public override void OnEndOfDay()
public override void OnEndOfDay(Symbol symbol)
{
var minuteHistory = History(_symbol, 60, Resolution.Minute);
var minuteHistory = History(symbol, 60, Resolution.Minute);
var lastHourHigh = minuteHistory.Select(minuteBar => minuteBar.High).DefaultIfEmpty(0).Max();
var dailyHistory = History(_symbol, 1, Resolution.Daily).First();
var dailyHistory = History(symbol, 1, Resolution.Daily).First();
var dailyHigh = dailyHistory.High;
var dailyLow = dailyHistory.Low;
var dailyOpen = dailyHistory.Open;

View File

@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.09"},
{"Treynor Ratio", "0.82"},
{"Total Fees", "$41.70"},
{"Estimated Strategy Capacity", "$2000000.00"},
{"Estimated Strategy Capacity", "$3000000.00"},
{"Fitness Score", "0.634"},
{"Kelly Criterion Estimate", "13.656"},
{"Kelly Criterion Probability Value", "0.228"},

View File

@@ -181,7 +181,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.149"},
{"Treynor Ratio", "-1.405"},
{"Total Fees", "$2.00"},
{"Estimated Strategy Capacity", "$6000000.00"},
{"Estimated Strategy Capacity", "$42000000.00"},
{"Fitness Score", "0.076"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -136,7 +136,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.126"},
{"Treynor Ratio", "-0.607"},
{"Total Fees", "$11.63"},
{"Estimated Strategy Capacity", "$13000000.00"},
{"Estimated Strategy Capacity", "$46000000.00"},
{"Fitness Score", "0.013"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -120,7 +120,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.105"},
{"Treynor Ratio", "1.667"},
{"Total Fees", "$2.91"},
{"Estimated Strategy Capacity", "$96000000.00"},
{"Estimated Strategy Capacity", "$670000000.00"},
{"Fitness Score", "0.141"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -91,7 +91,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.101"},
{"Treynor Ratio", "5.409"},
{"Total Fees", "$67.00"},
{"Estimated Strategy Capacity", "$2400000.00"},
{"Estimated Strategy Capacity", "$3200000.00"},
{"Fitness Score", "0.501"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -85,7 +85,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.009"},
{"Treynor Ratio", "1.575"},
{"Total Fees", "$22.77"},
{"Estimated Strategy Capacity", "$19000000.00"},
{"Estimated Strategy Capacity", "$22000000.00"},
{"Fitness Score", "0.999"},
{"Kelly Criterion Estimate", "38.64"},
{"Kelly Criterion Probability Value", "0.229"},

View File

@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.165"},
{"Treynor Ratio", "1.212"},
{"Total Fees", "$6.00"},
{"Estimated Strategy Capacity", "$32000000.00"},
{"Estimated Strategy Capacity", "$42000000.00"},
{"Fitness Score", "0.063"},
{"Kelly Criterion Estimate", "38.64"},
{"Kelly Criterion Probability Value", "0.229"},

View File

@@ -190,7 +190,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.176"},
{"Treynor Ratio", "-1.46"},
{"Total Fees", "$7.82"},
{"Estimated Strategy Capacity", "$6000000.00"},
{"Estimated Strategy Capacity", "$12000000.00"},
{"Fitness Score", "0.1"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -146,7 +146,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.239"},
{"Treynor Ratio", "-1.435"},
{"Total Fees", "$755.29"},
{"Estimated Strategy Capacity", "$150000000.00"},
{"Estimated Strategy Capacity", "$1100000000.00"},
{"Fitness Score", "0.024"},
{"Kelly Criterion Estimate", "-0.84"},
{"Kelly Criterion Probability Value", "0.53"},

View File

@@ -99,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.168"},
{"Treynor Ratio", "2.38"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$75000000.00"},
{"Estimated Strategy Capacity", "$300000000.00"},
{"Fitness Score", "0.245"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -96,7 +96,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0.988"},
{"Total Fees", "$7.78"},
{"Estimated Strategy Capacity", "$2200000.00"},
{"Estimated Strategy Capacity", "$8700000.00"},
{"Fitness Score", "0.031"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -43,7 +43,7 @@ namespace QuantConnect.Algorithm.CSharp
security.SetBuyingPowerModel(new CustomBuyingPowerModel());
}
public void OnData(Slice slice)
public override void OnData(Slice slice)
{
if (Portfolio.Invested)
{
@@ -113,7 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "1.04"},
{"Treynor Ratio", "5.073"},
{"Total Fees", "$30.00"},
{"Estimated Strategy Capacity", "$2800000.00"},
{"Estimated Strategy Capacity", "$20000000.00"},
{"Fitness Score", "0.418"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -80,7 +80,7 @@ namespace QuantConnect.Algorithm.CSharp
/// OnEndOfDay Event Handler - At the end of each trading day we fire this code.
/// To avoid flooding, we recommend running your plotting at the end of each day.
/// </summary>
public override void OnEndOfDay()
public override void OnEndOfDay(Symbol symbol)
{
//Log the end of day prices:
Plot("Trade Plot", "Price", _lastPrice);

View File

@@ -119,7 +119,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.112"},
{"Treynor Ratio", "-6.121"},
{"Total Fees", "$3.50"},
{"Estimated Strategy Capacity", "$6900000.00"},
{"Estimated Strategy Capacity", "$48000000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -124,7 +124,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.112"},
{"Treynor Ratio", "-6.121"},
{"Total Fees", "$3.50"},
{"Estimated Strategy Capacity", "$6900000.00"},
{"Estimated Strategy Capacity", "$48000000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -131,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.19"},
{"Treynor Ratio", "2.159"},
{"Total Fees", "$1.00"},
{"Estimated Strategy Capacity", "$14000000.00"},
{"Estimated Strategy Capacity", "$58000000.00"},
{"Fitness Score", "0.1"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -58,7 +58,9 @@ namespace QuantConnect.Algorithm.CSharp
//Weather used as a tradable asset, like stocks, futures etc.
if (data.Close != 0)
{
Order("BTC", (Portfolio.MarginRemaining / Math.Abs(data.Close + 1)));
// It's only OK to use SetHoldings with crypto when using custom data. When trading with built-in crypto data,
// use the cashbook. Reference https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/BasicTemplateCryptoAlgorithm.py
SetHoldings("BTC", 1);
}
Console.WriteLine("Buying BTC 'Shares': BTC: " + data.Close);
}
@@ -117,7 +119,7 @@ namespace QuantConnect.Algorithm.CSharp
//return "http://my-ftp-server.com/futures-data-" + date.ToString("Ymd") + ".zip";
// OR simply return a fixed small data file. Large files will slow down your backtest
return new SubscriptionDataSource("https://www.quandl.com/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc", SubscriptionTransportMedium.RemoteFile);
return new SubscriptionDataSource("https://www.quantconnect.com/api/v2/proxy/quandl/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc&api_key=WyAazVXnq7ATy_fefTqm", SubscriptionTransportMedium.RemoteFile);
}
/// <summary>
@@ -154,6 +156,7 @@ namespace QuantConnect.Algorithm.CSharp
{
string[] data = line.Split(',');
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
coin.EndTime = coin.Time.AddDays(1);
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);

View File

@@ -61,7 +61,7 @@ namespace QuantConnect.Algorithm.CSharp
/// "Nifty" type below and fired into this event handler.
/// </summary>
/// <param name="data">One(1) Nifty Object, streamed into our algorithm synchronised in time with our other data streams</param>
public void OnData(Slice data)
public override void OnData(Slice data)
{
if (data.ContainsKey("USDINR"))
{
@@ -77,7 +77,7 @@ namespace QuantConnect.Algorithm.CSharp
{
_today.NiftyPrice = Convert.ToDouble(data["NIFTY"].Close);
if (_today.Date == data["NIFTY"].EndTime)
if (_today.Date == data["NIFTY"].Time)
{
_prices.Add(_today);
@@ -91,7 +91,7 @@ namespace QuantConnect.Algorithm.CSharp
var quantity = (int)(Portfolio.MarginRemaining * 0.9m / data["NIFTY"].Close);
var highestNifty = (from pair in _prices select pair.NiftyPrice).Max();
var lowestNifty = (from pair in _prices select pair.NiftyPrice).Min();
if (Time.DayOfWeek == DayOfWeek.Wednesday) //prices.Count >= minimumCorrelationHistory &&
{
//List<double> niftyPrices = (from pair in prices select pair.NiftyPrice).ToList();
@@ -121,7 +121,7 @@ namespace QuantConnect.Algorithm.CSharp
/// End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets).
/// </summary>
/// <remarks>Method is called 10 minutes before closing to allow user to close out position.</remarks>
public override void OnEndOfDay()
public override void OnEndOfDay(Symbol symbol)
{
Plot("Nifty Closing Price", _today.NiftyPrice);
}
@@ -181,6 +181,7 @@ namespace QuantConnect.Algorithm.CSharp
//2011-09-13 7792.9 7799.9 7722.65 7748.7 116534670 6107.78
var data = line.Split(',');
index.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
index.EndTime = index.Time.AddDays(1);
index.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
index.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
index.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
@@ -247,6 +248,7 @@ namespace QuantConnect.Algorithm.CSharp
{
var data = line.Split(',');
currency.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
currency.EndTime = currency.Time.AddDays(1);
currency.Close = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
currency.Symbol = "USDINR";
currency.Value = currency.Close;

View File

@@ -114,29 +114,29 @@ namespace QuantConnect.Algorithm.CSharp
{"Total Trades", "1"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "155.262%"},
{"Compounding Annual Return", "157.498%"},
{"Drawdown", "84.800%"},
{"Expectancy", "0"},
{"Net Profit", "5123.242%"},
{"Sharpe Ratio", "2.067"},
{"Probabilistic Sharpe Ratio", "68.833%"},
{"Net Profit", "5319.081%"},
{"Sharpe Ratio", "2.086"},
{"Probabilistic Sharpe Ratio", "69.456%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "1.732"},
{"Beta", "0.037"},
{"Annual Standard Deviation", "0.841"},
{"Annual Variance", "0.707"},
{"Information Ratio", "1.902"},
{"Tracking Error", "0.848"},
{"Treynor Ratio", "46.992"},
{"Alpha", "1.736"},
{"Beta", "0.136"},
{"Annual Standard Deviation", "0.84"},
{"Annual Variance", "0.706"},
{"Information Ratio", "1.925"},
{"Tracking Error", "0.846"},
{"Treynor Ratio", "12.904"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$0"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "2.238"},
{"Return Over Maximum Drawdown", "1.832"},
{"Sortino Ratio", "2.269"},
{"Return Over Maximum Drawdown", "1.858"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
@@ -151,7 +151,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "1f54fb75ebcc0daafa5d45bfbaa4fbcb"}
{"OrderListHash", "0d80bb47bd16b5bc6989a4c1c7aa8349"}
};
/// <summary>
@@ -243,6 +243,7 @@ namespace QuantConnect.Algorithm.CSharp
{
string[] data = line.Split(',');
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
coin.EndTime = coin.Time.AddDays(1);
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
@@ -258,4 +259,4 @@ namespace QuantConnect.Algorithm.CSharp
}
}
}
}
}

View File

@@ -84,29 +84,29 @@ namespace QuantConnect.Algorithm.CSharp
{"Total Trades", "1"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "155.262%"},
{"Compounding Annual Return", "157.497%"},
{"Drawdown", "84.800%"},
{"Expectancy", "0"},
{"Net Profit", "5123.170%"},
{"Sharpe Ratio", "2.066"},
{"Probabilistic Sharpe Ratio", "68.832%"},
{"Net Profit", "5319.007%"},
{"Sharpe Ratio", "2.086"},
{"Probabilistic Sharpe Ratio", "69.456%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "1.732"},
{"Beta", "0.037"},
{"Annual Standard Deviation", "0.841"},
{"Annual Variance", "0.707"},
{"Information Ratio", "1.902"},
{"Tracking Error", "0.848"},
{"Treynor Ratio", "46.996"},
{"Alpha", "1.736"},
{"Beta", "0.136"},
{"Annual Standard Deviation", "0.84"},
{"Annual Variance", "0.706"},
{"Information Ratio", "1.925"},
{"Tracking Error", "0.846"},
{"Treynor Ratio", "12.903"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$0"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "2.238"},
{"Return Over Maximum Drawdown", "1.832"},
{"Sortino Ratio", "2.269"},
{"Return Over Maximum Drawdown", "1.858"},
{"Portfolio Turnover", "0"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
@@ -121,7 +121,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "0e7d560d0db2829adb19d3e403c30d97"}
{"OrderListHash", "50faa37f15732bf5c24ad1eeaa335bc7"}
};
/// <summary>
@@ -213,6 +213,7 @@ namespace QuantConnect.Algorithm.CSharp
{
string[] data = line.Split(',');
coin.Time = DateTime.Parse(data[0], CultureInfo.InvariantCulture);
coin.EndTime = coin.Time.AddDays(1);
coin.Open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
coin.High = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
coin.Low = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
@@ -228,4 +229,4 @@ namespace QuantConnect.Algorithm.CSharp
}
}
}
}
}

View File

@@ -212,7 +212,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.118"},
{"Treynor Ratio", "-0.591"},
{"Total Fees", "$62.24"},
{"Estimated Strategy Capacity", "$100000000.00"},
{"Estimated Strategy Capacity", "$49000000.00"},
{"Fitness Score", "0.147"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.251"},
{"Treynor Ratio", "9.323"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$220000000.00"},
{"Estimated Strategy Capacity", "$890000000.00"},
{"Fitness Score", "0.201"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -113,7 +113,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.08"},
{"Treynor Ratio", "0.517"},
{"Total Fees", "$3.70"},
{"Estimated Strategy Capacity", "$38000000.00"},
{"Estimated Strategy Capacity", "$270000000.00"},
{"Fitness Score", "0.019"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -123,7 +123,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.115"},
{"Treynor Ratio", "1.545"},
{"Total Fees", "$37.00"},
{"Estimated Strategy Capacity", "$58000.00"},
{"Estimated Strategy Capacity", "$400000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -186,7 +186,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.204"},
{"Treynor Ratio", "-8.165"},
{"Total Fees", "$46.75"},
{"Estimated Strategy Capacity", "$96000000.00"},
{"Estimated Strategy Capacity", "$670000000.00"},
{"Fitness Score", "0.002"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -204,7 +204,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.171"},
{"Treynor Ratio", "-1.761"},
{"Total Fees", "$8669.41"},
{"Estimated Strategy Capacity", "$170000.00"},
{"Estimated Strategy Capacity", "$320000.00"},
{"Fitness Score", "0.675"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -177,7 +177,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.171"},
{"Treynor Ratio", "-1.971"},
{"Total Fees", "$6806.67"},
{"Estimated Strategy Capacity", "$150000.00"},
{"Estimated Strategy Capacity", "$320000.00"},
{"Fitness Score", "0.694"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -131,7 +131,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.29"},
{"Treynor Ratio", "4.005"},
{"Total Fees", "$18.28"},
{"Estimated Strategy Capacity", "$200000000.00"},
{"Estimated Strategy Capacity", "$500000000.00"},
{"Fitness Score", "0.052"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -127,7 +127,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.204"},
{"Treynor Ratio", "-1.424"},
{"Total Fees", "$16.26"},
{"Estimated Strategy Capacity", "$250000000.00"},
{"Estimated Strategy Capacity", "$590000000.00"},
{"Fitness Score", "0.003"},
{"Kelly Criterion Estimate", "12.539"},
{"Kelly Criterion Probability Value", "0.367"},

View File

@@ -148,7 +148,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "1.441"},
{"Treynor Ratio", "-0.15"},
{"Total Fees", "$33.30"},
{"Estimated Strategy Capacity", "$4200000.00"},
{"Estimated Strategy Capacity", "$17000000.00"},
{"Fitness Score", "0.079"},
{"Kelly Criterion Estimate", "-9.366"},
{"Kelly Criterion Probability Value", "0.607"},

View File

@@ -184,7 +184,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.123"},
{"Treynor Ratio", "-1.288"},
{"Total Fees", "$669.76"},
{"Estimated Strategy Capacity", "$8100000.00"},
{"Estimated Strategy Capacity", "$210000.00"},
{"Fitness Score", "0.021"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -147,7 +147,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.049"},
{"Treynor Ratio", "-0.934"},
{"Total Fees", "$22.26"},
{"Estimated Strategy Capacity", "$3600000.00"},
{"Estimated Strategy Capacity", "$360000.00"},
{"Fitness Score", "0.002"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -122,7 +122,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.186"},
{"Treynor Ratio", "1.557"},
{"Total Fees", "$4.00"},
{"Estimated Strategy Capacity", "$1400000.00"},
{"Estimated Strategy Capacity", "$5200000.00"},
{"Fitness Score", "0.012"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -174,7 +174,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$804.33"},
{"Estimated Strategy Capacity", "$21000.00"},
{"Estimated Strategy Capacity", "$11000.00"},
{"Fitness Score", "0.504"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -98,7 +98,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$5.93"},
{"Estimated Strategy Capacity", "$200000.00"},
{"Estimated Strategy Capacity", "$590000.00"},
{"Fitness Score", "0.499"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -105,7 +105,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.394"},
{"Treynor Ratio", "-5.313"},
{"Total Fees", "$5.40"},
{"Estimated Strategy Capacity", "$59000000.00"},
{"Estimated Strategy Capacity", "$230000000.00"},
{"Fitness Score", "0.244"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -118,7 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.507"},
{"Treynor Ratio", "0"},
{"Total Fees", "$2651.01"},
{"Estimated Strategy Capacity", "$9800.00"},
{"Estimated Strategy Capacity", "$30000.00"},
{"Fitness Score", "0.467"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -99,7 +99,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.267"},
{"Treynor Ratio", "-0.847"},
{"Total Fees", "$41.17"},
{"Estimated Strategy Capacity", "$98000000.00"},
{"Estimated Strategy Capacity", "$340000000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "38.884"},
{"Kelly Criterion Probability Value", "0.009"},

View File

@@ -138,7 +138,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.195"},
{"Treynor Ratio", "55.977"},
{"Total Fees", "$14.80"},
{"Estimated Strategy Capacity", "$2100000.00"},
{"Estimated Strategy Capacity", "$15000000.00"},
{"Fitness Score", "0.018"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -222,7 +222,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.191"},
{"Treynor Ratio", "33.18"},
{"Total Fees", "$7.40"},
{"Estimated Strategy Capacity", "$1300000.00"},
{"Estimated Strategy Capacity", "$9000000.00"},
{"Fitness Score", "0.008"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -180,7 +180,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.718"},
{"Treynor Ratio", "18.473"},
{"Total Fees", "$66.60"},
{"Estimated Strategy Capacity", "$1200000.00"},
{"Estimated Strategy Capacity", "$8300000.00"},
{"Fitness Score", "0.162"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -197,7 +197,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.182"},
{"Treynor Ratio", "28.46"},
{"Total Fees", "$3.70"},
{"Estimated Strategy Capacity", "$830000.00"},
{"Estimated Strategy Capacity", "$5800000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -223,7 +223,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.183"},
{"Treynor Ratio", "37.798"},
{"Total Fees", "$7.40"},
{"Estimated Strategy Capacity", "$1400000.00"},
{"Estimated Strategy Capacity", "$9900000.00"},
{"Fitness Score", "0.008"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -196,7 +196,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.187"},
{"Treynor Ratio", "28.078"},
{"Total Fees", "$3.70"},
{"Estimated Strategy Capacity", "$1200000.00"},
{"Estimated Strategy Capacity", "$8700000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -207,7 +207,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.183"},
{"Treynor Ratio", "22.266"},
{"Total Fees", "$7.40"},
{"Estimated Strategy Capacity", "$1900000.00"},
{"Estimated Strategy Capacity", "$13000000.00"},
{"Fitness Score", "0.021"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -190,7 +190,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.176"},
{"Treynor Ratio", "27.339"},
{"Total Fees", "$3.70"},
{"Estimated Strategy Capacity", "$460000.00"},
{"Estimated Strategy Capacity", "$3200000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -204,7 +204,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.176"},
{"Treynor Ratio", "14.729"},
{"Total Fees", "$7.40"},
{"Estimated Strategy Capacity", "$1900000.00"},
{"Estimated Strategy Capacity", "$14000000.00"},
{"Fitness Score", "0.022"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -189,7 +189,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.179"},
{"Treynor Ratio", "28.253"},
{"Total Fees", "$3.70"},
{"Estimated Strategy Capacity", "$770000.00"},
{"Estimated Strategy Capacity", "$5400000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -102,7 +102,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.332"},
{"Treynor Ratio", "2.021"},
{"Total Fees", "$1.85"},
{"Estimated Strategy Capacity", "$47000000.00"},
{"Estimated Strategy Capacity", "$93000000.00"},
{"Fitness Score", "0.005"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -173,7 +173,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.176"},
{"Treynor Ratio", "29.128"},
{"Total Fees", "$7.40"},
{"Estimated Strategy Capacity", "$10000000.00"},
{"Estimated Strategy Capacity", "$71000000.00"},
{"Fitness Score", "0.007"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -92,7 +92,7 @@ namespace QuantConnect.Algorithm.CSharp
}
}
public override void OnEndOfDay()
public override void OnEndOfDay(Symbol symbol)
{
Plot("Indicator Signal", "EOD", IsDownTrend ? -1 : IsUpTrend ? 1 : 0);
}

View File

@@ -41,7 +41,9 @@ namespace QuantConnect.Algorithm.CSharp
// Without this, consuming projects would need to hard reference the Accord dlls,
// which is less than perfect. This seems to be the better of two evils
//
#pragma warning disable 0414
Accord.Math.Matrix3x3 _matrix = new Accord.Math.Matrix3x3();
#pragma warning restore 0414
//Fuzzy Engine
private FuzzyEngine _engine;

View File

@@ -317,7 +317,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.264"},
{"Treynor Ratio", "26.924"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$300000000.00"},
{"Estimated Strategy Capacity", "$890000000.00"},
{"Fitness Score", "0.251"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -106,7 +106,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.866"},
{"Treynor Ratio", "-0.286"},
{"Total Fees", "$5.40"},
{"Estimated Strategy Capacity", "$350000.00"},
{"Estimated Strategy Capacity", "$2400000.00"},
{"Fitness Score", "0.008"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -128,7 +128,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$1.00"},
{"Estimated Strategy Capacity", "$12000000000.00"},
{"Estimated Strategy Capacity", "$36000000000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -116,7 +116,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.073"},
{"Treynor Ratio", "0.573"},
{"Total Fees", "$14.75"},
{"Estimated Strategy Capacity", "$1300000.00"},
{"Estimated Strategy Capacity", "$6300000.00"},
{"Fitness Score", "0.2"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -51,7 +51,7 @@ namespace QuantConnect.Algorithm.CSharp
.Take(1)
.Single(), Resolution.Minute);
_spxOption.PriceModel = OptionPriceModels.BjerksundStensland();
_spxOption.PriceModel = OptionPriceModels.BlackScholes();
_expectedOptionContract = QuantConnect.Symbol.CreateOption(_spx, Market.USA, OptionStyle.European, OptionRight.Call, 3200m, new DateTime(2021, 1, 15));
if (_spxOption.Symbol != _expectedOptionContract)
@@ -90,16 +90,16 @@ namespace QuantConnect.Algorithm.CSharp
var vega = data.OptionChains.Values.OrderByDescending(y => y.Contracts.Values.Sum(x => x.Volume)).First().Contracts.Values.Select(x => x.Greeks.Vega).ToList();
// The commented out test cases all return zero.
// This is because of failure to evaluate the greeks in the option pricing model.
// For now, let's skip those.
// This is because of failure to evaluate the greeks in the option pricing model, most likely
// due to us not clearing the default 30 day requirement for the volatility model to start being updated.
if (deltas.Any(d => d == 0))
{
throw new AggregateException("Option contract Delta was equal to zero");
}
if (gammas.Any(g => g == 0))
{
throw new AggregateException("Option contract Gamma was equal to zero");
}
//if (gammas.Any(g => g == 0))
//{
// throw new AggregateException("Option contract Gamma was equal to zero");
//}
//if (lambda.Any(l => l == 0))
//{
// throw new AggregateException("Option contract Lambda was equal to zero");
@@ -108,10 +108,10 @@ namespace QuantConnect.Algorithm.CSharp
{
throw new AggregateException("Option contract Rho was equal to zero");
}
//if (theta.Any(t => t == 0))
//{
// throw new AggregateException("Option contract Theta was equal to zero");
//}
if (theta.Any(t => t == 0))
{
throw new AggregateException("Option contract Theta was equal to zero");
}
//if (vega.Any(v => v == 0))
//{
// throw new AggregateException("Option contract Vega was equal to zero");
@@ -148,40 +148,40 @@ namespace QuantConnect.Algorithm.CSharp
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp };
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
/// <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 Trades", "3"},
{"Average Win", "27.44%"},
{"Average Loss", "-62.81%"},
{"Compounding Annual Return", "-80.444%"},
{"Drawdown", "52.600%"},
{"Expectancy", "-0.282"},
{"Net Profit", "-52.604%"},
{"Sharpe Ratio", "-0.867"},
{"Probabilistic Sharpe Ratio", "0.021%"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "0.44"},
{"Alpha", "-0.611"},
{"Beta", "-0.033"},
{"Annual Standard Deviation", "0.695"},
{"Annual Variance", "0.484"},
{"Information Ratio", "-0.513"},
{"Tracking Error", "0.718"},
{"Treynor Ratio", "18.473"},
{"Total Fees", "$66.60"},
{"Estimated Strategy Capacity", "$1200000.00"},
{"Fitness Score", "0.162"},
{"Total Trades", "2"},
{"Average Win", "0%"},
{"Average Loss", "-56.91%"},
{"Compounding Annual Return", "44.906%"},
{"Drawdown", "9.800%"},
{"Expectancy", "-1"},
{"Net Profit", "2.644%"},
{"Sharpe Ratio", "7.691"},
{"Probabilistic Sharpe Ratio", "91.027%"},
{"Loss Rate", "100%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "0"},
{"Beta", "0"},
{"Annual Standard Deviation", "0.417"},
{"Annual Variance", "0.174"},
{"Information Ratio", "7.691"},
{"Tracking Error", "0.417"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$46000000.00"},
{"Fitness Score", "0.023"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "-0.136"},
{"Return Over Maximum Drawdown", "-1.529"},
{"Portfolio Turnover", "0.427"},
{"Sortino Ratio", "0.535"},
{"Return Over Maximum Drawdown", "5.789"},
{"Portfolio Turnover", "0.03"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
@@ -195,7 +195,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "a7f76d1e2d6f27651465217c92deea80"}
{"OrderListHash", "3cccf8c2409ee8a9020ba79a6c45742a"}
};
}
}

View File

@@ -192,7 +192,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$3300.00"},
{"Estimated Strategy Capacity", "$23000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -185,7 +185,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$0.00"},
{"Estimated Strategy Capacity", "$3300.00"},
{"Estimated Strategy Capacity", "$23000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -158,8 +158,10 @@ namespace QuantConnect.Algorithm.CSharp
/// <summary>
/// Fire plotting events once per day.
/// </summary>
public override void OnEndOfDay()
public override void OnEndOfDay(Symbol symbol)
{
if (symbol != _symbol) return;
if (!_indicators.BB.IsReady) return;
Plot("BB", "Price", _price);
@@ -261,7 +263,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.146"},
{"Treynor Ratio", "-2.677"},
{"Total Fees", "$1.00"},
{"Estimated Strategy Capacity", "$75000000.00"},
{"Estimated Strategy Capacity", "$530000000.00"},
{"Fitness Score", "0.001"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -94,7 +94,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.165"},
{"Treynor Ratio", "1.212"},
{"Total Fees", "$6.00"},
{"Estimated Strategy Capacity", "$32000000.00"},
{"Estimated Strategy Capacity", "$42000000.00"},
{"Fitness Score", "0.063"},
{"Kelly Criterion Estimate", "38.64"},
{"Kelly Criterion Probability Value", "0.229"},

View File

@@ -102,7 +102,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "1.925"},
{"Total Fees", "$61.90"},
{"Estimated Strategy Capacity", "$2900000.00"},
{"Estimated Strategy Capacity", "$5800000.00"},
{"Fitness Score", "0.979"},
{"Kelly Criterion Estimate", "38.64"},
{"Kelly Criterion Probability Value", "0.229"},

View File

@@ -100,7 +100,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.196"},
{"Treynor Ratio", "-0.169"},
{"Total Fees", "$34.00"},
{"Estimated Strategy Capacity", "$460000000.00"},
{"Estimated Strategy Capacity", "$180000000.00"},
{"Fitness Score", "0.008"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -145,7 +145,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.22"},
{"Treynor Ratio", "3.431"},
{"Total Fees", "$3.00"},
{"Estimated Strategy Capacity", "$480000000.00"},
{"Estimated Strategy Capacity", "$1900000000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -118,7 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.004"},
{"Treynor Ratio", "1.577"},
{"Total Fees", "$293.06"},
{"Estimated Strategy Capacity", "$19000000.00"},
{"Estimated Strategy Capacity", "$14000000.00"},
{"Fitness Score", "0.999"},
{"Kelly Criterion Estimate", "-6.994"},
{"Kelly Criterion Probability Value", "0.593"},

View File

@@ -118,7 +118,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.214"},
{"Treynor Ratio", "-0.774"},
{"Total Fees", "$443.74"},
{"Estimated Strategy Capacity", "$110000000.00"},
{"Estimated Strategy Capacity", "$750000000.00"},
{"Fitness Score", "0.013"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -135,7 +135,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.224"},
{"Treynor Ratio", "3.851"},
{"Total Fees", "$26.01"},
{"Estimated Strategy Capacity", "$11000000.00"},
{"Estimated Strategy Capacity", "$22000000.00"},
{"Fitness Score", "0.999"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -105,7 +105,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.346"},
{"Treynor Ratio", "-0.863"},
{"Total Fees", "$13.69"},
{"Estimated Strategy Capacity", "$1800000.00"},
{"Estimated Strategy Capacity", "$13000000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -85,7 +85,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.005"},
{"Treynor Ratio", "1.772"},
{"Total Fees", "$16.28"},
{"Estimated Strategy Capacity", "$17000000.00"},
{"Estimated Strategy Capacity", "$14000000.00"},
{"Fitness Score", "0.999"},
{"Kelly Criterion Estimate", "38.64"},
{"Kelly Criterion Probability Value", "0.229"},

View File

@@ -103,7 +103,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.1"},
{"Treynor Ratio", "3.315"},
{"Total Fees", "$27.72"},
{"Estimated Strategy Capacity", "$8600000.00"},
{"Estimated Strategy Capacity", "$25000000.00"},
{"Fitness Score", "0.688"},
{"Kelly Criterion Estimate", "13.656"},
{"Kelly Criterion Probability Value", "0.228"},

View File

@@ -151,7 +151,7 @@ namespace QuantConnect.Algorithm.CSharp
/// End of a trading day event handler. This method is called at the end of the algorithm day (or multiple times if trading multiple assets).
/// </summary>
/// <remarks>Method is called 10 minutes before closing to allow user to close out position.</remarks>
public override void OnEndOfDay()
public override void OnEndOfDay(Symbol symbol)
{
int i = 0;
foreach (var kvp in Data.OrderBy(x => x.Value.Symbol))

View File

@@ -0,0 +1,87 @@
/*
* 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.Collections.Generic;
using QuantConnect.Data;
using QuantConnect.Interfaces;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Regression Definition for Python NamedArgumentsRegression
/// Used to test PythonNet kwargs
/// </summary>
/// <meta name="tag" content="using data" />
public class NamedArgumentsRegression : IRegressionAlgorithmDefinition
{
/// <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 Language[] Languages { get; } = { Language.Python };
/// <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 Trades", "1"},
{"Average Win", "0%"},
{"Average Loss", "0%"},
{"Compounding Annual Return", "246.000%"},
{"Drawdown", "1.100%"},
{"Expectancy", "0"},
{"Net Profit", "3.459%"},
{"Sharpe Ratio", "10.11"},
{"Probabilistic Sharpe Ratio", "83.150%"},
{"Loss Rate", "0%"},
{"Win Rate", "0%"},
{"Profit-Loss Ratio", "0"},
{"Alpha", "1.935"},
{"Beta", "-0.119"},
{"Annual Standard Deviation", "0.16"},
{"Annual Variance", "0.026"},
{"Information Ratio", "-4.556"},
{"Tracking Error", "0.221"},
{"Treynor Ratio", "-13.568"},
{"Total Fees", "$3.26"},
{"Estimated Strategy Capacity", "$890000000.00"},
{"Fitness Score", "0.111"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},
{"Sortino Ratio", "52.533"},
{"Return Over Maximum Drawdown", "214.75"},
{"Portfolio Turnover", "0.111"},
{"Total Insights Generated", "0"},
{"Total Insights Closed", "0"},
{"Total Insights Analysis Completed", "0"},
{"Long Insight Count", "0"},
{"Short Insight Count", "0"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$0"},
{"Total Accumulated Estimated Alpha Value", "$0"},
{"Mean Population Estimated Insight Value", "$0"},
{"Mean Population Direction", "0%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "0%"},
{"Rolling Averaged Population Magnitude", "0%"},
{"OrderListHash", "82fee25cd17100c53bb173834ab5f0b2"}
};
}
}

View File

@@ -121,7 +121,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.611"},
{"Treynor Ratio", "9.236"},
{"Total Fees", "$103.34"},
{"Estimated Strategy Capacity", "$9500000.00"},
{"Estimated Strategy Capacity", "$8000000.00"},
{"Fitness Score", "0.999"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -30,7 +30,6 @@ namespace QuantConnect.Algorithm.CSharp
private int _onEndOfDaySpyCallCount;
private int _onEndOfDayBacCallCount;
private int _onEndOfDayIbmCallCount;
private int _onEndOfDayCallCount;
/// <summary>
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
@@ -55,14 +54,6 @@ namespace QuantConnect.Algorithm.CSharp
});
}
/// <summary>
/// Obsolete overload to be removed.
/// </summary>
public override void OnEndOfDay()
{
_onEndOfDayCallCount++;
}
/// <summary>
/// We expect it to be called for the universe selected <see cref="Symbol"/>
/// and the post initialize manually added equity <see cref="Symbol"/>
@@ -115,10 +106,6 @@ namespace QuantConnect.Algorithm.CSharp
{
throw new Exception($"OnEndOfDay(IBM) unexpected count call {_onEndOfDayIbmCallCount}");
}
if (_onEndOfDayCallCount != 4)
{
throw new Exception($"OnEndOfDay() unexpected count call {_onEndOfDayCallCount}");
}
}
/// <summary>
@@ -156,7 +143,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.07"},
{"Treynor Ratio", "3.602"},
{"Total Fees", "$20.75"},
{"Estimated Strategy Capacity", "$1300000.00"},
{"Estimated Strategy Capacity", "$5200000.00"},
{"Fitness Score", "0.249"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -55,6 +55,8 @@ namespace QuantConnect.Algorithm.CSharp
/// <meta name="tag" content="indicators" />
public class OpeningBreakoutAlgorithm : QCAlgorithm
{
#pragma warning disable 00162 // File contains unreachable code when EnableOrderUpdateLogging is false
// the equity symbol we're trading
private const string symbol = "SPY";
@@ -396,9 +398,9 @@ namespace QuantConnect.Algorithm.CSharp
/// <summary>
/// If we're still invested by the end of the day, liquidate
/// </summary>
public override void OnEndOfDay()
public override void OnEndOfDay(Symbol symbol)
{
if (Security.Invested)
if (symbol == Security.Symbol && Security.Invested)
{
Liquidate();
}
@@ -544,5 +546,6 @@ namespace QuantConnect.Algorithm.CSharp
return (Security.Holdings.IsLong && PSARMin > stopPrice)
|| (Security.Holdings.IsShort && PSARMin < stopPrice);
}
#pragma warning restore 00162
}
}

View File

@@ -97,7 +97,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$12.00"},
{"Estimated Strategy Capacity", "$3100000.00"},
{"Estimated Strategy Capacity", "$310000.00"},
{"Fitness Score", "0.5"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -141,7 +141,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0"},
{"Treynor Ratio", "0"},
{"Total Fees", "$2.00"},
{"Estimated Strategy Capacity", "$9800.00"},
{"Estimated Strategy Capacity", "$4900.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -117,7 +117,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.044"},
{"Treynor Ratio", "-0.336"},
{"Total Fees", "$1.00"},
{"Estimated Strategy Capacity", "$890000000.00"},
{"Estimated Strategy Capacity", "$3600000000.00"},
{"Fitness Score", "0.003"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

View File

@@ -163,7 +163,7 @@ namespace QuantConnect.Algorithm.CSharp
{"Tracking Error", "0.002"},
{"Treynor Ratio", "0"},
{"Total Fees", "$4.00"},
{"Estimated Strategy Capacity", "$190000.00"},
{"Estimated Strategy Capacity", "$760000.00"},
{"Fitness Score", "0"},
{"Kelly Criterion Estimate", "0"},
{"Kelly Criterion Probability Value", "0"},

Some files were not shown because too many files have changed in this diff Show More