Overall Statistics |
Total Trades 9310 Average Win 0.21% Average Loss -0.08% Compounding Annual Return -67.640% Drawdown 67.900% Expectancy -0.447 Net Profit -67.740% Sharpe Ratio -5.328 Probabilistic Sharpe Ratio 0.000% Loss Rate 85% Win Rate 15% Profit-Loss Ratio 2.70 Alpha -0.587 Beta -0.066 Annual Standard Deviation 0.112 Annual Variance 0.013 Information Ratio -4.079 Tracking Error 0.18 Treynor Ratio 8.981 Total Fees $0.00 |
namespace QuantConnect.Algorithm.CSharp { public class CalibratedVentralCompensator : QCAlgorithm { public string forex = "EURUSD"; private bool betOnUp = false; private RollingWindow<decimal> close; public override void Initialize() { SetEndDate(2019, 12, 1); SetStartDate(2018, 12, 1); SetCash(200); var eud = AddForex(forex, Resolution.Hour, Market.Oanda); eud.SetDataNormalizationMode(DataNormalizationMode.Raw); SetBrokerageModel(BrokerageName.OandaBrokerage); close = new RollingWindow<decimal>(4); } /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. /// Slice object keyed by symbol containing the stock data public override void OnData(Slice data) { close.Add(data[forex].Close); if(close.Count <= 1) return; var currentPrice = Securities[forex].Price; var amountToBuy = Portfolio.Cash/currentPrice; var upTrend = close[1] < close[0]; Debug("Last Close : "+close[1]+", Current Close : "+close[0]+", Profit since last trade : "+Portfolio[forex].UnrealizedProfit); if(betOnUp != upTrend){ Liquidate(forex); Debug("Liquidated position, holding "+Securities[forex].Invested); } if(upTrend){ MarketOrder(forex, amountToBuy); betOnUp = true; Debug("Long with "+(amountToBuy)+" Units, holding "+Securities[forex].Invested); } else{ MarketOrder(forex, -amountToBuy); betOnUp = false; Debug("Short with "+(-amountToBuy)+" Units, holding "+Securities[forex].Invested); } } } }