Overall Statistics
Total Trades
158
Average Win
0%
Average Loss
0.00%
Compounding Annual Return
1.533%
Drawdown
5.900%
Expectancy
-1
Net Profit
0.986%
Sharpe Ratio
0
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$158.17
using System;
using System.Collections;
using System.Collections.Generic;
using QuantConnect.Securities;
using QuantConnect.Models;
using System.Globalization;

namespace QuantConnect {

    public class load_data : BaseData
    {
       
        public string tic = "";
        public double mrkt_cap = 0;
        public long cshoc = 0;
        public double prccd = 0;
        public double sum_mrkt_cap = 0;

        public load_data()
        {
            this.Symbol = "SPY_1";
        }
        
        public override string GetSource(SubscriptionDataConfig config, DateTime date, DataFeedEndpoint datafeed)
        {
            var startDate = new DateTime(2000, 1, 1).ToString("yyyy-MM-dd");
            var endDate = DateTime.Now.ToString("yyyy-MM-dd");
           
            
            //QUANDL WRAPPER ON YAHOO FINANCE API TO SORT DATA:
            //https://www.quandl.com/api/v1/datasets/YAHOO/INDEX_SPY.csv?trim_start=2000-01-01&trim_end=2014-12-03&sort_order=asc
       
            return "https://www.dropbox.com/s/8hmubibjuxtpaw0/mrkt_cap.csv?dl=1";
        }
        
        public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, DataFeedEndpoint datafeed)
        {
            load_data yBar = new load_data();

            try
            {
                string[] data = line.Split(',');
                //Required.
                yBar.Symbol = this.Symbol;
                yBar.Time = DateTime.ParseExact(data[1], "yyyy-MM-dd", CultureInfo.InvariantCulture);
                
                //User configured / optional data on each bar:
                
                yBar.tic = (data[0]);
                yBar.mrkt_cap = Convert.ToDouble(data[4]);
                yBar.sum_mrkt_cap = Convert.ToDouble(data[5]);
                
                yBar.prccd = Convert.ToDouble(data[3]);
                
                yBar.cshoc = Convert.ToInt64(data[2]);
                
                
                //This is the value the engine uses for portfolio calculations
                yBar.Value = yBar.cshoc;
            }
            catch {
                
            }

            return yBar;
        }
    }
}                        
using System;
using System.Collections;
using System.Collections.Generic; 
using QuantConnect.Securities;  
using QuantConnect.Models;   

