Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0.006% Drawdown 0.100% Expectancy 0 Net Profit 0.037% Sharpe Ratio 0.254 Probabilistic Sharpe Ratio 2.017% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.587 Tracking Error 0.162 Treynor Ratio 0.344 Total Fees $0.00 |
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.Indicators; using QuantConnect.Orders; 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 QCAlgorithm algorithm {get; set;} public static TimeSpan BP1m = TimeSpan.FromMinutes(1); public readonly int SMAP = 6; public static int RLLWS = 1440; public static Symbol _BTCUSD; public static Dictionary<string, SY1D> D1D = new Dictionary<string, SY1D>(); public override void Initialize() { SetStartDate(2014, 7, 1); SetEndDate(DateTime.Now - TimeSpan.FromDays(1)); SetAccountCurrency("USD"); SetCash("USD", 25000000); SetCash("BTC", 1m); //SetBrokerageModel(BrokerageName.FxcmBrokerage); SetBrokerageModel(BrokerageName.AlphaStreams); _BTCUSD = "BTCUSD"; var BTCUSD_crypto = AddCrypto("BTCUSD", Resolution.Minute, Market.Bitfinex); D1D.Add(_BTCUSD, new SY1D(BTCUSD_crypto.Symbol, BP1m, RLLWS)); foreach (var kvp in D1D) { var SY1D = kvp.Value; var consolidator1D_Q = (IDataConsolidator)new QuoteBarConsolidator(BP1m); consolidator1D_Q.DataConsolidated += (sender, baseData) => { var bar = (QuoteBar)baseData; SY1D.BQ.Add(bar); }; SubscriptionManager.AddConsolidator(SY1D.Symbol, consolidator1D_Q); } AddAlpha(new Alpha_BTCUSD(_BTCUSD)); } public override void OnOrderEvent(OrderEvent orderEvent) { Debug(Time + " " + orderEvent); } public void OnInsightsGeneratedVerifier(IAlgorithm algorithm, GeneratedInsightsCollection insightsCollection) { if (insightsCollection.Insights.Count(insight => insight.Symbol.Value.Equals("BTCUSD")) != 1) { throw new Exception("Unexpected insights were emitted"); } } } public class SY1D { public readonly Symbol Symbol; public readonly RollingWindow<QuoteBar> BQ; public readonly TimeSpan BP1m; public SimpleMovingAverage SMA; public SY1D(Symbol symbol, TimeSpan bP1m, int RLLWS) { Symbol = symbol; BP1m = bP1m; BQ = new RollingWindow<QuoteBar>(RLLWS); } public bool BQIsReady { get {return BQ.IsReady;} } public bool WasJustUpdated(DateTime current) { return BQ.Count > 0 && BQ[0].Time == current - BP1m; } } }
namespace QuantConnect { public partial class Base { public class Alpha_BTCUSD : AlphaModel { private readonly Symbol _symbol; public Alpha_BTCUSD(Symbol symbol) { _symbol = symbol; } public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice data) { foreach (var SY1D in D1D.Values) { if (SY1D.BQIsReady && SY1D.WasJustUpdated(algorithm.Time)) { algorithm.Debug("dgssdff" + SY1D.Symbol); if (SY1D.Symbol.Equals("BTCUSD")) { var prices_ASK_Open = SY1D.BQ.Select(x => x.Ask.Open).ToList(); algorithm.Debug("dgssdff" + prices_ASK_Open[0]); yield return Insight.Price(SY1D.Symbol, Resolution.Daily, 7, InsightDirection.Down); algorithm.MarketOrder(SY1D.Symbol, 1, false, "BTCUSD_OCO1_Entry_TP1"); yield break; } } } } } } }