Overall Statistics |
Total Trades 8 Average Win 28.58% Average Loss 0% Compounding Annual Return 139.659% 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 |
namespace QuantConnect.Algorithm.CSharp { public class TradingTechnologiesBrokerageExampleAlgorithm : QCAlgorithm { private Future _continuousContract; private Security _currentContract; public override void Initialize() { SetStartDate(2021, 1, 1); SetCash(100000); SetBrokerageModel(BrokerageName.TradingTechnologies, AccountType.Margin); _continuousContract = AddFuture(Futures.Indices.SP500EMini, Resolution.Minute, dataNormalizationMode: DataNormalizationMode.BackwardsRatio, dataMappingMode: DataMappingMode.LastTradingDay, contractDepthOffset: 0 ); // Set default order properties DefaultOrderProperties.TimeInForce = TimeInForce.Day; } private decimal GetTargetPrice(Security contract, decimal factor) { var targetPrice = contract.Price * factor; var inversePriceVariation = 1 / contract.SymbolProperties.MinimumPriceVariation; return Math.Round(targetPrice * inversePriceVariation)/inversePriceVariation; } public override void OnData(Slice data) { if (!Portfolio.Invested) { _currentContract = Securities[_continuousContract.Mapped]; // Place an order with the default order properties MarketOrder(_currentContract.Symbol, 1); // Place an order with new order properties var orderProperties = new OrderProperties { TimeInForce = TimeInForce.GoodTilCanceled }; var limitPrice = GetTargetPrice(_currentContract, 0.9m); var ticket = LimitOrder(_currentContract.Symbol, 1, limitPrice, orderProperties: orderProperties); // Update the order var orderFields = new UpdateOrderFields { Quantity = 2, LimitPrice = GetTargetPrice(_currentContract, 1.05m), Tag = "Informative order tag" }; var response = ticket.Update(orderFields); if (!LiveMode && response.IsSuccess) { Debug("Order updated successfully"); } } else if (_currentContract != null && _currentContract.Symbol != _continuousContract.Mapped) { Log($"{Time} - rolling position from {_currentContract.Symbol} to {_continuousContract.Mapped}"); var currentPositionSize = _currentContract.Holdings.Quantity; Liquidate(_currentContract.Symbol); MarketOrder(_continuousContract.Mapped, currentPositionSize); _currentContract = Securities[_continuousContract.Mapped]; } } } }