Overall Statistics
Total Trades
10
Average Win
0.67%
Average Loss
-0.01%
Compounding Annual Return
23.033%
Drawdown
1.300%
Expectancy
44.200
Net Profit
1.701%
Sharpe Ratio
5.534
Probabilistic Sharpe Ratio
91.418%
Loss Rate
40%
Win Rate
60%
Profit-Loss Ratio
74.33
Alpha
0.155
Beta
0.118
Annual Standard Deviation
0.034
Annual Variance
0.001
Information Ratio
-1.022
Tracking Error
0.073
Treynor Ratio
1.571
Total Fees
$0.00
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Indicators")
AddReference("QuantConnect.Common")

class WarmupHistoryAlgorithm(QCAlgorithm):

    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(2014,5,1)   #Set Start Date
        self.SetEndDate(2014,5,30)     #Set End Date
        self.SetCash(100000)          #Set Strategy Cash
        # Find more symbols here: http://quantconnect.com/data
        forex = self.AddForex("EURUSD", Resolution.Minute, Market.FXCM, leverage = 30) #Market.FXCM
        # forex = self.AddForex("EURUSD", Resolution.Second)
        self.SetBrokerageModel(BrokerageName.OandaBrokerage) #InteractiveBrokersBrokerage, OandaBrokerage, Bitfinex, GDAX or FxcmBrokerage

        self.window = RollingWindow[QuoteBar](20) #https://www.quantconnect.com/docs/algorithm-reference/handling-data#Handling-Data-QuoteBars
    def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.'''
        if data.ContainsKey("EURUSD"):
            self.window.Add(data["EURUSD"])
        if not self.window.IsReady: return

        epsilon = 0.0001
        currBar = self.window[0]                     # Current bar had index zero.
        pastBar = self.window[19]                     # Past bar has index one.
        delta = epsilon * 2000
        if  currBar.Open - pastBar.Open < delta:
            self.current = self.Time
            # start = self.Time
            self.Debug(currBar.Open - pastBar.Open)#, str(self.current)) # self.Log (only in log files)
            self.SetHoldings("EURUSD", -1)
        if (self.Time - self.current).total_seconds() >= 60*60: # loss
            self.Debug('loss') #, currBar.Open - pastBar.Open) #, (self.Time - self.current).total_seconds())
            self.SetHoldings("EURUSD", 1) #self.Liquidate()
        if self.Portfolio["EURUSD"].UnrealizedProfit > 1000:
            self.Debug('win') #, currBar.Open - pastBar.Open) #, (self.Time - self.current).total_seconds())
            self.SetHoldings("EURUSD", 1) #self.Liquidate()