| Overall Statistics |
|
Total Trades 659 Average Win 0.24% Average Loss -0.25% Compounding Annual Return -1.258% Drawdown 8.200% Expectancy -0.061 Net Profit -4.957% Sharpe Ratio -0.493 Loss Rate 52% Win Rate 48% Profit-Loss Ratio 0.96 Alpha -0.008 Beta -0.007 Annual Standard Deviation 0.018 Annual Variance 0 Information Ratio -0.813 Tracking Error 0.105 Treynor Ratio 1.165 Total Fees $0.00 |
import decimal as d
class BasicTemplateAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2013,10,07)
self.SetEndDate(2017,10,11)
self.SetCash(5000)
self.pair = self.AddForex("EURUSD").Symbol
def OnData(self, data):
if not self.Portfolio.Invested:
price = data[self.pair].Close
onePercent = d.Decimal(1.01)
self.Buy(self.pair, 1000)
self.LimitOrder(self.pair, -1000, price * onePercent)
self.StopMarketOrder(self.pair, -1000, price / onePercent)
def OnOrderEvent(self, orderEvent):
order = self.Transactions.GetOrderById(orderEvent.OrderId)
if order.Status == OrderStatus.Filled:
if order.Type == OrderType.Limit or order.Type == OrderType.Limit:
self.Transactions.CancelOpenOrders(order.Symbol)
if order.Status == OrderStatus.Canceled:
self.Log(str(orderEvent))