| Overall Statistics |
|
Total Trades 30 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $400000.00 |
class BasicTemplateAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2017, 7, 17)
self.SetEndDate(2017, 7, 17)
self.SetCash(100000)
self.resolution = Resolution.Minute
self.pair = self.AddForex("AUDUSD").Symbol
def OnData(self, data):
security = self.Securities[self.pair]
invested = security.Invested
# if not invested:
price = data[self.pair].Close
weight = 1
direction = 1
quantity = int(self.CalculateOrderQuantity(self.pair, weight))
self.Buy(self.pair, quantity)
self.Debug("MarketOrder: " + str(quantity))
price = self.Securities[self.pair].Close
onePercent = 0.001
# inc = security.PriceVariationModel.GetMinimumPriceVariation(security)
inc = 0.0001
priceProfit = Math.Round(price * (1 + direction * onePercent) / inc) * inc
priceLoss = Math.Round(price * (1 - direction * onePercent) / inc) * inc
# take profit
self.LimitOrder(self.pair, -quantity, priceProfit)
self.Debug("LimitOrder: " + str(-quantity) + ", " + str(priceProfit))
# stop loss
self.StopMarketOrder(self.pair, -quantity, priceLoss)
self.Debug("StopMarketOrder: " + str(-quantity) + ", " + str(priceLoss))
def OnOrderEvent(self, orderEvent):
order = self.Transactions.GetOrderById(orderEvent.OrderId)
self.Debug(str(order))
if order.Status == OrderStatus.Filled:
if order.Type == OrderType.Limit or order.Type == OrderType.StopMarket:
self.Transactions.CancelOpenOrders(order.Symbol)