Overall Statistics Total Trades 4 Average Win 0% Average Loss -5.58% Compounding Annual Return 7.145% Drawdown 8.700% Expectancy -1 Net Profit 7.186% Sharpe Ratio 0.542 Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.14 Beta 12.543 Annual Standard Deviation 0.114 Annual Variance 0.013 Information Ratio 0.402 Tracking Error 0.114 Treynor Ratio 0.005 Total Fees \$0.00
```import numpy as np
import decimal
### <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(2016,1,1)  #Set Start Date
self.SetEndDate(2017,1,1)    #Set End Date
self.SetCash(100000)           #Set Strategy Cash

self.CommodityChannelIndex = self.CCI("EURUSD", 8, MovingAverageType.Simple, Resolution.Minute)

#self.Debug("numpy test >>> print numpy.pi: " + str(np.pi)) #testing that Numpy module works

def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.

Arguments:
data: Slice object keyed by symbol containing the stock data
'''

return

cci = self.CommodityChannelIndex.Current.Value
current = data["EURUSD"].Close
if not self.Portfolio.Invested:
if 26 <= cci <= 36 and self.Portfolio.Invested <= 0:
twoPercent = decimal.Decimal(0.97)
#Use 100% of the portfolio to buy curpair
#self.Debug("
self.SetHoldings("EURUSD", -1)
#Get the current price of curpair
stopPrice = self.Securities["EURUSD"].Price * twoPercent
#Sell all of the curpair if the price drops below stopprice
self.StopMarketOrder("EURUSD", self.Portfolio["EURUSD"].Quantity, stopPrice)
if -26 <= cci <= -36 and self.Portfolio.Invested <= 0:
twoPercent = decimal.Decimal(1.05)
#self.Debug("
self.SetHoldings("EURUSD", 1)
stopPrice = self.Securities["EURUSD"].Price * twoPercent
self.StopMarketOrder("EURUSD", -self.Portfolio["EURUSD"].Quantity, stopPrice)
if self.Portfolio.Invested:
if self.Portfolio["EURUSD"].IsLong:
if 25 <= cci <= 25:
#self.Debug("
self.Liquidate("EURUSD")
#self.Debug("Exited Long Position, CCI back to normal ")
if self.Portfolio["EURUSD"].IsShort:
if -25 <= cci <= -25:
#self.Debug("
self.Liquidate("EURUSD")
#self.Debug("exited short position, cci back to normal")

def OnEndOfDay(self):
self.Plot("Indicators", "CCI", self.CommodityChannelIndex.Current.Value)```