Package: pipeline-live
⚠️ This is software is very outdated and is not recommended for use in new setups ⚠️We will keep this project up and with the documentation for the parts that remain
for those users who are still using this, but we suggest migrating to another tool
until we perform a major refactoring of this project to bring it up to speed. If this
is something you'd like to see please reach out to us to let us know!The docs below still talk about zipline and Quantopian however Quantopian has since
gone out of business and the below hasn't yet been updated to reflect this.If you're looking for another modern alternative to zipline, we recommend checking
outzipline-reloadedin the meantime
while we review committing to a major refactor of this project.Zipline Pipeline Extension for Live Tradingpipeline-liveis an extension for zipline pipeline independently usable
for live trading, outside of zipline. While zipline is a great backtesting
library, the default Pipeline API requires complicated setup for data bundle,
which is often challenging to average users. Quantopian's proprietary data
sources such as Morningstar is also not available to many. This library is
to address this issue by using online API data sources and simplify the interface
for live trading usage.
The interface complies the original zipline/pipeline for the most part.  For more
details about the Pipeline API, please seeQuantopian's tutorialandzipline document.If you are looking to use this library for your Quantopian algorithm,
check out themigration document.Data SourcesThis library predominantly relies on theAlpaca Data APIfor daily
price data.IEX Clouddata is also supported, though if too much
data is requested, it stops being free. (See the note in the IEX section below.)Installpipeline-liveis a PyPI module and you can install it usingpipcommand.$pipinstallpipeline-liveThis module is tested and expected to work with python 3.6 and laterExampleHere is a simple pipeline example.
Please make sure to first set your API keys to these environment variables:using pythonimportosos.environ["APCA_API_KEY_ID"]=<ALPACA_API_KEY>os.environ["APCA_API_SECRET_KEY"]=<ALPACA_SECRET_KEY># if you use the paper endpoint:os.environ["APCA_API_BASE_URL"]="https://paper-api.alpaca.markets"(or do it with bash if you prefer)frompipeline_live.engineimportLivePipelineEnginefrompipeline_live.data.sources.alpacaimportlist_symbolsfrompipeline_live.data.alpaca.pricingimportUSEquityPricingfrompipeline_live.data.alpaca.factorsimportAverageDollarVolumefromzipline.pipelineimportPipelineeng=LivePipelineEngine(list_symbols)top5=AverageDollarVolume(window_length=20).top(5)pipe=Pipeline({'close':USEquityPricing.close.latest,},screen=top5)df=eng.run_pipeline(pipe)'''closeAAPL   215.49AMZN  1902.90FB     172.90QQQ    180.80SPY    285.79'''Data CacheSince most of the data does not change during the day, the data access layer
caches the dataset on disk.  In case you need to purge the cache, the cache
data is located in$ZIPLINE_ROOT/data/daily_cache.Pipeline APIpipeline_live.engine.LivePipelineEngineThis class provides the similar interface tozipline.pipeline.engine.SimplePipelineEngine.
The main difference is itsrun_pipelinedoes not require the start and end dates as parameters,
and returns a DataFrame with the data for the current date (US/Eastern time).
Its constructor acceptslist_symbolfunction that is supposed to return the full set of
symbols as a string list, which is used as the maximum universe inside the engine.Alpaca Data APITheAlpaca Data APIis currently the least-limited source of pricing data
supported by pipeline-live. In order to use the Alpaca Data API, you'll need to
register for an Alpaca accounthereand generate API key information with
the dashboard. Once you have your keys generated, you need to store them in
the following environment variables:APCA_API_BASE_URL
APCA_API_KEY_ID
APCA_API_SECRET_KEYpipeline_live.data.alpaca.pricing.USEquityPricingThis class provides the basic price information retrieved fromAlpaca Data API.Where Did the Polygon integration go?Alpaca used to offer an integration with polygon, however with the removal of
that integration from the Alpaca api we removed the polygon integration here as well.IEX Data Source APITo use IEX-source data, you need to sign up for an IEX Cloud account and save
your IEX token as an environment variable calledIEX_TOKEN.IMPORTANT NOTE: IEX data is now limited for free accounts. In order to
avoid using more messages than you are allotted each month, please
be sure that you are not using IEX-sourced factors too frequently
or on too many securities. For more information about how many messages
each method will cost, please refer tothis partof the IEX Cloud documentation.pipeline_live.data.iex.pricing.USEquityPricingThis class provides the basic price information retrieved fromIEX Chart API.pipeline_live.data.iex.fundamentals.IEXCompanyThis provides the DataSet interface usingIEX Company API.pipeline_live.data.iex.fundamentals.IEXKeyStatsThis provides the DataSet interface usingIEX Key Stats API.pipeline_live.data.iex.factorsIt is important to note that the original builtin factors from zipline does
not work here as is, since some of them rely on zipline's USEquityPricing class.
This package provides the same set of zipline's builtin factor classes usingpipeline_live.data.iex.pricing.USEquityPricingclass. For the complete
list of builtin factors, please referzipline documentpipeline_live.data.iex.classifiers.Sector()A shortcut forIEXCompany.sector.latestpipeline_live.data.iex.classifiers.Industry()A shortcut forIEXCompany.industry.latest