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,9,1) #Set Start Date
        self.SetEndDate(2017,11,14) #Set End Date
        self.SetCash(1000) #Set Strategy Cash
        
        # define crypto we want to trade on
        # ETHUSD or LTCUSD or BTCUSD
        self.target_crypto = "ETHUSD"
        
        # Set brokerage to GDAX for cryptos
        self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)
        
        # Add crypto at minute resolution
        self.AddCrypto(self.target_crypto, Resolution.Minute)
        self.SetBenchmark(self.target_crypto)
        
        # create consolidator for 15 minute
        consFiveMin = TradeBarConsolidator(5)
        consFiveMin.DataConsolidated += self.OnDataConsolidated
        self.SubscriptionManager.AddConsolidator(self.target_crypto, consFiveMin)
        
        # Define exponential moving average at 1 min resolution
        self.ema_very_fast_one_min = self.EMA(self.target_crypto, 10)
        
        # Define exponential moving average at 5 min resolution
        self.ema_very_fast_five_min = ExponentialMovingAverage("5minEMA", 2);
    
    def OnDataConsolidated(self, sender, bar):
        self.ema_very_fast_five_min.Update(bar.EndTime, bar.Close);
        self.Debug(str(self.Time) + " > New 5 Min Bar!")
        self.Plot("EMA", self.ema_very_fast_one_min)
        self.Plot("EMA", self.ema_very_fast_five_min)
    
    
    def OnData(self, data):
        pass #self.Debug(str(self.Time) + " > New 1 Min Bar!")