| Overall Statistics |
|
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 6985.446% Drawdown 22.500% Expectancy 0 Net Profit 108.631% Sharpe Ratio 23.75 Probabilistic Sharpe Ratio 92.928% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 18.204 Beta -2.235 Annual Standard Deviation 0.761 Annual Variance 0.578 Information Ratio 22.555 Tracking Error 0.798 Treynor Ratio -8.081 Total Fees $160.95 Estimated Strategy Capacity $140000000.00 Lowest Capacity Asset GC VOFJUCDY9XNH |
# Boot Camp (#1)
from AlgorithmImports import *
from math import floor
class BasicTemplateFuturesAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2013, 12, 20)
self.SetEndDate(2014, 2, 20)
self.SetCash(1000000)
self.gold = self.AddFuture(Futures.Metals.Gold)
self.gold.SetFilter(0, 90)
#1. Widen the free portfolio percentage to 30% to avoid margin calls for futures
self.Settings.FreePortfolioValuePercentage = 0.30
def OnMarginCallWarning(self):
self.Error("You received a margin call warning..")
def OnData(self, slice):
for chain in slice.FutureChains:
self.popularContracts = [contract for contract in chain.Value if contract.OpenInterest > 1000]
if len(self.popularContracts) == 0:
continue
sortedByOIContracts = sorted(self.popularContracts, key=lambda k : k.OpenInterest, reverse=True)
self.liquidContract = sortedByOIContracts[0]
if not self.Portfolio.Invested:
#2. Delete the old code for manually calculating the position size (lines 30-33)
#3. Replace the manually calculated math above with
# the SetHoldings function to automatically calculate your position size
self.SetHoldings(self.liquidContract.Symbol, 1)