Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
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
$0.00
# CryptoVolatilityTap (v4, ETHUSD, Minute, Py)
# Tap crypto volatility spikes

from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Indicators")
AddReference("QuantConnect.Common")

from System import *
from QuantConnect import *
from QuantConnect.Data import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Data.Consolidators import *
from datetime import datetime
import decimal as d
import numpy as np

class CVTap(QCAlgorithm):

    def Initialize(self):
        
        self.SetStartDate(2017,11,1) #Set Start Date
        self.SetEndDate(2017,11,14) #Set End Date
        self.SetCash(10000) #Set Strategy Cash
        
        self.fxPair = "EURUSD"
        
        # Add EURUSD
        self.AddForex(self.fxPair, Resolution.Minute)

        # Create consolidator for 30 minutes
        consThirtyMin = QuoteBarConsolidator(30)
        consThirtyMin.DataConsolidated += self.OnDataConsolidated
        
        self.SubscriptionManager.AddConsolidator(self.fxPair, consThirtyMin)

        self.bb30 = BollingerBands("30minBB", 20,2,MovingAverageType.Simple)
        
        # Inititalize rolling window which stores to store upper bollinger band indicator values
        self.bbUpperRollingWindow = RollingWindow[float](3)
        
    def OnDataConsolidated(self, sender, bar):
        # Update bb30 indicator
        self.bb30.Update(bar.EndTime, bar.Close)
        
        # Add to rolling window
        self.bbUpperRollingWindow.Add(self.bb30.Current.Value)

    def OnData(self, data):
        # Return if rolling window is not ready
        if not self.bbUpperRollingWindow.IsReady: return
    
        self.Log("upper rolling window : " + str(self.bbUpperRollingWindow[0]))