GeezerVison is showing github.com — Merge Framework and Classic Algorithms · nuswgg/Lean@32ac314
File treeExpand file treeCollapse file tree Open diff view settings AlgorithmFactory/Python/Wrappers Algorithm/Framework/Alphas
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/ForexCalendarAlpha.cs +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 14 | 14 | */ | 15 | 15 |
| 16 | 16 | using NodaTime; | 17 | | -using QuantConnect.Algorithm.Framework; | 18 | 17 | using QuantConnect.Algorithm.Framework.Alphas; | 19 | 18 | using QuantConnect.Algorithm.Framework.Execution; | 20 | 19 | using QuantConnect.Algorithm.Framework.Portfolio; | 21 | 20 | using QuantConnect.Algorithm.Framework.Risk; | 22 | 21 | using QuantConnect.Algorithm.Framework.Selection; | 23 | 22 | using QuantConnect.Data; | 24 | 23 | using QuantConnect.Data.Custom; | 25 | | -using QuantConnect.Data.UniverseSelection; | 26 | 24 | using QuantConnect.Interfaces; | 27 | 25 | using QuantConnect.Securities.Forex; | 28 | 26 | using System; | 29 | 27 | using System.Collections.Generic; | 30 | 28 | using System.Linq; | | 29 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 31 | 30 |
| 32 | 31 | namespace QuantConnect.Algorithm.CSharp.Alphas | 33 | 32 | { | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/GasAndCrudeOilEnergyCorrelationAlpha.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 |
| 16 | 16 | using Accord.Math; | 17 | 17 | using Accord.Statistics; | 18 | | -using QuantConnect.Algorithm.Framework; | 19 | 18 | using QuantConnect.Algorithm.Framework.Alphas; | 20 | 19 | using QuantConnect.Algorithm.Framework.Execution; | 21 | 20 | using QuantConnect.Algorithm.Framework.Portfolio; | | 29 | 28 | using System; | 30 | 29 | using System.Collections.Generic; | 31 | 30 | using System.Linq; | | 31 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 32 | 32 |
| 33 | 33 | namespace QuantConnect.Algorithm.CSharp.Alphas | 34 | 34 | { | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/GlobalEquityMeanReversionIBSAlpha.cs +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | * limitations under the License. | 14 | 14 | */ | 15 | 15 |
| 16 | | -using QuantConnect.Algorithm.Framework; | 17 | 16 | using QuantConnect.Algorithm.Framework.Alphas; | 18 | 17 | using QuantConnect.Algorithm.Framework.Execution; | 19 | 18 | using QuantConnect.Algorithm.Framework.Portfolio; | 20 | 19 | using QuantConnect.Algorithm.Framework.Risk; | 21 | 20 | using QuantConnect.Algorithm.Framework.Selection; | 22 | 21 | using QuantConnect.Data; | 23 | | -using QuantConnect.Data.UniverseSelection; | 24 | 22 | using QuantConnect.Orders.Fees; | 25 | 23 | using System; | 26 | 24 | using System.Collections.Generic; | 27 | 25 | using System.Linq; | | 26 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 28 | 27 |
| 29 | 28 | namespace QuantConnect.Algorithm.CSharp.Alphas | 30 | 29 | { | 31 | 30 | /// <summary> | 32 | | - /// Equity indices exhibit mean reversion in daily returns. The Internal Bar Strength indicator (IBS), | | 31 | + /// Equity indices exhibit mean reversion in daily returns. The Internal Bar Strength indicator (IBS), | 33 | 32 | /// which relates the closing price of a security to its daily range can be used to identify overbought | 34 | 33 | /// and oversold securities. | 35 | 34 | /// | 36 | 35 | /// This alpha ranks 33 global equity ETFs on its IBS value the previous day and predicts for the following day | 37 | | - /// that the ETF with the highest IBS value will decrease in price, and the ETF with the lowest IBS value | | 36 | + /// that the ETF with the highest IBS value will decrease in price, and the ETF with the lowest IBS value | 38 | 37 | /// will increase in price. | 39 | 38 | /// | 40 | 39 | /// Source: Kakushadze, Zura, and Juan Andrés Serur. “4. Exchange-Traded Funds (ETFs).” 151 Trading Strategies, Palgrave Macmillan, 2018, pp. 90–91. | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/GreenblattMagicFormulaAlpha.cs +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | * limitations under the License. | 14 | 14 | */ | 15 | 15 |
| 16 | | -using QuantConnect.Algorithm.Framework; | 17 | 16 | using QuantConnect.Algorithm.Framework.Alphas; | 18 | 17 | using QuantConnect.Algorithm.Framework.Execution; | 19 | 18 | using QuantConnect.Algorithm.Framework.Portfolio; | | 28 | 27 | using System; | 29 | 28 | using System.Collections.Generic; | 30 | 29 | using System.Linq; | | 30 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 31 | 31 |
| 32 | 32 | namespace QuantConnect.Algorithm.CSharp.Alphas | 33 | 33 | { | 34 | 34 | /// <summary> | 35 | 35 | /// This alpha picks stocks according to Joel Greenblatt's Magic Formula. | 36 | 36 | /// First, each stock is ranked depending on the relative value of the ratio EV/EBITDA. For example, a stock | 37 | | - /// that has the lowest EV/EBITDA ratio in the security universe receives a score of one while a stock that has | | 37 | + /// that has the lowest EV/EBITDA ratio in the security universe receives a score of one while a stock that has | 38 | 38 | /// the tenth lowest EV/EBITDA score would be assigned 10 points. | 39 | 39 | /// | 40 | 40 | /// Then, each stock is ranked and given a score for the second valuation ratio, Return on Capital (ROC). | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/IntradayReversalCurrencyMarketsAlpha.cs +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | * limitations under the License. | 14 | 14 | */ | 15 | 15 |
| 16 | | -using QuantConnect.Algorithm.Framework; | 17 | 16 | using QuantConnect.Algorithm.Framework.Alphas; | 18 | 17 | using QuantConnect.Algorithm.Framework.Execution; | 19 | 18 | using QuantConnect.Algorithm.Framework.Portfolio; | | 26 | 25 | using System; | 27 | 26 | using System.Collections.Generic; | 28 | 27 | using System.Linq; | | 28 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 29 | 29 |
| 30 | 30 | namespace QuantConnect.Algorithm.CSharp.Alphas | 31 | 31 | { | 32 | 32 | /// <summary> | 33 | 33 | /// Reversal strategy that goes long when price crosses below SMA and Short when price crosses above SMA. | 34 | | - /// The trading strategy is implemented only between 10AM - 3PM (NY time). Research suggests this is due to | | 34 | + /// The trading strategy is implemented only between 10AM - 3PM (NY time). Research suggests this is due to | 35 | 35 | /// institutional trades during market hours which need hedging with the USD. Source paper: | 36 | 36 | /// LeBaron, Zhao: Intraday Foreign Exchange Reversals | 37 | 37 | /// http://people.brandeis.edu/~blebaron/wps/fxnyc.pdf | @@ -113,7 +113,7 @@ public override IEnumerable<Insight> Update(QCAlgorithmFramework algorithm, Slic | 113 | 113 | { | 114 | 114 | var price = kvp.Value.Price; | 115 | 115 |
| 116 | | - var direction = symbolData.IsUptrend(price) | | 116 | + var direction = symbolData.IsUptrend(price) | 117 | 117 | ? InsightDirection.Up | 118 | 118 | : InsightDirection.Down; | 119 | 119 |
| @@ -139,7 +139,7 @@ private bool ShouldEmitInsight(QCAlgorithmFramework algorithm, Symbol symbol) | 139 | 139 | var timeOfDay = algorithm.Time.TimeOfDay; | 140 | 140 |
| 141 | 141 | return algorithm.Securities[symbol].HasData && | 142 | | - timeOfDay >= TimeSpan.FromHours(10) && | | 142 | + timeOfDay >= TimeSpan.FromHours(10) && | 143 | 143 | timeOfDay <= TimeSpan.FromHours(15); | 144 | 144 | } | 145 | 145 |
| @@ -166,7 +166,7 @@ public SymbolData(QCAlgorithm algorithm, Symbol symbol, int periodSma, Resolutio | 166 | 166 | PreviousDirection = InsightDirection.Flat; | 167 | 167 | _priceSMA = algorithm.SMA(symbol, periodSma, resolution); | 168 | 168 | } | 169 | | - | | 169 | + | 170 | 170 | public bool IsUptrend(decimal price) | 171 | 171 | { | 172 | 172 | return _priceSMA.IsReady && price < Math.Round(_priceSMA * 1.001m, 6); | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/MeanReversionLunchBreakAlpha.cs +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | * limitations under the License. | 14 | 14 | */ | 15 | 15 |
| 16 | | -using QuantConnect.Algorithm.Framework; | 17 | 16 | using QuantConnect.Algorithm.Framework.Alphas; | 18 | 17 | using QuantConnect.Algorithm.Framework.Execution; | 19 | 18 | using QuantConnect.Algorithm.Framework.Portfolio; | | 26 | 25 | using System; | 27 | 26 | using System.Collections.Generic; | 28 | 27 | using System.Linq; | | 28 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 29 | 29 |
| 30 | 30 | namespace QuantConnect.Algorithm.CSharp.Alphas | 31 | 31 | { | 32 | 32 | /// <summary> | 33 | 33 | /// This alpha aims to capture the mean-reversion effect of ETFs during lunch-break by ranking 20 ETFs | 34 | | - /// on their return between the close of the previous day to 12:00 the day after and predicting mean-reversion | | 34 | + /// on their return between the close of the previous day to 12:00 the day after and predicting mean-reversion | 35 | 35 | /// in price during lunch-break. | 36 | 36 | /// | 37 | | - /// Source: Lunina, V. (June 2011). The Intraday Dynamics of Stock Returns and Trading Activity: Evidence from OMXS 30 (Master's Essay, Lund University). | | 37 | + /// Source: Lunina, V. (June 2011). The Intraday Dynamics of Stock Returns and Trading Activity: Evidence from OMXS 30 (Master's Essay, Lund University). | 38 | 38 | /// Retrieved from http://lup.lub.lu.se/luur/download?func=downloadFile&recordOId=1973850&fileOId=1973852 | 39 | 39 | /// | 40 | 40 | /// This alpha is part of the Benchmark Alpha Series created by QuantConnect which are open sourced so the community and client funds can see an example of an alpha. | @@ -78,8 +78,8 @@ orderby cf.DollarVolume descending | 78 | 78 | } | 79 | 79 |
| 80 | 80 | /// <summary> | 81 | | - /// Uses the price return between the close of previous day to 12:00 the day after to | 82 | | - /// predict mean-reversion of stock price during lunch break and creates direction prediction | | 81 | + /// Uses the price return between the close of previous day to 12:00 the day after to | | 82 | + /// predict mean-reversion of stock price during lunch break and creates direction prediction | 83 | 83 | /// for insights accordingly. | 84 | 84 | /// </summary> | 85 | 85 | private class MeanReversionLunchBreakAlphaModel : AlphaModel | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/RebalancingLeveragedETFAlpha.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | * limitations under the License. | 14 | 14 | */ | 15 | 15 |
| 16 | | -using QuantConnect.Algorithm.Framework; | 17 | 16 | using QuantConnect.Algorithm.Framework.Alphas; | 18 | 17 | using QuantConnect.Algorithm.Framework.Execution; | 19 | 18 | using QuantConnect.Algorithm.Framework.Portfolio; | | 24 | 23 | using System; | 25 | 24 | using System.Collections.Generic; | 26 | 25 | using System.Linq; | | 26 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 27 | 27 |
| 28 | 28 | namespace QuantConnect.Algorithm.CSharp.Alphas | 29 | 29 | { | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/ShareClassMeanReversionAlpha.cs +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | * limitations under the License. | 14 | 14 | */ | 15 | 15 |
| 16 | | -using QuantConnect.Algorithm.Framework; | 17 | 16 | using QuantConnect.Algorithm.Framework.Alphas; | 18 | 17 | using QuantConnect.Algorithm.Framework.Execution; | 19 | 18 | using QuantConnect.Algorithm.Framework.Portfolio; | 20 | 19 | using QuantConnect.Algorithm.Framework.Risk; | 21 | 20 | using QuantConnect.Algorithm.Framework.Selection; | 22 | 21 | using QuantConnect.Data; | 23 | | -using QuantConnect.Data.UniverseSelection; | 24 | 22 | using QuantConnect.Indicators; | 25 | 23 | using QuantConnect.Orders.Fees; | 26 | 24 | using System; | 27 | 25 | using System.Collections.Generic; | 28 | 26 | using System.Linq; | | 27 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 29 | 28 |
| 30 | 29 | namespace QuantConnect.Algorithm.CSharp.Alphas | 31 | 30 | { | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/SykesShortMicroCapAlpha.cs +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | * limitations under the License. | 14 | 14 | */ | 15 | 15 |
| 16 | | -using QuantConnect.Algorithm.Framework; | 17 | 16 | using QuantConnect.Algorithm.Framework.Alphas; | 18 | 17 | using QuantConnect.Algorithm.Framework.Execution; | 19 | 18 | using QuantConnect.Algorithm.Framework.Portfolio; | | 25 | 24 | using System; | 26 | 25 | using System.Collections.Generic; | 27 | 26 | using System.Linq; | | 27 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 28 | 28 |
| 29 | 29 | namespace QuantConnect.Algorithm.CSharp.Alphas | 30 | 30 | { | |
Collapse file Copy file name to clipboardExpand all lines: Algorithm.CSharp/Alphas/TriangleExchangeRateArbitrageAlpha.cs +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 | * limitations under the License. | 14 | 14 | */ | 15 | 15 |
| 16 | | -using QuantConnect.Algorithm.Framework; | 17 | 16 | using QuantConnect.Algorithm.Framework.Alphas; | 18 | 17 | using QuantConnect.Algorithm.Framework.Execution; | 19 | 18 | using QuantConnect.Algorithm.Framework.Portfolio; | 20 | 19 | using QuantConnect.Algorithm.Framework.Risk; | 21 | 20 | using QuantConnect.Algorithm.Framework.Selection; | 22 | 21 | using QuantConnect.Data; | 23 | | -using QuantConnect.Data.UniverseSelection; | 24 | 22 | using QuantConnect.Orders.Fees; | 25 | 23 | using System; | 26 | 24 | using System.Collections.Generic; | 27 | 25 | using System.Linq; | | 26 | +using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; | 28 | 27 |
| 29 | 28 | namespace QuantConnect.Algorithm.CSharp.Alphas | 30 | 29 | { | |
|