Overall Statistics
Total Trades
2251
Average Win
0.19%
Average Loss
-0.08%
Compounding Annual Return
-3.806%
Drawdown
11.500%
Expectancy
-0.087
Net Profit
-7.486%
Sharpe Ratio
-0.827
Loss Rate
73%
Win Rate
27%
Profit-Loss Ratio
2.38
Alpha
-0.079
Beta
3.014
Annual Standard Deviation
0.037
Annual Variance
0.001
Information Ratio
-1.263
Tracking Error
0.037
Treynor Ratio
-0.01
Total Fees
$0.00
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(2015,1,1)  #Set Start Date
        self.SetEndDate(2017,1,1)    #Set End Date
        self.SetCash(100000)           #Set Strategy Cash
        
        self.forex = self.AddForex("EURUSD", Resolution.Hour, Market.Oanda)
        self.CommodityChannelIndex = self.CCI("EURUSD",20,MovingAverageType.Simple,Resolution.Hour)
        #self.Strength = self.RSI("EURUSD",3,MovingAverageType.Simple,Resolution.Minute)
        self.Debug("numpy test >>> print numpy.pi: " + str(np.pi))

    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
        '''
        
        if not self.CommodityChannelIndex.IsReady: 
            return
        
        cci = self.CommodityChannelIndex.Current.Value
        current = data["EURUSD"].Close
        if not self.Portfolio.Invested:
            
            if cci > 15.0:
                self.Debug("CCI is greater than 15")
                self.MarketOrder("EURUSD", 40000) 
                
            if cci < -15.0:
                self.Debug("CCI is less than -50")
                self.MarketOrder("EURUSD", -40000)
              
        if self.Portfolio.Invested:       
            if self.Portfolio["EURUSD"].IsLong:
                if cci < 15:
                    self.Liquidate("EURUSD")
                   
            if self.Portfolio["EURUSD"].IsShort:
                if cci > -15.0:
                    self.Liquidate("EURUSD")
                
        
    def OnEndOfDay(self):
        self.Plot("Indicators", "CCI", self.CommodityChannelIndex.Current.Value)