Overall Statistics |
Total Trades 649 Average Win 0.15% Average Loss -0.02% Compounding Annual Return 55.215% Drawdown 1.600% Expectancy 3.346 Net Profit 11.988% Sharpe Ratio 6.933 Loss Rate 50% Win Rate 50% Profit-Loss Ratio 7.75 Alpha 0.291 Beta 0.14 Annual Standard Deviation 0.043 Annual Variance 0.002 Information Ratio 3.369 Tracking Error 0.068 Treynor Ratio 2.15 Total Fees $1.37 |
namespace QuantConnect.Algorithm.CSharp { public class TestRenkoConsolidator : QCAlgorithm { private double renkoSize = 0.75; private string symString = "LTCUSD"; private double startingCash = 100; private BarDirection currentBarDirection = BarDirection.NoDelta; private RenkoBar currentBar; public override void Initialize() { SetStartDate(2017, 06, 01); SetEndDate(2017, 09, 02); SetCash(startingCash); AddCrypto(symString, Resolution.Second, Market.GDAX); SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash); var renko = new RenkoConsolidator((decimal)renkoSize, RenkoType.Wicked); renko.DataConsolidated += OnRenkoBar; SubscriptionManager.AddConsolidator(symString, renko); } public override void OnData(Slice data) { } public void OnRenkoBar(object sender, RenkoBar bar) { currentBar = bar; currentBarDirection = currentBar.Direction; CheckForExitCondition(); CheckForEntryCondition(); } private void CheckForExitCondition() { if(currentBarDirection == BarDirection.Falling) { Liquidate(symString); } } private void CheckForEntryCondition() { Transactions.CancelOpenOrders(symString); if(currentBarDirection == BarDirection.Rising) { decimal units = UnitsToBuy(); decimal limitPrice = currentBar.Close; LimitOrder(symString, units, limitPrice); } } private decimal UnitsToBuy() { decimal dollarsAtRisk = Portfolio.Cash * 0.01m; decimal riskPerUnit = currentBar.Close - (decimal)(2 * renkoSize); decimal unitsToBuy = dollarsAtRisk / riskPerUnit; return unitsToBuy; } } }