Overall Statistics
Total Trades
3691
Average Win
3.43%
Average Loss
-1.31%
Compounding Annual Return
105186.455%
Drawdown
84.700%
Expectancy
0.414
Net Profit
349879.235%
Sharpe Ratio
3.827
Loss Rate
61%
Win Rate
39%
Profit-Loss Ratio
2.61
Alpha
-1.94
Beta
571.427
Annual Standard Deviation
1.549
Annual Variance
2.398
Information Ratio
3.819
Tracking Error
1.549
Treynor Ratio
0.01
Total Fees
$139302.26
//Copyright HardingSoftware.com, 2018.
//Granted to the public domain.
//Use at your own risk.
namespace QuantConnect.Algorithm.CSharp
{
    public class Coins : QCAlgorithm
    {
		string tickersString ="BTCUSD,ETHUSD,LTCUSD";
		Resolution resolution=Resolution.Hour;
		List<StockData> stockDatas = new List<StockData>();
		int rsiPeriod=24;
		string stockHeld="";
		
        public override void Initialize() 
        {
            SetStartDate(2017, 1, 1);    
            SetEndDate(DateTime.Now);
            SetCash(100);
			string[] tickers = tickersString.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string ticker in tickers)
			{
				Symbol symbol = QuantConnect.Symbol.Create(ticker, SecurityType.Crypto, Market.GDAX);
				AddCrypto(symbol, resolution);
				StockData stockData=new StockData();
				stockData.Ticker=ticker;
				stockData.Rsi=RSI(ticker,rsiPeriod,MovingAverageType.Exponential,resolution);
				stockDatas.Add(stockData);
			}
			foreach (Security s in Securities.Values)
            {
            	s.FeeModel=new CustomFeeModel();
            }
        }

        public override void OnData(Slice data) 
        {
        	foreach (StockData stockData in stockDatas)
        	{
				stockData.Fitness=stockData.Rsi;
        	}

    	    var q1 = from x in stockDatas
    			orderby x.Fitness descending
    			select x;
        	
        	List<StockData> q2=q1.ToList();
        	if (q2.Count>0)		
        	{
        		StockData selectedStockData=q2.First();
        		if (selectedStockData.Ticker != stockHeld)
        		{
        			Liquidate(stockHeld);
        			SetHoldings(selectedStockData.Ticker, 1.0);
					stockHeld=selectedStockData.Ticker;
        		}
        	}
        }
        
        class StockData
        {
        	public string Ticker;
			public RelativeStrengthIndex Rsi;
			public decimal Fitness;
        }
        
        public class CustomFeeModel : IFeeModel
	    {
	        public decimal GetOrderFee(Security security, Order order)
	        {
	            var fee = order.AbsoluteQuantity*0.001m*security.Price;
	            return fee;
	        }
	    }
    }
}