Overall Statistics |
Total Trades 8 Average Win 28.58% Average Loss 0% Compounding Annual Return 139.661% Drawdown 24.600% Expectancy 0 Net Profit 125.612% Sharpe Ratio 2.247 Probabilistic Sharpe Ratio 73.150% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0.461 Annual Variance 0.213 Information Ratio 2.247 Tracking Error 0.461 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset ES XUERCWA6EWAP |
class TradingTechnologiesBrokerageExampleAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) self.SetCash(100000) self.SetBrokerageModel(BrokerageName.TradingTechnologies, AccountType.Margin) self.continuous_contract = self.AddFuture(Futures.Indices.SP500EMini, Resolution.Minute, dataNormalizationMode = DataNormalizationMode.BackwardsRatio, dataMappingMode = DataMappingMode.LastTradingDay, contractDepthOffset = 0) self.current_contract = None # Set default order properties self.DefaultOrderProperties.TimeInForce = TimeInForce.Day def get_target_price(self, contract, factor): target_price = contract.Price * factor inverse_price_variation = 1 / contract.SymbolProperties.MinimumPriceVariation return round(target_price * inverse_price_variation)/inverse_price_variation def OnData(self, data): if not self.Portfolio.Invested: self.current_contract = self.Securities[self.continuous_contract.Mapped] # Place an order with the default order properties self.MarketOrder(self.current_contract.Symbol, 1) # Place an order with new order properties order_properties = OrderProperties() order_properties.TimeInForce = TimeInForce.GoodTilCanceled limit_price = self.get_target_price(self.current_contract, 0.9) ticket = self.LimitOrder(self.current_contract.Symbol, 1, limit_price, orderProperties = order_properties) # Update the order update_fields = UpdateOrderFields() update_fields.Quantity = 2 update_fields.LimitPrice = self.get_target_price(self.current_contract, 1.05) update_fields.Tag = "Informative order tag" response = ticket.Update(update_fields) if not self.LiveMode and response.IsSuccess: self.Debug("Order updated successfully") # Rollover to the next contract elif self.current_contract is not None and self.current_contract.Symbol != self.continuous_contract.Mapped: self.Log(f"{self.Time} - rolling position from {self.current_contract.Symbol} to {self.continuous_contract.Mapped}") current_position_size = self.current_contract.Holdings.Quantity self.Liquidate(self.current_contract.Symbol) self.MarketOrder(self.continuous_contract.Mapped, current_position_size) self.current_contract = self.Securities[self.continuous_contract.Mapped]