Overall Statistics |
Total Orders 6 Average Win 0.63% Average Loss -0.05% Compounding Annual Return 6.842% Drawdown 0.300% Expectancy 6.313 Net Profit 1.143% Sharpe Ratio 3.074 Sortino Ratio 3.963 Probabilistic Sharpe Ratio 90.341% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 13.63 Alpha 0.039 Beta -0.027 Annual Standard Deviation 0.012 Annual Variance 0 Information Ratio -0.171 Tracking Error 0.107 Treynor Ratio -1.397 Total Fees $9.12 Estimated Strategy Capacity $740000000.00 Lowest Capacity Asset MGC VOFJUCDY9XNH Portfolio Turnover 0.65% |
#region imports using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Globalization; using System.Drawing; using QuantConnect; using QuantConnect.Algorithm.Framework; using QuantConnect.Algorithm.Framework.Selection; using QuantConnect.Algorithm.Framework.Alphas; using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Algorithm.Framework.Execution; using QuantConnect.Algorithm.Framework.Risk; using QuantConnect.Algorithm.Selection; using QuantConnect.Parameters; using QuantConnect.Benchmarks; using QuantConnect.Brokerages; using QuantConnect.Util; using QuantConnect.Interfaces; using QuantConnect.Algorithm; using QuantConnect.Indicators; using QuantConnect.Data; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Custom; using QuantConnect.DataSource; using QuantConnect.Data.Fundamental; using QuantConnect.Data.Market; using QuantConnect.Data.UniverseSelection; using QuantConnect.Notifications; using QuantConnect.Orders; using QuantConnect.Orders.Fees; using QuantConnect.Orders.Fills; using QuantConnect.Orders.Slippage; using QuantConnect.Scheduling; using QuantConnect.Securities; using QuantConnect.Securities.Equity; using QuantConnect.Securities.Future; using QuantConnect.Securities.Option; using QuantConnect.Securities.Forex; using QuantConnect.Securities.Crypto; using QuantConnect.Securities.Interfaces; using QuantConnect.Storage; using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm; #endregion using QuantConnect.DataSource; namespace QuantConnect { public class USFuturesDataAlgorithm : QCAlgorithm { private Future _miniGold; private Future _microGold; private Dictionary<Symbol, FuturesContract?> _contract = new Dictionary<Symbol, FuturesContract?>(); public override void Initialize() { SetStartDate(2013, 12, 20); SetEndDate(2014, 2, 20); SetCash(1000000); UniverseSettings.Asynchronous = true; _miniGold = AddFuture(Futures.Metals.Gold); _miniGold.SetFilter(0, 90); _contract.Add(_miniGold.Symbol, null); _microGold = AddFuture(Futures.Metals.MicroGold); _microGold.SetFilter(0, 90); _contract.Add(_microGold.Symbol, null); } public override void OnData(Slice slice) { foreach (var kvp in slice.FutureChains) { var symbol = kvp.Key; var chain = kvp.Value; if (_contract.ContainsKey(symbol)) { // Select the contract with the greatest open interest var mostLiquidContract = chain.OrderBy(x => x.OpenInterest).Last(); if (_contract[symbol] == null || mostLiquidContract.Symbol != _contract[symbol].Symbol) { if (_contract[symbol] != null) { Liquidate(_contract[symbol].Symbol); } _contract[symbol] = mostLiquidContract; if (symbol == _miniGold.Symbol) { MarketOrder(_contract[symbol].Symbol, 1); } else if (symbol == _microGold.Symbol) { MarketOrder(_contract[symbol].Symbol, -1); } } } } } public override void OnSecuritiesChanged(SecurityChanges changes) { foreach (var security in changes.AddedSecurities) { // Historical data var history = History(security.Symbol, 100, Resolution.Minute); Debug($"We got {history.Count()} from our history request for {security.Symbol}"); } } } }