| Overall Statistics |
|
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 3053.437% Drawdown 3.000% Expectancy 0 Net Profit 1.908% Sharpe Ratio 12.298 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.559 Beta 113.013 Annual Standard Deviation 0.13 Annual Variance 0.017 Information Ratio 12.247 Tracking Error 0.13 Treynor Ratio 0.014 Total Fees $298.35 |
import numpy as np
### <summary>
### Basic template algorithm simply initializes the date range and cash. This is a skeleton
### framework you can use for designing an algorithm.
### </summary>
class BasicTemplateAlgorithm(QCAlgorithm):
'''Basic template algorithm simply initializes the date range and cash'''
def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.SetStartDate(2018,6,1) #Set Start Date
self.SetEndDate(2018,6,2) #Set End Date
self.SetCash(100000) #Set Strategy Cash
self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)
self.AddCrypto("BTCUSD", Resolution.Minute)
self.period = 20
self.SetWarmUp(2000)
# ...other initialization...
consolidator = TradeBarConsolidator(TimeSpan.FromMinutes(15))
consolidator.DataConsolidated += self.OnDataConsolidated
self.SubscriptionManager.AddConsolidator("BTCUSD", consolidator)
self._atr = AverageTrueRange("BTCUSD", self.period)
self.RegisterIndicator("BTCUSD", self._atr, consolidator)
self.PlotIndicator("ATR", self._atr)
def OnDataConsolidated(self, sender, bar):
self.Debug(str(self.Time) + " > New Bar!")
self.Debug(str(bar.High))
self.Debug(str(bar.Low))
self.Debug(str(bar.Open))
self.Debug(str(bar.Close))
if not self.Portfolio.Invested:
self.SetHoldings("BTCUSD", 1)
def OnData(self, data):
pass
#if self._atr.IsReady:
#self.Plot("Indicators", self._atr);