Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
0%
Compounding Annual Return
49.437%
Drawdown
0.200%
Expectancy
0
Net Profit
0%
Sharpe Ratio
11.695
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.245
Beta
-0.135
Annual Standard Deviation
0.02
Annual Variance
0
Information Ratio
4.008
Tracking Error
0.033
Treynor Ratio
-1.716
Total Fees
$0.00
import decimal as d

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2017,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.StopMarket:
                self.Transactions.CancelOpenOrders(order.Symbol)
                
        if order.Status == OrderStatus.Canceled:
            self.Log(str(orderEvent))