Overall Statistics |
Total Trades 0 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 -2.189 Tracking Error 0.723 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 |
using QuantConnect.Securities; namespace QuantConnect { public partial class Base ///ONDATA { public class Alpha_LTC_UP : AlphaModel { private readonly Symbol _symbol; private string SYMBOL = "LTCUSD" ; public Alpha_LTC_UP(Symbol symbol) { _symbol = symbol; } public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice data) { var dat_ = from LTC_MINUTE in DATA_LTC_MINUTE.Values from LTC_MINUTE_Q in DATA_LTC_MINUTE_Q.Values select new {LTC_MINUTE, LTC_MINUTE_Q} ; foreach (var d_ in dat_) { if (d_.LTC_MINUTE.Symbol.Equals(SYMBOL) && d_.LTC_MINUTE_Q.Symbol.Equals(SYMBOL)) { if ( d_.LTC_MINUTE.BQIsReady && d_.LTC_MINUTE_Q.BQIsReady && d_.LTC_MINUTE.WasJustUpdated(algorithm.UtcTime) && d_.LTC_MINUTE_Q.WasJustUpdated(algorithm.UtcTime) ) { if (d_.LTC_MINUTE_Q.B[0].Ask.Low < 0) { algorithm.Debug("LTC neg Ask low price : " + d_.LTC_MINUTE_Q.B[0].Ask.Low + " | " + "Time : " + d_.LTC_MINUTE_Q.B[0].Time); yield break; } } } } } } } }
using QuantConnect.Securities; namespace QuantConnect { public partial class Base ///ONDATA { public static decimal Quantity_to_hold_BTC = 0; public static bool Hold_BTC = false; public static decimal high_BTC = 0; public static decimal high_true_BTC = 0; public class Alpha_BTC_UP : AlphaModel { private readonly Symbol _symbol; private string SYMBOL = "BTCUSD" ; public Alpha_BTC_UP(Symbol symbol) { _symbol = symbol; } public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice data) { var dat_ = from BTC_MINUTE in DATA_BTC_MINUTE.Values from BTC_MINUTE_Q in DATA_BTC_MINUTE_Q.Values select new {BTC_MINUTE, BTC_MINUTE_Q} ; foreach (var d_ in dat_) { if (d_.BTC_MINUTE.Symbol.Equals(SYMBOL) && d_.BTC_MINUTE_Q.Symbol.Equals(SYMBOL)) { if ( d_.BTC_MINUTE.BQIsReady && d_.BTC_MINUTE_Q.BQIsReady && d_.BTC_MINUTE.WasJustUpdated(algorithm.UtcTime) && d_.BTC_MINUTE_Q.WasJustUpdated(algorithm.UtcTime) ) { if (d_.BTC_MINUTE_Q.B[0].Ask.Low < 0) { algorithm.Debug("BTC neg Ask low price : " + d_.BTC_MINUTE_Q.B[0].Ask.Low + " | " + "Time : " + d_.BTC_MINUTE_Q.B[0].Time); yield break; } } } } } } } }
using System; using System.Collections.Generic; using System.Linq; using QuantConnect.Data; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Market; using QuantConnect.Indicators; using QuantConnect.Parameters; using QuantConnect.Orders; using QuantConnect.Algorithm.Framework.Risk; using QuantConnect.Algorithm.Framework.Alphas; using QuantConnect.Algorithm.Framework.Execution; using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Algorithm.Framework.Selection; namespace QuantConnect { public partial class Base : QCAlgorithm { public static Symbol _BTCUSD; public static Symbol _LTCUSD; public static TimeSpan Minute = TimeSpan.FromMinutes(1); //LTC 240 public static int Rol_minute = 4; public static Dictionary<string, BTC_MINUTE> DATA_BTC_MINUTE = new Dictionary<string, BTC_MINUTE>(); public static Dictionary<string, BTC_MINUTE_Q> DATA_BTC_MINUTE_Q = new Dictionary<string, BTC_MINUTE_Q>(); public static Dictionary<string, LTC_MINUTE> DATA_LTC_MINUTE = new Dictionary<string, LTC_MINUTE>(); public static Dictionary<string, LTC_MINUTE_Q> DATA_LTC_MINUTE_Q = new Dictionary<string, LTC_MINUTE_Q>(); string Symbol_BTC = "BTCUSD" ; string Symbol_LTC = "LTCUSD" ; public override void Initialize() { SetStartDate(2013, 1, 1); SetEndDate(DateTime.Now); Portfolio.SetCash("USD", 1000000m, 1); Settings.RebalancePortfolioOnInsightChanges = false; Settings.RebalancePortfolioOnSecurityChanges = false; //SetBrokerageModel(BrokerageName.AlphaStreams); SetBrokerageModel(BrokerageName.Bitfinex, AccountType.Margin); SetWarmUp(TimeSpan.FromMinutes(1440*113), Resolution.Minute); //var Crypto = AddCrypto(symbol, Resolution.Minute, Market.FXCM).Symbol; var Crypto_BTC = AddCrypto(Symbol_BTC, Resolution.Minute, Market.Bitfinex).Symbol; DATA_BTC_MINUTE.Add(Symbol_BTC, new BTC_MINUTE(Crypto_BTC, Minute, Rol_minute)); DATA_BTC_MINUTE_Q.Add(Symbol_BTC, new BTC_MINUTE_Q(Crypto_BTC, Minute, Rol_minute)); var Crypto_LTC = AddCrypto(Symbol_LTC, Resolution.Minute, Market.Bitfinex).Symbol; DATA_LTC_MINUTE.Add(Symbol_LTC, new LTC_MINUTE(Crypto_LTC, Minute, Rol_minute)); DATA_LTC_MINUTE_Q.Add(Symbol_LTC, new LTC_MINUTE_Q(Crypto_LTC, Minute, Rol_minute)); foreach (var kvp in DATA_BTC_MINUTE) { var BTC_MINUTE = kvp.Value; var bar_minute = (IDataConsolidator)new TradeBarConsolidator(Minute); bar_minute.DataConsolidated += (sender, baseData) => { var bar = (TradeBar)baseData; BTC_MINUTE.B.Add(bar); }; SubscriptionManager.AddConsolidator(BTC_MINUTE.Symbol, bar_minute); } foreach (var kvp in DATA_LTC_MINUTE) { var LTC_MINUTE = kvp.Value; var bar_minute = (IDataConsolidator)new TradeBarConsolidator(Minute); bar_minute.DataConsolidated += (sender, baseData) => { var bar = (TradeBar)baseData; LTC_MINUTE.B.Add(bar); }; SubscriptionManager.AddConsolidator(LTC_MINUTE.Symbol, bar_minute); } foreach (var kvp in DATA_BTC_MINUTE_Q) { var BTC_MINUTE_Q = kvp.Value; var bar_minute = (IDataConsolidator)new QuoteBarConsolidator(Minute); bar_minute.DataConsolidated += (sender, baseData) => { var bar = (QuoteBar)baseData; BTC_MINUTE_Q.B.Add(bar); }; SubscriptionManager.AddConsolidator(BTC_MINUTE_Q.Symbol, bar_minute); } foreach (var kvp in DATA_LTC_MINUTE_Q) { var LTC_MINUTE_Q = kvp.Value; var bar_minute = (IDataConsolidator)new QuoteBarConsolidator(Minute); bar_minute.DataConsolidated += (sender, baseData) => { var bar = (QuoteBar)baseData; LTC_MINUTE_Q.B.Add(bar); }; SubscriptionManager.AddConsolidator(LTC_MINUTE_Q.Symbol, bar_minute); } AddAlpha(new Alpha_BTC_UP(_BTCUSD)); AddAlpha(new Alpha_LTC_UP(_LTCUSD)); } public void OnInsightsGeneratedVerifier(IAlgorithm algorithm, GeneratedInsightsCollection insightsCollection) { if ( insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("BTCUSD")) != 1 && insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("LTCUSD")) != 1 ) { throw new Exception("Unexpected insights were emitted"); } } } public class BTC_MINUTE { public readonly Symbol Symbol; public readonly RollingWindow<TradeBar> B; public readonly TimeSpan Minute; public BTC_MINUTE(Symbol symbol, TimeSpan minute, int Rol_minute) { Symbol = symbol; Minute = minute; B = new RollingWindow<TradeBar>(Rol_minute); } public bool BQIsReady { get { return B.IsReady ;} } public bool WasJustUpdated(DateTime current) { return B.Count > 0 && B[0].Time > (current - TimeSpan.FromSeconds(5)) - Minute && B[0].Time < (current + TimeSpan.FromSeconds(5)) - Minute ; } } public class LTC_MINUTE { public readonly Symbol Symbol; public readonly RollingWindow<TradeBar> B; public readonly TimeSpan Minute; public LTC_MINUTE(Symbol symbol, TimeSpan minute, int Rol_minute) { Symbol = symbol; Minute = minute; B = new RollingWindow<TradeBar>(Rol_minute); } public bool BQIsReady { get { return B.IsReady ;} } public bool WasJustUpdated(DateTime current) { return B.Count > 0 && B[0].Time > (current - TimeSpan.FromSeconds(5)) - Minute && B[0].Time < (current + TimeSpan.FromSeconds(5)) - Minute ; } } public class BTC_MINUTE_Q { public readonly Symbol Symbol; public readonly RollingWindow<QuoteBar> B; public readonly TimeSpan Minute; public BTC_MINUTE_Q(Symbol symbol, TimeSpan minute, int Rol_minute) { Symbol = symbol; Minute = minute; B = new RollingWindow<QuoteBar>(Rol_minute); } public bool BQIsReady { get { return B.IsReady ;} } public bool WasJustUpdated(DateTime current) { return B.Count > 0 && B[0].Time > (current - TimeSpan.FromSeconds(5)) - Minute && B[0].Time < (current + TimeSpan.FromSeconds(5)) - Minute ; } } public class LTC_MINUTE_Q { public readonly Symbol Symbol; public readonly RollingWindow<QuoteBar> B; public readonly TimeSpan Minute; public LTC_MINUTE_Q(Symbol symbol, TimeSpan minute, int Rol_minute) { Symbol = symbol; Minute = minute; B = new RollingWindow<QuoteBar>(Rol_minute); } public bool BQIsReady { get { return B.IsReady ;} } public bool WasJustUpdated(DateTime current) { return B.Count > 0 && B[0].Time > (current - TimeSpan.FromSeconds(5)) - Minute && B[0].Time < (current + TimeSpan.FromSeconds(5)) - Minute ; } } }