f8b79b8d6b
Regression Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Address JB comment * Remove repeated fields in BaseRenkoBar - Add new unit test to all indicators that inherit from IndicatorBase<TradeBar>. This test asserts the indicators can receive RenkoBar's as input * Add Regression test and improve unit tests - Change `Volume` property from `RenkoBar.cs` since RenkoBar's don't have Volume. Now it throws an error when accessed * Address required changes * Add Python regression test and enhance unit tests * Enhance unit and regression tests * Assert indicator current value at the end * Allow more indicators to use Renko/VolumeRenkoBar
61 lines
2.6 KiB
Python
61 lines
2.6 KiB
Python
# 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.
|
|
|
|
from AlgorithmImports import *
|
|
|
|
### <summary>
|
|
### Regrssion algorithm to assert we can update indicators that inherit from IndicatorBase<TradeBar> with RenkoBar's
|
|
### </summary>
|
|
### <meta name="tag" content="renko" />
|
|
### <meta name="tag" content="indicators" />
|
|
### <meta name="tag" content="using data" />
|
|
### <meta name="tag" content="consolidating data" />
|
|
class IndicatorWithRenkoBarsRegressionAlgorithm(QCAlgorithm):
|
|
def Initialize(self):
|
|
self.SetStartDate(2013, 10, 7)
|
|
self.SetEndDate(2013, 10, 9)
|
|
|
|
self.AddEquity("SPY")
|
|
self.AddEquity("AIG")
|
|
|
|
spyRenkoConsolidator = RenkoConsolidator(0.1)
|
|
spyRenkoConsolidator.DataConsolidated += self.OnSPYDataConsolidated
|
|
|
|
aigRenkoConsolidator = RenkoConsolidator(0.05)
|
|
aigRenkoConsolidator.DataConsolidated += self.OnAIGDataConsolidated
|
|
|
|
self.SubscriptionManager.AddConsolidator("SPY", spyRenkoConsolidator)
|
|
self.SubscriptionManager.AddConsolidator("AIG", aigRenkoConsolidator)
|
|
|
|
self.mi = MassIndex("MassIndex", 9, 25)
|
|
self.wasi = WilderAccumulativeSwingIndex("WilderAccumulativeSwingIndex", 8)
|
|
self.wsi = WilderSwingIndex("WilderSwingIndex", 8)
|
|
self.b = Beta("Beta", 3, "AIG", "SPY")
|
|
self.indicators = [self.mi, self.wasi, self.wsi, self.b]
|
|
|
|
def OnSPYDataConsolidated(self, sender, renkoBar):
|
|
self.mi.Update(renkoBar)
|
|
self.wasi.Update(renkoBar)
|
|
self.wsi.Update(renkoBar)
|
|
self.b.Update(renkoBar)
|
|
|
|
def OnAIGDataConsolidated(self, sender, renkoBar):
|
|
self.b.Update(renkoBar)
|
|
|
|
def OnEndOfAlgorithm(self):
|
|
for indicator in self.indicators:
|
|
if not indicator.IsReady:
|
|
raise Exception(f"{indicator.Name} indicator should be ready")
|
|
elif indicator.Current.Value == 0:
|
|
raise Exception(f"The current value of the {indicator.Name} indicator should be different than zero")
|