Overall Statistics |
Total Trades 1672 Average Win 1.35% Average Loss -1.17% Compounding Annual Return 30.280% Drawdown 25.200% Expectancy 0.093 Net Profit 102.654% Sharpe Ratio 0.807 Loss Rate 49% Win Rate 51% Profit-Loss Ratio 1.15 Alpha 0.264 Beta -1.596 Annual Standard Deviation 0.331 Annual Variance 0.11 Information Ratio 0.713 Tracking Error 0.377 Treynor Ratio -0.167 Total Fees $0.00 |
using System; using System.Collections.Generic; using System.Linq; using NodaTime; using QuantConnect.Brokerages; namespace QuantConnect.Algorithm.CSharp.DateTimeEffectAlgo { public class DateTimeEffectAlgo : QCAlgorithm { /* +-------------------------------------------------+ * |Algorithm Control Panel | * +-------------------------------------------------+*/ private readonly string[] _pairs = {"EURUSD", "USDJPY"}; private readonly decimal _leverage = 10m; private readonly decimal _exposure = 0.8m; /* +-------------------------------------------------+*/ private decimal _shareByPair; private readonly List<Symbol> _symbols = new List<Symbol>(); public override void Initialize() { SetStartDate(year: 2015, month: 01, day: 01); //Set Start Date SetEndDate(year: 2017, month: 09, day: 01); //Set End Date SetCash(startingCash: 25000); //Set Strategy Cash SetBrokerageModel(BrokerageName.OandaBrokerage); _shareByPair = (_leverage *_exposure ) / _pairs.Length; // Find more symbols here: http://quantconnect.com/data foreach (var pair in _pairs) { _symbols.Add(AddForex(pair, Resolution.Minute, "OANDA", leverage: _leverage).Symbol); if (pair == "EURUSD") { SetBenchmark(_symbols.Last()); } } // EURUSD: Short at GMT 09:15 am, do this on Wednesday, Thursday and Friday... Schedule.On(DateRules.Every(DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday), TimeRules.At(hour: 9, minute: 15, timeZone: DateTimeZone.Utc), () => { SetHoldings("EURUSD", -6); }); // ... close after 5 hours Schedule.On(DateRules.EveryDay(), TimeRules.At(14, 15, DateTimeZone.Utc), () => { Liquidate("EURUSD"); }); // USDJPY: Short at GMT 00:15 am, do this all weekdays... Schedule.On(DateRules.Every(DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday), TimeRules.At(hour: 0, minute: 15, timeZone: DateTimeZone.Utc), () => { SetHoldings("USDJPY", -4); }); // and close after 5 hours Schedule.On(DateRules.EveryDay(), TimeRules.At(5, 15, DateTimeZone.Utc), () => { Liquidate("UJPY"); }); } } }