What is Boot Camp?
Boot Camp is a great way to improve your skills and learn the QuantConnect API in easily digestible portions.
Don't have an account? Join QuantConnect Today
We are dedicated to providing investors with a cutting-edge platform for rapidly creating quant investment strategies. Founded in 2012, we've empowered more than 250,000 quants and engineers to create and trade their ideas.
Quickly and easily started with our API to build your strategy. The learning center lessons are interactive, step-by-step guides to make you productive as fast as possible.
Focus your efforts on driving alpha, not parsing CSV files. Our cloud offers hundreds of terabytes of traditional and alternative data preformatted, cleaned, and instantly accessible by our API.
Coordinate teamwork, control access permissions, and your shared cloud resources. Grow your trading organization safely and efficiently on top of our cloud architecture.
A selection of streaming live-trading strategies written by QuantConnect, and top highlights from the community available to follow and clone. Peer into detailed real-time positions to gain insight for your own trading.
What is Boot Camp?
Boot Camp is a great way to improve your skills and learn the QuantConnect API in easily digestible portions.
A collection of courses from independent educators to improve your quant skill base and create better strategies.
Solidify and expand your quant skill base with courses at QuantConnect
Learn algorithmic trading with python for US Equities. Guided strategy development in easily digestible portions.
Author: QuantConnect
Free | 94,515 People Enrolled
Learn algorithmic trading with python for FX. Guided strategy development in easily digestible portions.
Author: QuantConnect
Free | 20,326 People Enrolled
Learn algorithmic trading with python for Futures. Guided strategy development in easily digestible portions.
Author: QuantConnect
Free | 7,231 People Enrolled
In this algorithmic trading tutorial series you will learn everything you need to know to start writing your own trading bots using Python and the QuantConnect quantitative trading platform.
Author: Louis
Free | 27,883 People Enrolled
Master algorithmic trading on QuantConnect; backtest and live trade Stocks, Options, Futures, Forex, and Crypto.
Author: Cheng Li
Paid | Enroll on Udemy
Learn to use Python, Pandas, Matplotlib, and the QuantConnect Lean Engine to perform financial analysis and trading.
Author: Jose Portilla, Pierian Training
Paid | Enroll on Udemy
Learn to write programs that algorithmically trade cryptocurrencies using QuantConnect (C#).
Author: Eric Summers
Paid | Enroll on Udemy
Organization Notes
Get Started with Algorithm Lab
New Research
Low Beta Portfolios Across Industries
An implementation of a classic AQR strategy targeting low-beta stocks across many industries. Through diversification and low beta filters strategy co...
ReadAlgorithm Lab is your playground for developing and refining trading algorithms with QuantConnect. Utilize advanced tools, historical data, and robust backtesting to enhance your trading strategies. Transform your ideas into actionable insights and optimize your trading approach with ease.
Sign Up for FreeAlready have an account Log In.
This account is protected by two-factor authentication.
Request Token Information Reset My TokenCreated | Last Time Used | Agent | |
---|---|---|---|
No entries found |
To continue please enter your email:
(No google account required)
To verify that everything goes well please enter the 6 digit verification code generated by the authenticator application
Algorithm Lab is your playground for developing and refining trading algorithms with QuantConnect. Utilize advanced tools, historical data, and robust backtesting to enhance your trading strategies. Transform your ideas into actionable insights and optimize your trading approach with ease.
Sign Up for FreeAlready have an account Log In.
Jumpstart your algorithm development with a curated selection of classic live strategies written by QuantConnect, and top highlights from the community.
Live Projects list the projects that have live results.
Categories
Your projects with an active live deployment.
Live Projects list the projects that have live results.
Popular index-tracking, value and momentum US Equity strategies.
Alt-data powered strategies drawing on sentiment, machine-learning, and real-time news.
Classic technical and all-weather futures strategies to complement your portfolio.
Index tracking, dip and technical strategies to weather a crypto winter.
Technical and macro currency trading strategies for non-US investors.
Live Projects list the projects that have live results.
Open-source entries from quarterly college v college competition.
Please stop one of the following coding sessions, or upgrade your account.
NAME | ORGANIZATION |
---|
QuantConnect Datasets
Explore free and paid datasets available on QuantConnect covering fundamentals, pricing, and alternative options.
Datasets >
Dashboard
A transparent, community reporting system. Report suspected issues with our cloud data to be investigated by the QuantConnect Team.
Issue List
Loading...
Data Explorer Issues are a way to report and track data problems. They give the QuantConnect community a way to discuss potential solutions and be notified when they are resolved. If you think you have found a data problem please check the existing open and closed issues first; often another user may have already reported your problem.
Does your issue match any of the already listed issues?
Thank you for your contribution! Our team is currently working on resolving these issues, please subscribe to them to receive updates.
Datasets >
US ETF Constituents
Dataset by QuantConnect
The US ETF Constituents dataset by QuantConnect tracks the constituents and weighting of US Equities in 2,650 ETF listings. The data starts in June 2009 and is delivered on a daily basis (monthly basis before January 2015). This dataset is created by tracking the host ETF websites and can be delayed by up to 1 week.
This dataset depends on the US Equity Security Master dataset because the US Equity Security Master dataset contains information on splits, dividends, and symbol changes.
QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 160,000 quants are served every month.
The following snippet demonstrates how to request data from the US ETF Constituents dataset:
def initialize(self) -> None:
self.universe_settings.asynchronous = True
# Use the following method for a Classic Algorithm
self._universe = self.add_universe(self.universe.etf("SPY", Market.USA, self.universe_settings, self.etf_constituents_filter))
symbol = Symbol.create("SPY", SecurityType.EQUITY, Market.USA)
# Use the following method for a Framework Algorithm
self.add_universe_selection(ETFConstituentsUniverseSelectionModel(symbol, self.universe_settings, self.etf_constituents_filter))
def etf_constituents_filter(self, constituents: List[ETFConstituentUniverse]) -> List[Symbol]:
# Add all Symbols of the ETFConstituentUniverse
return [x.symbol for x in constituents]
public override void Initialize()
{
UniverseSettings.Asynchronous = true;
// Use the following method for a Classic Algorithm
_universe = AddUniverse(Universe.ETF("SPY", Market.USA, UniverseSettings, ETFConstituentsFilter));
var symbol = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);
// Use the following method for a Framework Algorithm
AddUniverseSelection(new ETFConstituentsUniverseSelectionModel(symbol, UniverseSettings, ETFConstituentsFilter));
}
private IEnumerable<Symbol> ETFConstituentsFilter(IEnumerable <ETFConstituentUniverse> constituents)
{
// Add all Symbols of the ETFConstituentUniverse
return constituents.Select(x => x.Symbol);
}
The following table describes the dataset properties:
Property | Value |
---|---|
Start Date | June 2009 |
Asset Coverage | 2,650 US ETF Listings |
Data Density | Dense |
Resolution | Daily (Monthly before Jan 2015) |
Timezone | New York |
The ETF Constituents dataset provides an excellent source of tradable universes for strategies without selection bias. When you use an ETF universe, the original ETF can serve as an excellent benchmark for your strategy performance. Other use cases include the following:
For more example algorithms, see Examples.
The ETF Constituents dataset provides ETFConstituentUniverse objects, which have the following attributes:
The following table shows the available ETFs:
ETF Tickers | |||||
---|---|---|---|---|---|
AADR | AAIT | AAWW | AAXJ | ABCS | ABEQ |
ACCU | ACES | ACIM | ACIO | ACSG | ACSI |
ACT | ACTV | ACWF | ACWI | ACWV | ACWX |
ADFI | ADIV | ADME | ADRA | ADRD | ADRE |
ADRU | AEMB | AESR | AFK | AFLG | AFMC |
AFSM | AFTY | AGEM | AGG | AGGE | AGGH |
AGGP | AGIH | AGII | AGLS | AGNG | AGOV |
AGQ | AGRG | AGRH | AGT | AGZ | AHYB |
AIA | AIEQ | AIIQ | AIQ | AIRR | ALFA |
ALFI | ALTL | ALTS | ALTY | AMCA | AMER |
AMID | AMLP | AMLX | AMOM | AMPS | AMZA |
ANEW | ANGL | AOA | AOK | AOM | AOR |
AOTG | APRZ | AQWA | ARCM | ARGT | ARKG |
ARKK | ARKQ | ARKW | ARKX | ARVR | ASEA |
ASET | ASHR | ASHX | AUGZ | AUSE | AUSF |
AVDE | AVDV | AVEM | AVES | AVGE | AVIE |
AVIV | AVLV | AVRE | AVSC | AVSD | AVSE |
AVSU | AVUS | AVUV | AWAY | AXDI | AXEN |
AXFN | AXHE | AXID | AXIT | AXJL | AXJS |
AXJV | AXMT | AXSL | AXTE | AXUT | BAB |
BABS | BATT | BBAG | BBAX | BBC | BBCA |
BBCB | BBEU | BBH | BBHY | BBIN | BBLU |
BBMC | BBP | BBRC | BBRE | BBSA | BBSC |
BBUS | BCHP | BCNA | BDAT | BDH | BDRY |
BECO | BEDZ | BEMO | BERN | BETZ | BFIT |
BFOR | BFTR | BHH | BIB | BIBL | BICK |
BIDS | BIGD | BIK | BIKR | BITQ | BITS |
BIV | BIZD | BJK | BKCH | BKCI | BKEM |
BKES | BKF | BKGI | BKIE | BKIS | BKLC |
BKMC | BKSE | BKUS | BLCN | BLDG | BLES |
BLHY | BLKC | BLLD | BLOK | BLV | BMED |
BND | BNDC | BNDW | BNDX | BNE | BNGE |
BOB | BOSS | BOTZ | BOUT | BPAY | BRF |
BRGL | BRNY | BRZU | BSCB | BSCC | BSCD |
BSCE | BSCF | BSCG | BSCH | BSCI | BSCJ |
BSCK | BSEA | BSJC | BSJD | BSJE | BSJF |
BSJG | BSJH | BSJI | BSJJ | BSV | BTAH |
BTAL | BTEC | BTEK | BTHM | BUFD | BUFF |
BUFG | BUFQ | BUFR | BUFT | BUG | BUL |
BUYZ | BUZ | BUZZ | BWX | BWZ | BYLD |
BYOB | BYTE | CACG | CALF | CARZ | CATH |
CBOE | CBON | CCON | CCOR | CCXE | CDC |
CDEI | CDL | CDX | CEFA | CEFS | CEMB |
CEY | CEZ | CFA | CFCV | CFGE | CFO |
CGDV | CGGO | CGGR | CGUS | CGW | CGXU |
CHAU | CHB | CHEP | CHGX | CHIC | CHIH |
CHII | CHIK | CHIL | CHIQ | CHIR | CHIS |
CHIX | CHLD | CHNA | CIBR | CID | CIL |
CIRC | CIU | CIZ | CLDL | CLIX | CLNR |
CLOU | CLRG | CLSA | CLSC | CLSM | CLY |
CLYH | CMBS | CMDT | CMF | CN | CNBS |
CNCR | CNDA | CNDF | CNHX | CNRG | CNSF |
CNTR | CNXT | COLX | COMB | COMG | COMT |
CONG | COPX | COWZ | CPI | CQQQ | CRAK |
CRBA | CRBI | CRBN | CRBQ | CRED | CRO |
CROP | CRPT | CRUZ | CSA | CSB | CSD |
CSF | CSJ | CSM | CSML | CTEC | CTEX |
CTRU | CU | CUMB | CURE | CUT | CVIE |
CVLC | CVMC | CVSE | CVY | CWEB | CWI |
CWS | CXSE | CYA | CZA | DALI | DALT |
DAPP | DAT | DAX | DBA | DBAP | DBAU |
DBAW | DBB | DBBR | DBC | DBE | DBEF |
DBEM | DBES | DBEU | DBEZ | DBGR | DBIF |
DBIT | DBIZ | DBJP | DBKO | DBLV | DBMX |
DBN | DBO | DBRE | DBSE | DBSP | DBU |
DBUK | DDBI | DDEZ | DDIV | DDLS | DDM |
DDWM | DEB | DECZ | DEEF | DEEP | DEF |
DEFA | DEFN | DEHP | DEM | DEMG | DENT |
DES | DESC | DEUS | DEW | DEWJ | DEZU |
DFAC | DFAE | DFAI | DFAR | DFAS | DFAT |
DFAU | DFAX | DFE | DFEM | DFEN | DFEV |
DFGR | DFHY | DFIC | DFIS | DFIV | DFJ |
DFLV | DFND | DFNL | DFNV | DFSE | DFSI |
DFSU | DFSV | DFUS | DFUV | DGRE | DGRO |
DGRS | DGRW | DGS | DGT | DHDG | DHS |
DIA | DIEM | DIG | DIHP | DIM | DINT |
DISV | DIV | DIVA | DIVB | DIVD | DIVI |
DIVO | DIVS | DIVZ | DJD | DJIA | DKA |
DLN | DLS | DMAT | DMDV | DMRE | DMRI |
DMRL | DMRM | DMRS | DMXF | DND | DNH |
DNL | DOG | DOL | DON | DOO | DOZR |
DPK | DPST | DQML | DRIV | DRLL | DRN |
DRSK | DRW | DSC | DSCF | DSG | DSI |
DSPC | DSTL | DSTX | DSUM | DSV | DTD |
DTEC | DTH | DTN | DTOX | DTRE | DUDE |
DUHP | DURA | DUSA | DUSL | DVAL | DVEM |
DVLU | DVOL | DVP | DVY | DVYA | DVYE |
DWAQ | DWAS | DWAT | DWAW | DWCR | DWEQ |
DWFI | DWIN | DWLD | DWLV | DWM | DWMC |
DWPP | DWSH | DWTR | DWUS | DWX | DXD |
DXGE | DXJ | DXJC | DXJF | DXJH | DXJR |
DXJS | DXJT | DXKW | DXPS | DXUS | DYHG |
DYLD | DYLS | DYNF | DZK | EAFD | EAOA |
EAOK | EAOM | EAOR | EASG | EASI | EATZ |
EBIZ | EBLU | EBND | ECH | ECLN | ECNS |
ECON | ECOW | ECOZ | EDBI | EDC | EDEN |
EDIV | EDOC | EDOG | EDOM | EDOW | EDUT |
EEB | EEG | EEHB | EELV | EEM | EEMA |
EEMD | EEME | EEML | EEMO | EEMS | EEMV |
EEMX | EEN | EEO | EES | EEZ | EFA |
EFAD | EFAV | EFAX | EFG | EFIV | EFN |
EFNL | EFRA | EFV | EGIS | EGPT | EGRW |
EGUS | EIDO | EINC | EIPX | EIRL | EIS |
EKAR | EKG | EKH | ELG | ELR | ELV |
EMAG | EMB | EMBB | EMBH | EMBU | EMCA |
EMCD | EMCG | EMCH | EMCR | EMDD | EMDG |
EMDI | EMDV | EMEM | EMER | EMEY | EMFM |
EMFN | EMFQ | EMFT | EMG | EMGC | EMGD |
EMGF | EMHD | EMHY | EMIF | EMLC | EMLP |
EMM | EMMT | EMPW | EMQQ | EMRE | EMSG |
EMSO | EMT | EMTL | EMV | EMXC | EMXF |
EMZA | ENFR | ENGN | ENOR | ENRG | ENTR |
ENY | ENZL | EOPS | EPHE | EPI | EPOL |
EPP | EPRE | EPRF | EPRO | EPS | EPU |
EQAL | EQIN | EQL | EQLT | EQRR | EQUL |
EQWL | EQWM | EQWS | ERET | ERGF | ERM |
ERSX | ERUS | ERX | ESG | ESGA | ESGD |
ESGE | ESGF | ESGG | ESGL | ESGN | ESGS |
ESGU | ESGV | ESGW | ESGY | ESIX | ESML |
ESMV | ESNG | ESPO | ESR | ETHO | ETPA |
EUDG | EUDV | EUFL | EUFN | EUMF | EUMV |
EURL | EURZ | EUSA | EUSC | EUXL | EVAL |
EVEN | EVX | EWA | EWAC | EWC | EWCO |
EWD | EWEB | EWEF | EWEM | EWG | EWGS |
EWH | EWHS | EWI | EWJ | EWK | EWL |
EWM | EWMC | EWMD | EWN | EWO | EWP |
EWQ | EWRE | EWRI | EWRM | EWRS | EWS |
EWSC | EWSM | EWSS | EWT | EWU | EWUS |
EWW | EWX | EWY | EWZ | EWZS | EXB |
EXI | EXT | EYLD | EZA | EZJ | EZM |
EZU | EZY | FAA | FAB | FAD | FAIL |
FAN | FAS | FATT | FAUS | FBCG | FBCV |
FBM | FBND | FBT | FBZ | FCA | FCAN |
FCD | FCEF | FCG | FCHI | FCL | FCLD |
FCOM | FCOR | FCPI | FCQ | FCTR | FCV |
FCVT | FDD | FDEM | FDEV | FDG | FDHT |
FDIG | FDIS | FDIV | FDL | FDLO | FDM |
FDMO | FDN | FDNI | FDRR | FDRV | FDT |
FDTS | FDV | FDVV | FDWM | FEBZ | FEDM |
FEDX | FEEM | FEFN | FEG | FEHY | FEIG |
FEM | FEMB | FEMS | FENY | FEP | FEUS |
FEUZ | FEVR | FEX | FFHG | FFL | FFR |
FFSG | FFTG | FFTI | FFTY | FGD | FGEM |
FGM | FGRO | FHC | FHK | FHLC | FIDI |
FIDU | FIL | FILL | FINU | FINX | FIO |
FISR | FITE | FIVA | FIVG | FIW | FJP |
FKL | FKO | FKU | FLAG | FLAU | FLAX |
FLBR | FLCA | FLCH | FLCO | FLEE | FLEH |
FLFR | FLG | FLGB | FLGR | FLHK | FLIN |
FLIO | FLIY | FLJH | FLJP | FLKR | FLLA |
FLLV | FLM | FLMB | FLMI | FLMX | FLN |
FLOT | FLQD | FLQE | FLQG | FLQH | FLQL |
FLQM | FLQS | FLRG | FLRT | FLRU | FLSA |
FLSP | FLSW | FLTB | FLTR | FLTW | FLV |
FLYT | FLZA | FM | FMAG | FMAT | FMB |
FMET | FMF | FMIL | FMK | FMM | FMU |
FMV | FNCF | FNCL | FNDA | FNDB | FNDC |
FNDE | FNDF | FNDX | FNG | FNGG | FNI |
FNIO | FNK | FNTC | FNX | FNY | FOC |
FOMO | FONE | FOS | FOVL | FPA | FPE |
FPFD | FPRO | FPX | FPXE | FPXI | FQAL |
FRAK | FRDM | FREL | FRI | FRL | FRN |
FRNW | FSBD | FSMD | FSMO | FSST | FSTA |
FSYD | FSZ | FTA | FTAG | FTC | FTCS |
FTEC | FTGC | FTGS | FTHI | FTLB | FTLS |
FTQ | FTQI | FTRI | FTSL | FTSM | FTVA |
FTW | FTXD | FTXG | FTXH | FTXL | FTXN |
FTXO | FTXR | FTY | FUI | FUTY | FV |
FVAL | FVC | FVD | FVI | FVL | FWDB |
FWDD | FWDI | FXD | FXEU | FXG | FXH |
FXI | FXL | FXN | FXO | FXR | FXU |
FXZ | FYC | FYLG | FYT | FYX | FZB |
GAA | GAF | GAL | GAMR | GARD | GASL |
GASX | GBDV | GBF | GBGR | GBIL | GBLD |
GBLO | GBUY | GCC | GCOR | GCOW | GDAT |
GDIV | GDJJ | GDMA | GDNA | GDOC | GDVD |
GDX | GDXJ | GDXX | GEM | GEMD | GENY |
GERJ | GERM | GEUR | GEX | GFGF | GFIN |
GFOF | GGEM | GHII | GHS | GHYB | GHYG |
GIGB | GIGE | GII | GINN | GIVE | GIY |
GK | GLCN | GLDE | GLIF | GLIN | GLOF |
GLOV | GLRY | GMAN | GMET | GMF | GMFL |
GMFS | GML | GMM | GMOM | GMTB | GNAT |
GNMA | GNOM | GNR | GNRX | GOAT | GOAU |
GOEX | GOP | GOVT | GPAL | GQRE | GREI |
GREK | GRES | GRI | GRID | GRMY | GRNB |
GRNR | GRPC | GRV | GSAX | GSD | GSEE |
GSEU | GSEW | GSFP | GSG | GSGO | GSID |
GSIE | GSIG | GSJY | GSLC | GSMA | GSPY |
GSRA | GSSC | GSST | GSUS | GSY | GTAA |
GTEK | GTIP | GTO | GULF | GUNR | GUR |
GURU | GUSA | GUSH | GVAL | GVI | GVIP |
GVT | GWL | GWX | GXC | GXF | GXG |
GXTG | GYEN | GYLD | HACK | HACV | HACW |
HAHA | HAIL | HAO | HAP | HAPI | HAPY |
HART | HAUD | HAUZ | HAWX | HBTA | HBU |
HCOM | HCRF | HDAW | HDEE | HDEF | HDEZ |
HDG | HDGE | HDGI | HDIV | HDLS | HDMV |
HDRO | HDUS | HDV | HDWM | HDWX | HECO |
HEDJ | HEEM | HEET | HEFA | HEFV | HEGE |
HEGJ | HELX | HEMV | HEQT | HERD | HERO |
HEUS | HEUV | HEWC | HEWG | HEWI | HEWJ |
HEWL | HEWP | HEWU | HEWW | HEWY | HEZU |
HFEZ | HFGO | HFND | HFXE | HFXI | HFXJ |
HGEM | HGEU | HGI | HGSD | HHH | HIBL |
HIDE | HILO | HIPR | HIPS | HISF | HJEN |
HJPX | HKK | HLAL | HLGE | HMTM | HNDL |
HOLD | HOM | HOMZ | HOTL | HSCZ | HSMV |
HSPX | HTEC | HTUS | HUSE | HUSV | HVAL |
HVOL | HVPW | HYD | HYDD | HYDR | HYEM |
HYG | HYGH | HYGI | HYGV | HYHG | HYIH |
HYLD | HYLG | HYLS | HYLV | HYXU | IAH |
IAI | IAK | IAT | IAU | IBB | IBBJ |
IBBQ | IBCB | IBCC | IBCD | IBCE | IBD |
IBDA | IBDB | IBDC | IBDD | IBDF | IBDH |
IBDJ | IBDK | IBDL | IBDM | IBDN | IBDO |
IBDP | IBDQ | IBDT | IBHA | IBHB | IBHC |
IBHD | IBHE | IBLC | IBLN | IBMD | IBME |
IBMF | IBMG | IBMH | IBMI | IBND | IBRN |
IBUY | ICAN | ICAP | ICF | ICLN | ICOL |
ICOW | ICSH | ICVT | IDAT | IDEV | IDHB |
IDHD | IDHQ | IDLB | IDLV | IDMO | IDNA |
IDOG | IDRV | IDU | IDV | IDVO | IDX |
IECS | IEDI | IEF | IEFA | IEFN | IEHS |
IEI | IEIH | IEIL | IEIS | IELG | IEME |
IEMG | IEO | IESM | IETC | IEUR | IEUS |
IEV | IEZ | IFAS | IFEU | IFGL | IFLY |
IFNA | IFRA | IFSM | IFV | IGBH | IGE |
IGEM | IGF | IGHG | IGIB | IGM | IGN |
IGOV | IGRO | IGSB | IGU | IGV | IGW |
IHAK | IHDG | IHE | IHF | IHI | IHY |
IIH | IJH | IJJ | IJK | IJNK | IJR |
IJS | IJT | ILDR | ILF | ILTB | IMFL |
IMOM | IMTM | INCO | INDA | INDF | INDL |
INDS | INDY | INFL | INFR | INKM | INNO |
INTF | INXX | IOIL | IOO | IPAC | IPAY |
IPD | IPF | IPFF | IPK | IPKW | IPN |
IPO | IPOS | IPS | IPU | IPW | IQDE |
IQDF | IQDG | IQDY | IQIN | IQLT | IQM |
IQSI | IQSU | IRBO | IRO | IRV | IRY |
ISCF | ISDS | ISDX | ISEM | ISHG | ISHP |
ISI | ISMD | ISRA | IST | ISTB | ISVL |
ISZE | ITA | ITAN | ITB | ITEQ | ITF |
ITIP | ITM | ITOT | IUS | IUSB | IUSG |
IUSS | IUSV | IVAL | IVDG | IVE | IVEG |
IVES | IVLC | IVLU | IVOG | IVOL | IVOO |
IVOV | IVRA | IVSG | IVV | IVW | IWB |
IWC | IWD | IWF | IWFH | IWIN | IWL |
IWM | IWN | IWO | IWP | IWR | IWS |
IWTR | IWV | IWW | IWX | IWY | IWZ |
IXC | IXG | IXJ | IXN | IXP | IXUS |
IYC | IYE | IYF | IYG | IYH | IYJ |
IYK | IYLD | IYM | IYR | IYT | IYW |
IYY | IYZ | IZRL | JANZ | JAVA | JBBB |
JCO | JCPB | JCPI | JCTR | JDG | JDIV |
JEMA | JEPI | JETS | JGLD | JGRO | JHCB |
JHCS | JHDV | JHEM | JHID | JHMA | JHMC |
JHMD | JHME | JHMF | JHMH | JHMI | JHML |
JHMM | JHMS | JHMT | JHMU | JHPI | JHSC |
JIDA | JIG | JIRE | JKD | JKE | JKF |
JKG | JKH | JKI | JKJ | JKK | JKL |
JMBS | JMEE | JMIN | JMOM | JMST | JMUB |
JNUG | JOET | JPED | JPEM | JPEU | JPGB |
JPGE | JPHF | JPHY | JPIE | JPIN | JPMB |
JPME | JPMV | JPNL | JPRE | JPSE | JPST |
JPUS | JQUA | JRE | JRNY | JSCP | JSMD |
JSML | JUSA | JUST | JVAL | JXI | JZRO |
KALL | KARS | KBA | KBE | KBUY | KBWB |
KBWC | KBWD | KBWI | KBWP | KBWR | KBWX |
KBWY | KCE | KCNY | KDFI | KDIV | KEJI |
KEMP | KEMQ | KEMX | KESG | KFVG | KFYP |
KGHG | KGRN | KGRO | KIE | KLCD | KLD |
KLDW | KLEM | KLIP | KLNE | KME | KMED |
KMLM | KNG | KNGS | KNOW | KOCG | KOIN |
KOKU | KOL | KOMP | KORP | KORU | KRBN |
KRE | KRMA | KROO | KROP | KRU | KSCD |
KURE | KVLE | KWEB | KWT | KXI | LABU |
LALT | LATM | LBJ | LBTA | LCTD | LCTU |
LDEM | LDRI | LDRS | LDSF | LEAD | LEGR |
LEMB | LEND | LFEQ | LGEM | LGLV | LGOV |
LIT | LIV | LKOR | LLDM | LLEM | LLSC |
LLSP | LMBS | LNGR | LOPX | LOUP | LOWC |
LQD | LQDH | LRGE | LRGF | LRNZ | LSAF |
LSAT | LSLT | LTL | LUXE | LVHB | LVHD |
LVHE | LVHI | LVIN | LVL | LVOL | LVUS |
LWPE | LYFE | MAAX | MAGA | MAKX | MAMB |
MARB | MARZ | MATF | MATH | MATL | MAUI |
MBB | MBCC | MBOX | MBSD | MCEF | MCHI |
MCRO | MCSE | MDCP | MDD | MDEV | MDIV |
MDLL | MDY | MDYG | MDYV | MEAR | MEME |
MES | META | METV | MEXX | MFDX | MFEM |
MFMS | MFUL | MFUS | MGC | MGK | MGV |
MID | MIDE | MIDF | MIDU | MIDZ | MILN |
MINC | MISL | MJ | MJUS | MKH | MLN |
MLPA | MLPX | MMIN | MMIT | MMLG | MMSC |
MMTM | MNA | MNM | MOAT | MOHR | MOM |
MONY | MOO | MOOD | MOON | MORT | MOTE |
MOTG | MOTI | MOTO | MPRO | MRAD | MRGR |
MSGR | MSOS | MTK | MTUM | MUB | MULT |
MUSI | MVIN | MVP | MVPS | MVV | MXDU |
MXI | MZG | MZN | MZO | NACP | NAIL |
NANR | NASH | NASI | NDIV | NDJI | NDVG |
NEAR | NEED | NERD | NETL | NFLT | NFO |
NFRA | NIFE | NIWM | NLR | NOBL | NOMO |
NORW | NSCS | NSPI | NSPY | NTKI | NTSE |
NTSI | NUAG | NUBD | NUCL | NUDM | NUDV |
NUEM | NUGO | NUGT | NUHY | NULC | NULG |
NULV | NUMG | NUMV | NURE | NUSA | NUSC |
NUSI | NVQ | NWLG | NXTE | NXTG | NY |
NYC | NYCC | NYF | NZAC | OASI | OBOR |
OCEN | OCIO | OEF | OEUR | OEW | OGEM |
OGIG | OIH | OLD | OMFL | OMFS | OMOM |
OND | ONEF | ONEK | ONEO | ONEQ | ONEV |
ONEY | ONG | ONLN | ONOF | ONTL | OOTO |
OPD | OQAL | ORG | OSCV | OSIZ | OTP |
OTR | OUSA | OUSM | OVB | OVF | OVL |
OVLC | OVLH | OVLU | OVM | OVOL | OVS |
OVT | OWNS | OYLD | PABU | PACA | PAF |
PAGG | PALC | PAMC | PAO | PAVE | PAWZ |
PBD | PBDM | PBE | PBEE | PBJ | PBP |
PBS | PBSM | PBTQ | PBUS | PBW | PCA |
PCEF | PDBC | PDEV | PDN | PDP | PEGA |
PEJ | PEK | PEX | PEXL | PEY | PEZ |
PFA | PFF | PFFA | PFFD | PFFR | PFI |
PFIG | PFIX | PFM | PFUT | PFXF | PGAL |
PGF | PGHY | PGJ | PGRO | PGX | PHB |
PHDG | PHO | PHYL | PIC | PICB | PICK |
PID | PIE | PILL | PIN | PINK | PIO |
PIQ | PIV | PIZ | PJB | PJF | PJG |
PJM | PJP | PKB | PKN | PKOL | PKW |
PLAT | PLCY | PLDR | PLND | PLRG | PLTL |
PLTM | PLW | PMA | PMNA | PMOM | PMPT |
PMR | PNQI | PNXQ | POTX | PPA | PPH |
PPI | PPLC | PPSC | PQBW | PQDI | PQIN |
PQLC | PQSC | PQSG | PQSV | PQY | PQZ |
PRAY | PREF | PRF | PRFZ | PRME | PRN |
PRNT | PSAU | PSC | PSCC | PSCD | PSCE |
PSCF | PSCH | PSCI | PSCM | PSCT | PSCU |
PSDN | PSET | PSFF | PSI | PSIL | PSJ |
PSK | PSL | PSMB | PSMC | PSMG | PSMM |
PSP | PSQ | PSR | PSTL | PSY | PTE |
PTEU | PTF | PTH | PTIN | PTJ | PTLC |
PTMC | PTNQ | PTO | PTRP | PUI | PUTW |
PUW | PVAL | PVI | PWB | PWC | PWJ |
PWND | PWO | PWP | PWT | PWV | PWY |
PWZ | PXE | PXF | PXH | PXI | PXJ |
PXLC | PXLG | PXLV | PXMC | PXMG | PXMV |
PXN | PXQ | PXR | PXSC | PXSG | PXSV |
PXUS | PY | PYH | PYZ | PZA | PZD |
PZI | PZJ | PZT | QABA | QAI | QARP |
QAT | QCAN | QCLN | QCLR | QDEF | QDEM |
QDF | QDIV | QDPL | QDXU | QDYN | QED |
QEFA | QEH | QEM | QEMM | QGBR | QGEM |
QGRO | QGTA | QID | QINC | QINT | QLC |
QLD | QLS | QLT | QLTA | QLTB | QLTC |
QLV | QLVD | QLVE | QMJ | QMN | QMOM |
QPT | QPX | QQC | QQD | QQEW | QQJG |
QQMG | QQQ | QQQA | QQQE | QQQJ | QQQM |
QQQN | QQQQ | QQXT | QRFT | QRMI | QSY |
QTEC | QTR | QTUM | QUAL | QUS | QVAL |
QVM | QVML | QVMM | QVMS | QWLD | QXGG |
QXMI | QXRR | QXTR | QXUS | QYLD | QYLG |
RAAX | RAFE | RALS | RAVI | RAYS | RBIN |
RBL | RBLD | RBUS | RCD | RDIV | RDMX |
RDOG | RDVI | RDVY | RECS | REDV | REEM |
REET | REFA | REGL | REIT | REM | REMG |
REMX | RESE | RESI | RESP | RETL | REVS |
REZ | RFAP | RFDA | RFDI | RFEM | RFEU |
RFF | RFFC | RFG | RFUN | RFV | RGI |
RGLB | RGRO | RHS | RIDV | RIET | RIGS |
RIGZ | RING | RISN | RKH | RLY | RNDM |
RNDV | RNEM | RNLC | RNMC | RNRG | RNSC |
ROAM | ROB | ROBO | ROBT | ROCI | RODE |
RODM | ROGS | ROI | ROKT | ROM | ROMO |
ROOF | RORE | RORO | ROSC | ROUS | RPG |
RPQ | RPV | RPX | RRF | RRGR | RSCO |
RSP | RSPE | RSPY | RSU | RSUN | RSX |
RSXJ | RTH | RTL | RTM | RTR | RTYD |
RULE | RUSL | RUSS | RVRS | RWCD | RWDC |
RWDE | RWED | RWG | RWGV | RWIU | RWJ |
RWK | RWL | RWLS | RWM | RWO | RWR |
RWSL | RWUI | RWV | RWVG | RWW | RWX |
RXI | RXL | RYE | RYF | RYH | RYJ |
RYLD | RYLG | RYT | RYU | RZG | RZV |
SAA | SAEF | SAGG | SATO | SAVN | SBEU |
SBIO | SBUS | SCAP | SCHA | SCHB | SCHC |
SCHD | SCHE | SCHF | SCHG | SCHH | SCHI |
SCHJ | SCHK | SCHM | SCHO | SCHP | SCHQ |
SCHR | SCHV | SCHX | SCHY | SCHZ | SCIF |
SCIN | SCJ | SCLP | SCOG | SCTR | SCZ |
SDAG | SDCI | SDEM | SDG | SDGA | SDIV |
SDOG | SDOW | SDS | SDSI | SDVY | SDY |
SEA | SECT | SEMI | SENT | SEPZ | SFY |
SFYF | SFYX | SGDJ | SGDM | SGGG | SGQI |
SH | SHBT | SHE | SHLD | SHMO | SHNY |
SHOC | SHV | SHVY | SHY | SHYD | SHYG |
SIL | SILJ | SIMS | SIPE | SIXA | SIXH |
SIXL | SIXS | SIZ | SIZE | SKOR | SKYY |
SLBT | SLDR | SLIM | SLOW | SLQD | SLT |
SLVP | SLVY | SLX | SLY | SLYG | SLYV |
SMB | SMCP | SMD | SMDV | SMDY | SMH |
SMIG | SMIN | SMLE | SMLF | SMLL | SMLV |
SMMD | SMMV | SMOG | SNPE | SNSR | SNUG |
SOCL | SOLR | SOVB | SOXL | SOXQ | SOXX |
SPAK | SPBC | SPCX | SPD | SPDV | SPDW |
SPEM | SPEU | SPGM | SPGP | SPHB | SPHD |
SPHQ | SPLG | SPLV | SPMD | SPMO | SPMV |
SPQQ | SPRE | SPSB | SPSM | SPTM | SPUC |
SPUN | SPUS | SPUU | SPVM | SPVU | SPXE |
SPXH | SPXL | SPXN | SPXS | SPXT | SPXU |
SPXV | SPY | SPYB | SPYC | SPYD | SPYG |
SPYV | SPYX | SQEW | SQLV | SQQQ | SRET |
SRVR | SSAM | SSFI | SSLY | SSO | SSPX |
SSPY | SSUS | SSXU | STH | STIP | STLC |
STLG | STLV | STMB | STOT | STRV | STSB |
STXD | STXG | STXK | STXV | STXX | SUB |
SUBZ | SULR | SUNY | SUPL | SURE | SUSA |
SUSC | SUSL | SVAL | SVOL | SWAN | SWAR |
SWH | SWIN | SXQG | SXUS | SYE | SYG |
SYLD | SYTL | SYUS | SYV | SZNE | TAIL |
TAN | TAO | TAWK | TAXF | TAXR | TBF |
TBLU | TBT | TCHF | TCHI | TCHP | TCTL |
TDD | TDH | TDIV | TDN | TDSA | TDSB |
TDSC | TDSD | TDSE | TDTF | TDTT | TDV |
TDVG | TDX | TECB | TECL | TEMP | TENG |
TEQI | TERM | TETF | TFIV | TFLO | TFLT |
TGEM | TGN | TGR | TGRW | THCX | THD |
THHY | THNQ | THRK | TILT | TINT | TINY |
TIP | TIPX | TLDH | TLEH | TLH | TLT |
TLTD | TLTE | TMDV | TMF | TMFC | TMFE |
TMFG | TMFM | TMFS | TMFX | TMW | TNA |
TOK | TOKE | TOLZ | TONS | TOTL | TPAY |
TPHD | TPHE | TPIF | TPLC | TPLE | TPOR |
TPSC | TPYP | TQQQ | TRFM | TRND | TRPL |
TRSK | TRTY | TSPA | TTAC | TTAI | TTFS |
TTH | TUR | TUSA | TUTI | TUTT | TWEB |
TWM | TWOK | TWON | TYD | TYLG | TYNE |
TYNS | TZD | TZE | TZG | TZI | TZL |
TZO | TZV | TZW | TZY | UAE | UAV |
UBD | UBIO | UBOT | UBT | UCC | UCOM |
UCYB | UDBI | UDIV | UDOW | UEVM | UGE |
UGEM | UIVM | UJB | UK | UKF | UKK |
UKW | ULQ | ULST | ULTR | ULVM | UMDD |
UMI | UOP | UPRO | UPW | UPWD | URA |
URE | URTH | URTY | USAI | USD | USEQ |
USHG | USIG | USLB | USMC | USMF | USMV |
USPX | USRT | USSD | USSG | UST | USVM |
USWD | USXF | UTES | UTH | UTLF | UTLT |
UTRN | UTSL | UUP | UVDV | UVG | UVT |
UVU | UWC | UWM | UXI | UYG | UYM |
VALQ | VALX | VAMO | VAW | VB | VBK |
VBR | VCAR | VCIT | VCLN | VCLO | VCLT |
VCR | VCSH | VDC | VDE | VEA | VEGA |
VEGI | VERS | VESH | VETS | VEU | VFH |
VFIN | VFLQ | VFMF | VFMO | VFMV | VFQY |
VFVA | VGEM | VGFO | VGIT | VGK | VGSH |
VGT | VHT | VICE | VIG | VIGI | VIOG |
VIOO | VIOV | VIRS | VIS | VIXH | VLLV |
VLML | VLSM | VLU | VLUE | VMOT | VNAM |
VNLA | VNM | VNQ | VNQI | VO | VOE |
VONE | VONG | VONV | VOO | VOOG | VOOV |
VOT | VOX | VPC | VPL | VPN | VPOP |
VPU | VR | VRAI | VRP | VSDA | VSGX |
VSL | VSMV | VSPY | VSS | VT | VTC |
VTHR | VTI | VTRN | VTV | VTWG | VTWO |
VTWV | VUG | VV | VWID | VWO | VXF |
VXUS | VYM | VYMI | WANT | WBAL | WBIA |
WBIB | WBIC | WBID | WBIE | WBIF | WBIG |
WBIH | WBII | WBIL | WBIN | WBIR | WBIT |
WBIY | WCAT | WCBR | WCHN | WCLD | WDIV |
WDNA | WDRW | WDTI | WEAR | WEBL | WEXP |
WFH | WFVK | WGRO | WINN | WIP | WIZ |
WKLY | WLDR | WLTH | WMCR | WMH | WNDY |
WOMN | WOOD | WPS | WREI | WSKY | WTAI |
WTRE | WTRX | WTV | WUGI | WUSA | WWJD |
WWOW | WXSP | XAR | XB | XBB | XBI |
XBUY | XCCC | XCEM | XCLR | XCOM | XDAT |
XDNA | XES | XFIV | XGC | XHB | XHE |
XHLF | XHMO | XHS | XHYC | XHYD | XHYE |
XHYF | XHYH | XHYI | XHYT | XITK | XJH |
XJR | XKFS | XKII | XKST | XLB | XLBS |
XLBT | XLC | XLE | XLES | XLF | XLFS |
XLG | XLI | XLIS | XLK | XLKS | XLP |
XLPS | XLRE | XLSR | XLU | XLUS | XLV |
XLVO | XLVS | XLY | XLYS | XME | XMHQ |
XMLV | XMMO | XMPT | XMVM | XMX | XNTK |
XONE | XOP | XOUT | XPH | XPND | XRLV |
XRMI | XRO | XRT | XSD | XSHD | XSHQ |
XSLV | XSMO | XSOE | XSVM | XSVN | XSW |
XT | XTEN | XTH | XTL | XTN | XTR |
XTRE | XTWO | XTWY | XUSA | XVOL | XVV |
XWEB | XYLD | XYLG | YAO | YDIV | YESR |
YINN | YLCO | YLD | YLDE | YMLI | YMLP |
YOLO | YPRO | YPS | YUMY | YYY | ZCAN |
ZDEU | ZGBR | ZGEN | ZHOK | ZIG | ZLRG |
ZMLP | ZSML |
To add US ETF Constituents data to your algorithm, call the AddUniverseadd_universe and Universe.ETFuniverse.etf methods. To select which constituents occupy the universe, provide the ETF Symbol and a selection function.
class ETFConstituentUniverseAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2018, 1, 1)
self.set_end_date(2020, 8, 25)
self.set_cash(100000)
self.universe_settings.asynchronous = True
self._universe = self.add_universe(self.universe.etf("SPY", self.universe_settings, self.etf_constituents_filter))
namespace QuantConnect
{
public class ETFConstituentUniverseAlgorithm : QCAlgorithm
{
public override void Initialize()
{
SetStartDate(2018, 1, 1);
SetEndDate(2020, 8, 25);
SetCash(100000);
UniverseSettings.Asynchronous = true;
_universe = AddUniverse(Universe.ETF("SPY", UniverseSettings, ETFConstituentsFilter));
}
}
}
For more information about universe settings, see Settings.
To access the US ETF Constituent data, use the ETFConstituentUniverse objects in your selection function. The data is available in daily resolution. The Symbol objects you return from your selection function defines the universe constituents.
def etf_constituents_filter(self, constituents: List[ETFConstituentUniverse]) -> List[Symbol]:
for c in constituents:
self.debug(f'{c.end_time} :: {c.last_update} :: {c.weight} :: {c.shares_held} :: {c.market_value}')
return [x.symbol for x in constituents]
public IEnumerable<Symbol> ETFConstituentsFilter(IEnumerable<ETFConstituentUniverse> constituents)
{
foreach (var c in constituents)
{
Debug($"{c.EndTime} :: {c.LastUpdate} :: {c.Weight} :: {c.SharesHeld} :: {c.MarketValue}");
}
return constituents.Select(c => c.Symbol);
}
You can get historical universe data in an algorithm and in the Research Environment.
To get historical universe data in an algorithm, call the Historyhistory method with the Universe object and the lookback period. If there is no data in the period you request, the history result is empty.
var history = History(_universe, 30, Resolution.Daily);
foreach (var constituents in history)
{
foreach (ETFConstituentUniverse constituent in constituents)
{
Log($"{constituent.Symbol} weight at {constituent.EndTime}: {constituent.Weight}");
}
}
# DataFrame example where the columns are the ETFConstituentUniverse attributes:
df_history = self.history(self.universe, 30, Resolution.DAILY, flatten=True)
# Series example where the values are lists of ETFConstituentUniverse objects:
series_history = self.history(self.universe, 30, Resolution.DAILY)
for (universe_symbol, time), constituents in series_history.items():
for constituent in constituents:
self.log(f'{constituent.symbol} weight at {constituent.end_time}: {constituent.weight}')
To get historical universe data in research, call the UniverseHistoryuniverse_history method with the Universe object and the lookback period. The UniverseHistoryuniverse_history returns the filtered universe. If there is no data in the period you request, the history result is empty.
var universeHistory = qb.UniverseHistory(universe, qb.Time.AddDays(-30), qb.Time);
foreach (var constituents in universeHistory )
{
foreach (ETFConstituentUniverse constituent in constituents)
{
Console.WriteLine($"{constituent.Symbol} weight at {constituent.EndTime}: {constituent.Weight}");
}
}
# DataFrame example where the columns are the ETFConstituentUniverse attributes:
df_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time, flatten=True)
# Series example where the values are lists of ETFConstituentUniverse objects:
series_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time)
for (universe_symbol, time), constituents in series_history.items():
for constituent in constituents:
print(f"{constituent.symbol} weight at {constituent.end_time}: {constituent.weight}")
You can call the Historyhistory method in Research.
The ETF Constituents dataset provides ETFConstituentUniverse objects, which have the following attributes:
The following example algorithm creates a dynamic universe of the 10 largest US Equities in the SPY ETF. Each day, the algorithm forms a dollar-neutral and market-neutral portfolio by buying the 10 ETF constituents and shorting the SPY ETF.
from AlgorithmImports import *
from QuantConnect.DataSource import *
class ETFConstituentUniverseAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2016, 1, 1)
self.set_end_date(2021, 1, 1)
self.set_cash(100000)
self.universe_settings.asynchronous = True
self.universe_settings.resolution = Resolution.MINUTE
self.spy = self.add_equity("SPY").symbol
# Add universe selection on SPY's constituents to select only from large cap stocks
# Save the universe to access its members for historical data call
self._universe = self.add_universe(self.universe.etf(self.spy, self.universe_settings, self.etf_constituents_filter))
# Historical Universe data, so you can work on the selection longitudinally
history = self.history(self._universe, 30, Resolution.DAILY)
for (universe_symbol, time), constituents in history.items():
for constituent in constituents:
self.debug(f'{constituent.symbol}: {constituent.weight}')
self.weight_by_symbol = {}
# Rebalance daily using scheduled event since selection is on daily basis
self.schedule.on(
self.date_rules.every_day(self.spy),
self.time_rules.after_market_open(self.spy, 1),
self.rebalance)
def etf_constituents_filter(self, constituents: List[ETFConstituentUniverse]) -> List[Symbol]:
# The top 10 weighted securities are considered better active selections
# Save the weights for position sizing
selected = sorted([c for c in constituents if c.weight],
key=lambda c: c.weight, reverse=True)[:10]
self.weight_by_symbol = {c.symbol: c.weight for c in selected}
return list(self.weight_by_symbol.keys())
def rebalance(self) -> None:
spy_weight = sum(self.weight_by_symbol.values())
# Liquidate the ones not in top 10 weights
if spy_weight > 0:
for symbol in self.portfolio.Keys:
if symbol not in self.weight_by_symbol:
self.liquidate(symbol)
# Create a long-short portfolio to earn excess return of the top 10 weighted stocks from SPY
for symbol, weight in self.weight_by_symbol.items():
self.set_holdings(symbol, 0.5 * weight / spy_weight)
self.set_holdings(self.spy, -0.5)
def on_securities_changed(self, changes: SecurityChanges) -> None:
# Liquidate the ones not in top 10 weights
for security in changes.removed_securities:
if security.invested:
self.liquidate(security.symbol, 'Removed From Universe')
for security in changes.added_securities:
# Historical data
history = self.history(security.symbol, 7, Resolution.DAILY)
self.debug(f'We got {len(history)} from our history request for {security.symbol}')
using QuantConnect.DataSource;
namespace QuantConnect
{
public class ETFConstituentUniverseAlgorithm : QCAlgorithm
{
private Symbol _spy;
private Universe _universe;
private Dictionary<Symbol, decimal> _weightBySymbol = new Dictionary<Symbol, decimal>();
public override void Initialize()
{
SetStartDate(2016, 1, 1);
SetEndDate(2021, 1, 1);
SetCash(100000);
UniverseSettings.Asynchronous = true;
UniverseSettings.Resolution = Resolution.Minute;
// Add universe selection on SPY's constituents to select only from large cap stocks
// Save the universe to access its members for historical data call
_spy = AddEquity("SPY").Symbol;
_universe = AddUniverse(Universe.ETF(_spy, UniverseSettings, ETFConstituentsFilter));
// Historical Universe data, so you can work on the selection longitudinally
var history = History(_universe, 30, Resolution.Daily);
foreach (var constituents in history)
{
foreach (ETFConstituentUniverse constituent in constituents)
{
Debug($"{constituent.Symbol} weight at {constituent.EndTime}: {constituent.Weight}");
}
}
// Rebalance daily using scheduled event since selection is on daily basis
Schedule.On(
DateRules.EveryDay(_spy),
TimeRules.AfterMarketOpen(_spy, 1),
Rebalance);
}
private IEnumerable<Symbol> ETFConstituentsFilter(IEnumerable<ETFConstituentUniverse> constituents)
{
// The top 10 weighted securities are considered better active selections
// Save the weights for position sizing
_weightBySymbol = constituents.OrderByDescending(c => c.Weight).Take(10)
.ToDictionary(c => c.Symbol, c => c.Weight ?? 0m);
return _weightBySymbol.Keys;
}
private void Rebalance()
{
var spyWeight = _weightBySymbol.Values.Sum();
// Liquidate the ones not in top 10 weights
if (spyWeight > 0)
{
foreach(var symbol in Portfolio.Keys)
{
if (!_weightBySymbol.ContainsKey(symbol))
{
Liquidate(symbol);
}
}
// Create a long-short portfolio to earn excess return of the top 10 weighted stocks from SPY
foreach(var kvp in _weightBySymbol)
{
SetHoldings(kvp.Key, 0.5m * kvp.Value / spyWeight);
}
SetHoldings(_spy, -0.5m);
}
}
public override void OnSecuritiesChanged(SecurityChanges changes)
{
// Liquidate the ones not in top 10 weights
foreach (var security in changes.RemovedSecurities.Where(x => x.Invested))
{
Liquidate(security.Symbol, "Removed From Universe");
}
foreach (var security in changes.AddedSecurities)
{
// Historical data
var history = History(security.Symbol, 7, Resolution.Daily);
Debug($"We got {history.Count()} from our history request for {security.Symbol}");
}
}
}
}
The following example algorithm creates a dynamic universe of the 10 largest US Equities in the SPY ETF. Each day, the algorithm forms a dollar-neutral and market-neutral portfolio by buying the 10 ETF constituents and shorting the SPY ETF.
from AlgorithmImports import *
from QuantConnect.DataSource import *
class ETFConstituentUniverseFrameworkAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2016, 1, 1)
self.set_end_date(2021, 1, 1)
self.set_cash(100000)
self.universe_settings.asynchronous = True
self.universe_settings.resolution = Resolution.MINUTE
self.weight_by_symbol = {}
# Add universe selection on SPY's constituents to select only from large cap stocks
# Save the universe to access its members for historical data call
spy = self.add_equity("SPY").symbol
self.add_universe_selection(ETFConstituentsUniverseSelectionModel(spy, self.universe_settings, self.etf_constituents_filter))
# Add alpha model that set normalized weight as investment insight
self.add_alpha(ETFConstituentsAlphaModel(self, spy))
# Set up portfolio construction model that invest by the insight weights
pcm = InsightWeightingPortfolioConstructionModel()
# Avoid excessive rebalance on insight changes
pcm.rebalance_on_insight_changes = False
self.set_portfolio_construction(pcm)
self.add_risk_management(NullRiskManagementModel())
self.set_execution(ImmediateExecutionModel())
def etf_constituents_filter(self, constituents: List[ETFConstituentUniverse]) -> List[Symbol]:
# The top 10 weighted securities are considered better active selections
# Save the weights for position sizing
selected = sorted([c for c in constituents if c.weight],
key=lambda c: c.weight, reverse=True)[:10]
self.weight_by_symbol = {c.symbol: c.weight for c in selected}
return list(self.weight_by_symbol.keys())
class ETFConstituentsAlphaModel(AlphaModel):
def __init__(self, algorithm: QCAlgorithm, etf: Symbol) -> None:
self.algorithm = algorithm
self.etf = etf
self.day = -1
def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
# Rebalance daily since selection is on daily basis
if self.day == algorithm.time.day:
return []
self.day = algorithm.time.day
insights = []
# Create a long-short portfolio to earn excess return of the top 10 weighted stocks from SPY
etf_weight = sum(self.algorithm.weight_by_symbol.values())
if etf_weight> 0:
# Invest half the portfolio by normalized weights of the top 10 constituents
for symbol, weight in self.algorithm.weight_by_symbol.items():
if algorithm.securities.contains_key(symbol):
insights.append(Insight.price(symbol, Expiry.END_OF_DAY, InsightDirection.UP, weight=0.5*weight/etf_weight))
# Short the other half with SPY, looking to profit from the active selection
insights.append(Insight.price(self.etf, Expiry.END_OF_DAY, InsightDirection.DOWN, weight=0.5))
return insights
def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
# Liquidate the ones not in top 10 weights
for security in changes.removed_securities:
if security.invested:
algorithm.liquidate(security.symbol, 'Removed From Universe')
for security in changes.added_securities:
# Historical data
history = algorithm.history(security.symbol, 7, Resolution.DAILY)
algorithm.debug(f'We got {len(history)} from our history request for {security.symbol}')
using QuantConnect.DataSource;
namespace QuantConnect
{
public class ETFConstituentUniverseFrameworkAlgorithm : QCAlgorithm
{
public Dictionary<Symbol, decimal> WeightBySymbol = new Dictionary<Symbol, decimal>();
public override void Initialize()
{
SetStartDate(2016, 1, 1);
SetEndDate(2021, 1, 1);
SetCash(100000);
UniverseSettings.Asynchronous = true;
UniverseSettings.Resolution = Resolution.Minute;
// Add universe selection on SPY's constituents to select only from large cap stocks
// Save the universe to access its members for historical data call
var spy = AddEquity("SPY").Symbol;
AddUniverseSelection(new ETFConstituentsUniverseSelectionModel(spy, UniverseSettings, ETFConstituentsFilter));
// Add alpha model that set normalized weight as investment insight
AddAlpha(new ETFConstituentsAlphaModel(this, spy));
// Set up portfolio construction model that invest by the insight weights
var pcm = new InsightWeightingPortfolioConstructionModel();
// Avoid excessive rebalance on insight changes
pcm.RebalanceOnInsightChanges = false;
SetPortfolioConstruction(pcm);
AddRiskManagement(new NullRiskManagementModel());
SetExecution(new ImmediateExecutionModel());
}
private IEnumerable<Symbol> ETFConstituentsFilter(IEnumerable<ETFConstituentUniverse> constituents)
{
// The top 10 weighted securities are considered better active selections
// Save the weights for position sizing
WeightBySymbol = constituents.OrderByDescending(c => c.Weight).Take(10)
.ToDictionary(c => c.Symbol, c => c.Weight ?? 0m);
return WeightBySymbol.Keys;
}
}
public class ETFConstituentsAlphaModel : AlphaModel
{
private int _day = -1;
private Symbol _etf;
private ETFConstituentsDataFrameworkAlgorithm _algorithm;
public ETFConstituentsAlphaModel(ETFConstituentsDataFrameworkAlgorithm algorithm, Symbol etf)
{
_etf = etf;
_algorithm = algorithm;
}
public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice slice)
{
// Rebalance daily since selection is on daily basis
if (_day == algorithm.Time.Day)
{
return Enumerable.Empty<Insight>();
}
_day = algorithm.Time.Day;
var insights = new List<Insight>();
// Create a long-short portfolio to earn excess return of the top 10 weighted stocks from SPY
var etfWeight = (double)_algorithm.WeightBySymbol.Values.Sum();
if (etfWeight > 0)
{
// Invest half the portfolio by normalized weights of the top 10 constituents
foreach(var kvp in _algorithm.WeightBySymbol)
{
insights.Add(Insight.Price(kvp.Key, Expiry.EndOfDay, InsightDirection.Up, weight: (double)kvp.Value/etfWeight * 0.5));
}
// Short the other half with SPY, looking to profit from the active selection
insights.Add(Insight.Price(_etf, Expiry.EndOfDay, InsightDirection.Down, weight: 0.5));
}
return insights;
}
public override void OnSecuritiesChanged(QCAlgorithm algorithm, SecurityChanges changes)
{
// Liquidate the ones not in top 10 weights
foreach (var security in changes.RemovedSecurities.Where(x => x.Invested))
{
algorithm.Liquidate(security.Symbol, "Removed From Universe");
}
foreach (var security in changes.AddedSecurities)
{
// Historical data
var history = algorithm.History(security.Symbol, 7, Resolution.Daily);
algorithm.Debug($"We got {history.Count()} from our history request for {security.Symbol}");
}
}
}
}
The following example lists ETF constituents with the greatest weight in the SPY:
var qb = new QuantBook();
// Add the ETF
var symbol = qb.AddEquity("SPY").Symbol;
// Add ETF Universe Selection
IEnumerable<Symbol> ETFConstituentsFilter(IEnumerable<ETFConstituentUniverse> constituents)
{
// Take the top 10 weighted constituents
return constituents
.OrderByDescending(c => c.Weight)
.Take(10)
.Select(c => c.Symbol);
}
var universe = qb.AddUniverse(qb.Universe.ETF(spy, qb.UniverseSettings, ETFConstituentsFilter));
// Historical Universe data
var universeHistory = qb.UniverseHistory(universe, qb.Time.AddDays(-30), qb.Time);
foreach (var constituents in universeHistory )
{
foreach (ETFConstituentUniverse constituent in constituents)
{
Console.WriteLine($"{constituent.Symbol} weight at {constituent.EndTime}: {constituent.Weight}");
}
}
qb = QuantBook()
# Add the ETF
qb.spy = qb.add_equity("SPY").symbol
# Add ETF Universe Selection
def etf_constituents_filter(constituents):
# Take the top 10 weighted constituents
selected = sorted([c for c in constituents if c.weight],
key=lambda c: c.weight, reverse=True)[:10]
return [c.symbol for c in selected]
universe = qb.add_universe(qb.universe.etf(qb.spy, qb.universe_settings, etf_constituents_filter))
# Historical Universe data
universe_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time)
for (universe_symbol, time), constituents in universe_history.items():
for constituent in constituents:
print(f"{constituent.symbol} weight at {constituent.end_time}: {constituent.weight}")
US ETF Constituents is allowed to be used in the cloud for personal and commercial projects for free. The data is permissioned for use within the licensed organization only
Free | Documentation
US ETF Constituents can be downloaded on premise with the LEAN CLI, for a charge per file downloaded. This download is for the licensed organization's internal LEAN use only and cannot be redistributed or converted in any format.
Starting at 50 QCC/file | Learn More
LEAN CLI is a cross-platform wrapper on the QuantConnect algorithmic trading engine called LEAN. The CLI makes using LEAN incredibly easy, reducing most of the pain points of developing and managing an algorithmic trading strategy to a few lines of bash.
Using the CLI you can download the same data QuantConnect hosts in the cloud for a small fee. These fees are per file downloaded, and are paid for in QuantConnect-Credits (QCC). We recommend purchasing credits to enable downloading.
The CLI command generator is a helpful tool to generate a copy-paste command to download this dataset from the form below.
lean data download \
--dataset "US ETF Constituents" \
--data-type "trade" \
--ticker "SPY, QQQ" \
--start "20240217" \
--end "20250216"
lean data download `
--dataset "US ETF Constituents" `
--data-type "trade" `
--ticker "SPY, QQQ" `
--start "20240217" `
--end "20250216"
Free access for universe selection strategies on the QuantConnect Cloud. Create custom filters using price and volume for the ETF constituents.
On premise download of ETF constituent data files, including closing price and volume for the day for local backtesting.
Bulk download of the entire US ETF Constituents dataset
Bulk download of the entire US ETF Constituents dataset
What people are saying about this
This product has not received any reviews yet, be the first to post one!
Rate the Module:
Provider offers 4 licensing options
Explore free and paid datasets available on QuantConnect covering fundamentals, pricing, and alternative options.
Dataset Status from to
No Runs
OK
Degraded
Failure
Explore free and paid datasets available on QuantConnect covering fundamentals, pricing, and alternative options.
Lorem ipsum dolor sit amet conjectura lorem ipsum dolor sit amet conjectura lorem ipsum
Configuration Keys
Environment Variables
Lorem ipsum dolor sit amet conjectura lorem ipsum dolor sit amet conjectura lorem ipsum
File Link
Lorem ipsum dolor sit amet conjectura lorem ipsum dolor sit amet conjectura lorem ipsum
Lorem ipsum dolor sit amet conjectura lorem ipsum dolor sit amet conjectura lorem ipsum
Upload a manually created tar or zip file to all cloud data systems.
Add a link and click the Sync Dataset button to upload the dataset
Upload Destinations
The dataset synchronizer is an internal tool for the QuantConnect team to upload data to the
cloud data storage environments. It supports TAR files which are extracted in the root directory
of the cloud data environments.
Take extreme care to carefully structure your data TAR package with
the same folders as the LEAN data folder. Ensure all folders and file names are lowercase as Linux is case-sensitive.
Support
Algorithm Lab is your playground for developing and refining trading algorithms with QuantConnect. Utilize advanced tools, historical data, and robust backtesting to enhance your trading strategies. Transform your ideas into actionable insights and optimize your trading approach with ease.
Sign Up for FreeAlready have an account Log In.
⭑
⭑
⭑
⭑
⭑
Hover and click over the stars to rate us.
It looks like you are not fully satisfied with your experience on QuantConnect, please take a moment to let us know how we can improve our services for you:
If you have a minute to spare, please leave us a review on Trustpilot.
Stories like yours help others see the full potential of QuantConnect.
Organization Name |
---|
Upgrade to Team plan or higher to enable custom invoicing
Changes will be applied to future invoices.
Users will be able to join by following the link in the invitation email.
You’ve been invited by Jared Broad to join his G-Force Organization.
Would you like to accept the invitation?
Are you sure you want to delete the encryption key "undefined"?
Caution: We will not be able to decrypt encrypted projects without the original key.
Drag & Drop or
Keys are added to the local storage in your web browser and not uploaded to QuantConnect. To use an encrypted project on another computer you will need to bring a copy of the key.
This project is encrypted using the key .
This project will be encrypted using the key .