| Overall Statistics |
|
Total Trades 438 Average Win 0.55% Average Loss -0.03% Compounding Annual Return 20.587% Drawdown 8.900% Expectancy 3.624 Net Profit 22.376% Sharpe Ratio 1.946 Probabilistic Sharpe Ratio 82.326% Loss Rate 78% Win Rate 22% Profit-Loss Ratio 19.67 Alpha 0.168 Beta -0.006 Annual Standard Deviation 0.086 Annual Variance 0.007 Information Ratio 0.419 Tracking Error 0.134 Treynor Ratio -26.314 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(2015,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()