namespace QuantConnect 
{   
    // Name your algorithm class anything, as long as it inherits QCAlgorithm
    public class CustomDataYahooQuandl : QCAlgorithm
    {   
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize()
        {
        	string[] comp = new string[] {"A","C","D","E","F","K","L","M","S","T","V","AV","BA","BK","BP","BT","CA","CB","CI","CL","CM","CP","CS","CX","DB","DD","DE","EA","EC","ED","EP","FB","FE","G.","GD","GE","GG","GM","GS","HD","IP","IX","JD","K.","KB","KO","KR","KZ","L.","LB","LU","MA","MO","MS","MT","MU","PD","PG","PM","PX","RF","RY","SE","SO","SU","TD","TI","TM","TS","TV","TX","UL","UN","VZ","WF","WM","WY","XL","YY","AAL","ABB","ABT","ABV","ABX","ACH","ACL","ACN","ADI","ADM","ADP","AEG","AEP","AES","AET","AFL","AGG","AGN","AIG","ALL","ALU","AMT","AMX","AON","APA","APC","APD","ASR","ASX","AUO","AVB","AVP","AXP","AZN","BAC","BAK","BAM","BAX","BB.","BBD","BBL","BBT","BBY","BCE","BCH","BCS","BDX","BEN","BGA","BHI","BHP","BLK","BLS","BMA","BMO","BMY","BND","BNI","BNS","BSX","BTI","BUD","BYH","CAG","CAH","CAJ","CAR","CAT","CBD","CBS","CCE","CCI","CCL","CCU","CEA","CEO","CHA","CHK","CHL","CHT","CHU","CIB","CIG","CLX","CM.","CME","CMI","CNI","CNP","CNQ","COF","COP","COV","COX","CP.","CPB","CPL","CRH","CRM","CSC","CSX","CTL","CUK","CVC","CVE","CVS","CVX","CWP","DAL","DCM","DEO","DFS","DHR","DIS","DNA","DOW","DOX","DUK","DVN","EBR","ECA","ECL","EEM","EFA","ELN","ELP","EMC","EMQ","EMR","ENB","EOG","EOP","EPD","EQR","ERJ","ETE","ETN","ETR","EXC","FBF","FBR","FCX","FDX","FMS","FMX","FOX","FRX","G.1","GDT","GDW","GGB","GIS","GLD","GLH","GLW","GPS","GSH","GSK","HAL","HAN","HCA","HCN","HDB","HES","HIG","HMC","HNP","HNZ","HOG","HON","HPE","HPQ","HSH","HTX","HUM","IAC","IAH","IBA","IBM","IBN","ICE","IJH","IMO","ING","IPG","ITW","IVV","IVZ","IWD","IWF","IWM","IWO","JCI","JHF","JHX","JNJ","JPM","KEY","KGC","KHC","KMB","KMI","KMP","KOF","KRB","KSS","KYO","LFC","LLY","LMT","LOW","LQD","LUV","LUX","LVS","LYB","LYG","MAD","MAR","MAS","MAT","MBT","MCD","MCK","MCO","MDT","MER","MET","MFC","MFG","MGM","MHG","MHS","MMC","MMM","MON","MOS","MPC","MRK","MRO","MSI","MTL","MTU","MYL","NCC","NEE","NEM","NGG","NKE","NMR","NOC","NOK","NOV","NSC","NT.","NTT","NUE","NVO","NVS","NYX","OMC","OOM","OXY","PAC","PAM","PBR","PCG","PCP","PCZ","PEG","PEP","PFE","PFG","PGR","PHG","PNC","POT","PPG","PRU","PSA","PSX","PTR","PUK","PVD","PVN","PWG","PXD","PZE","Q.2","QQQ","RAI","RBS","RCI","RIG","RIO","ROH","RTN","RY.","S.1","S.3","SAN","SAP","SBS","SGP","SHG","SHI","SID","SIG","SLB","SLF","SLR","SMI","SNE","SNN","SNP","SNY","SPG","SPY","SQM","SRE","SSL","STI","STJ","STM","STO","STT","STZ","SU.","SWY","SYF","SYK","SYY","T.2","TAR","TBH","TCK","TCN","TD.","TEF","TEL","TGT","THC","TIP","TJX","TKC","TLK","TLM","TMB","TMO","TMX","TND","TNE","TOT","TRB","TRI","TRP","TRV","TSD","TSL","TSM","TSU","TTM","TVE","TWC","TWX","TXN","TXU","TYC","UBB","UBS","UCL","UGP","UMC","UNH","UNP","UPS","USB","UTX","V.5","VCO","VEA","VFC","VIP","VIV","VLO","VNQ","VOD","VOO","VRX","VTI","VWO","WAT","WBA","WBK","WFC","WFT","WIT","WMB","WMT","WN.","WWY","WYE","XEL","XOM","XRX","XTO","YPF","YUM","YZC","ZBH","ZNH","AAPL","ABBV","ABEV","ABX.","ADBE","ADCT","AHIT","AHM.","AL.1","AL.Z","ALTR","ALXN","AMAT","AMCC","AMGN","AMOV","AMZN","ANTM","APOL","ARBA","ARMH","ARNC","ASML","AT.2","ATAD","ATVI","AVAL","AVGO","BABA","BBBY","BBRY","BBVA","BCE.","BEAS","BIIB","BMO.","BNS.","BR.2","BRCD","BRCM","BRFS","BSAC","BSMX","BXLT","CB.1","CE.2","CELG","CERN","CHKP","CHRT","CIEN","CISG","CLS.","CM.2","CMVT","CN.1","CNCO","CNQ.","CNR.","CNU.","COC1","COLT","COST","CSCO","CTSH","CVE.","DELL","EBAY","ECA.","ECP.","EDS.","ENB.","ENIA","EOCC","ERIC","ESRX","FITB","FLEX","FMCC","FMCN","FNMA","FOXA","FSLR","GENZ","GGAL","GILD","GM.1","GMST","GOOG","GUCG","GWO.","HFBK","HI.2","HSBC","HSE.","ILMN","IMNX","IMO.","INFY","INTC","INTU","IRCP","ITCB","ITUB","ITWO","JAVA","JNPR","KRFT","KUTV","LLTC","LNKD","LVLT","MDLZ","MEDI","MFC.","MLNM","MNST","MPEL","MSFT","MXIM","NAVI","NDY.","NFLX","NTAP","NTES","NTRS","NXPI","NXTL","OAT.","OIIM","ORAN","ORCL","ORLY","PALM","PAYX","PCAR","PCLN","PMCS","POT.","PUSH","PWF.","PYPL","QCOM","RDPL","REGN","RELX","RENX","SANM","SBUX","SC.1","SCCO","SCHW","SDLI","SEBL","SHLD","SHPG","SLF.","SMFG","SNLC","SOTR","SPGI","SPIL","SPLS","SYMC","TEVA","TGNA","TI.1","TI.2","TI.A","TLAB","TLM.","TLHY.1"};
            string[] comp1 = new string[] {"WT","TMUS","TRI.","TRP.","TSLA","TWTR","TX.2","VALE","VEDL","VIAB","VIAV","VRSN","VRTX","VRX.","WB.1","WB.3","XLNX","YHOO","YOKU","4206B","AAGIY","ABI.3","ABNYY","ABOYY","ABS.1","ABSXY","ABSZF","ACGBY","ACKAY","ADRNY","AEC.1","AED.1","AED.3","AFRVY","AGC.1","AGESY","AGN.2","AGPPF","AGRPY","AIBYY","AIPUY","AJINY","AKBTY","AKZOY","ALGGY","ALPMY","AMCRY","ANFGY","ANGPY","ANZBY","AOMOY","AONNY","ARA.1","ARZGY","ASBFY","ASBRY","ASGLY","ASHTY","ATD.B","ATLKY","AUKNY","AVE.2","AWCMY","AWE.2","AXAHY","AXBKY","AXF.1","AZA.1","BAB.Z","BACHY","BAESY","BAM.A","BASFY","BAYRY","BBD.B","BCAHY","BDORY","BELLY","BGYEY","BGYNY","BHKLY","BKHYY","BKJAY","BKRKY","BLSFY","BNGPY","BNPQY","BNPZY","BOX.1","BPC.2","BRDCY","BRGYY","BRK.A","BRK.B","BRP.1","BRTHY","BTAFF","BUD.2","BXBLY","BZLFY","BZQIY","CAOVY","CBAUY","CCTVY","CCU.1","CDGLY","CDSCY","CFC.3","CGA.1","CGKEY","CGP.1","CICHY","CKHUY","CLPHY","CMAKY","CMCSA","CMCSK","CMGHY","CMNFY","CMPGY","CMTOY","CMWAY","CMX.1","CPCAY","CPNLQ","CPQ.2","CPYYY","CRARY","CRZBY","CSUAY","CTMCY","CTTAY","CXSSY","CYRBY","CZMTY","DBRSY","DBSDY","DCX.1","DDAIF","DDAIY","DFIHY","DHOXY","DIISY","DKILY","DLAKY","DNBHF","DNFGY","DNHBY","DNKEY","DNPLY","DNZOY","DPSGY","DRSDY","DRSRY","DSEEY","DSITY","DSKYY","DTBKY","DTEGY","DTV.2","DWAHY","DYNIQ","DYSVY","EADSY","EBR.B","ECIFY","EDPFY","EGFLY","EGIEY","EIR.1","EKDKQ","ELEYY","ELPVY","ELUXY","EMT.2","ENGIY","ENGQF","ENGSY","ENLAY","ENRNQ","ENSTY","EONGY","ESALY","ESYJY","ETPOY","EURNY","FANDY","FDC.2","FEG.1","FELTY","FETLF","FIATY","FIAZY","FJTSY","FNEVY","FOX.3","FPAFY","FREYY","FSUGY","FUJHY","FUJIY","GAILY","GARPY","GBLXQ","GBOOY","GBTZY","GFSZY","GGDVY","GIGNY","GLAPY","GLAXF","GLNCY","GMALY","GOOGL","GPMCY","GRYMY","GWLIF","GWLLY","GXYEY","GZPFY","HACBY","HBOOY","HCA.2","HEINY","HENGY","HENKY","HINOY","HKXCY","HLPPY","HMV20","HNGKY","HNHAY","HOKCY","HTHIY","HUSKF","HUWHY","HVMGY","IBDRY","ICABY","ICAGY","ICIYY","IDCBY","IDEXY","IESFY","IFNNY","IMBBY","IMI.2","IMPUY","INF.3","INTHY","IPRPY","IREBY","ISCHY","ISNPY","ISUZY","ITOCY","ITVPY","IVNYY","IYCLY","IYCOY","JALSQ","JAPAY","JBSAY","JCCIY","JCYGY","JEHLY","JMHLY","JPSWY","JRONY","JSAIY","JSFCF","JSFCY","JSHLY","JSMFY","KAEPY","KAJMY","KBSTY","KCRPY","KDDIY","KFSGY","KGFHY","KHOLY","KKPNY","KLBAY","KMTUY","KNBWY","KNCAY","KPCPY","KPELY","KRYPY","KUBTY","KWHIY","LBTYK","LDBKY","LEHMQ","LFUGY","LIHR.","LNVGY","LRLCY","LSO.2","LTORY","LUKOY","MAKSY","MAURY","MAV.1","MAY.2","MBK.1","MCHVY","MEL.3","MHTLY","MIELY","MIRKQ","MITEY","MITSY","MLYBY","MOTAY","MOTMY","MRWSY","MSADY","MSBHY","MTLHY","MTLQQ","MTNOY","MTRJY","MXICY","MYS.1","MYSZY","MYTAY","NABZY","NCMGY","NDEKY","NDVLY","NGLOY","NHYDY","NIKOY","NILSY","NINOY","NIPNY","NISGY","NISQY","NOBGY","NOVKY","NPNYY","NPSKY","NPSNY","NRBAY","NRTLQ","NSANY","NSSMY","NTXFY","NZSKY","OGXPY","OGZPY","OIBRQ","OJIPY","OJSCY","OLMIY","OMRNY","OMVKY","ONE.1","ORSTF","OSTLY","OTPGF","OUBSF","OVCHY","OZMLY","PBCRY","PBR.A","PCA.Z","PCCWY","PCRFY","PCS.1","PEXNY","PGN.1","PHA.1","PNGAY","PNLYY","PPAAY","PPERY","PSFT.","PTAIY","PTGCY","PTINY","PUGOY","PUODY","PUTKY","PZE.2","QABSY","QBIEY","QXLRY","RBGPF","RCI.B","RDS.A","RDS.B","RELEY","REPYY","REXMY","RHHBY","RHHDY","RHHQY","RICOY","RINYY","RLNIY","ROSYY","RSAIF","RSHYY","RSNAY","RTOLY","RWEOY","RWEPY","RYAAY","RYCEY","SANYY","SBKFF","SBMRF","SBMRY","SBRCY","SBTLY","SCBFF","SCHYY","SDA.1","SDAYY","SDT.2","SDVKY","SFTBY","SGAPY","SGBLY","SGGKY","SGPRY","SGPYY","SGTPY","SGTZY","SHC.1","SHCAY","SHRGY","SHZUY","SIEGY","SINGY","SKHSY","SKVKY","SKYAY","SLLDY","SLT.1","SMTOY","SNE.1","SNMRY","SNRAY","SOHVY","SOMLY","SOMMY","SPC.2","SPI.3","SPKKY","SQMCY","SRGHY","SRHBY","SSEZY","SSLTY","SSNHZ","SSREY","STRZA","SUHJY","SVJTY","SVNDY","SWCEY","SWDBY","SWRBY"};
            string[] comp2 = new string[] {"SYHTY","SZEZY","SZKMY","TATYY","TBE.1","TCA.P","TCEHY","TCK.B","TCM.3","TELNY","TEM.1","TFONY","THBIY","TISCY","TKAGY","TKECY","TKGBY","TKGSY","TKGZY","TKOMY","TKPYY","TKS.1","TLKGY","TLSNY","TLSYY","TLXLY","TMKOY","TNABY","TNT.2","TOELY","TOMOY","TOPPY","TOSBF","TOSYY","TRIN.","TRKNY","TRO.2","TRUMY","TRYIY","TSCDY","TSUKY","TSX.2","TTDKY","TTNDY","TWX.1","TYABY","TZA.1","UBS.4","UNEWY","UOVEY","UPMKY","USB.1","UUGRY","UVYPY","UVYZY","VDMCY","VEOEY","VIV.3","VIVHY","VLKAY","VOLVY","VSTR.","WAMUQ","WARFY","WCOEQ","WEICY","WFGPY","WHLKY","WLMIY","WLP.1","WLWHY","WMC.1","WMMVY","WOPEY","WOSYY","WPPGY","WWNTY","WYNMY","XYIGY","YAHOY","YMZBY","YUEIY","ZHEXY","3INGYY","3NSRGY","3WMMBY","AYEF10","BAC.PS","CSRLY.","CZMX20","FREE.1","FREY10","PEG.PA","RBS.PK","SMAG40","STTSY.","TLSNY.","VALE.P","VRTS.1","SWMA"};
            SetStartDate(2010, 1, 2);
            SetEndDate(2016, 12, 3);
            SetCash(100000);
           // Debug("manu");
            
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
            AddSecurity(SecurityType.Equity, "TMB", Resolution.Minute);
            for(int i =0; i< comp1.Length; i++)
            {
            	AddSecurity(SecurityType.Equity,comp[i], Resolution.Minute);
            }
            for(int i =0; i< comp1.Length; i++)
            {
            	AddSecurity(SecurityType.Equity, comp1[i], Resolution.Minute);
            }
            for(int i =0; i< comp2.Length; i++)
            {
            	AddSecurity(SecurityType.Equity, comp2[i], Resolution.Minute);
            }
            AddData<load_data>("SPY_1", Resolution.Minute);
            //Debug("nithin");
            //load_data a = new load_data();
            //call(a);
            
        }

        public void OnData(TradeBars data) 
        {  
            //QuantConnect SPY Minute Events here:
        }
        
        public void OnData(load_data data)
        {
            //Yahoo/Quandl SPY_Daily Events here:
            //Debug("nithin2");
           // Debug(Convert.ToString(data.Value));
            
            //var quantity = (int) (Portfolio.Cash / data.Value); 
            if(Securities.ContainsKey(data.tic))
            {
            	SetHoldings(data.tic, data.mrkt_cap/data.sum_mrkt_cap);
            }
            
            if (!Portfolio.Invested) 
            {
                
            }
        }
        
    }
}