Pylivetrader vs pipeline_live

Hello Alpaca,

I am new to Alpaca. Comfortable with Quantopian and wondering about transferring some algos.
What is the difference between pylivetrader vs pipeline-live? Which one is recommended to get started.

Thanks,
vg

Hi,
Pylivetrader is using pipeline-live for the pipeline functionality.
so you should use Pylivetrader.
read the README of the repository, it contains useful information and code examples.

Good question! I’ll copy this directly from the pylivetrader docs

pylivetrader is a simple python live trading framework with zipline interface. The main purpose is to run algorithms developed in the Quantopian platform in live trading via broker API. In order to convert your algorithm for pylivetrader, please read the migration document.

So, what does that mean? This is the module you need to import so you can run Quantopian and/or zipline algorithms. The link above gives directions on how to do that.

Just like zipline, pylivetrader doesn’t support pipelines ‘out of the box’. It includes all the familiar methods like symbols (to find an asset by its symbol), data.history (to get historical price and volume data), order_target_percent (to place orders), but it doesn’t know anything about pipelines. In the Quantopian environment, one would need to import pipeline to get that functionality. Something like this.

from quantopian.pipeline import Pipeline

Once pipeline is imported then you can define a pipeline to fetch data and have access to all the familiar built in factors and filters.

So, as long as your pylivetrader algorithm doesn’t use pipelines, you don’t need to import it. However, if one want’s to fetch fundamental data, and especially if one wants to fetch an initial stock ‘universe’, then pipeline is very handy.

Getting started, perhaps get some simple Quantopian algorithms to run in pylivetrader which don’t rely on pipeline. After feeling comfortable, import pipeline-live and add pipeline functionality to your algorithms. One thing to note, just like one can run pipelines in Quantopian notebooks outside of an algorithm, one can also import pipeline-live into a notebook and run pipelines standalone (outside of pylivetrader).

The big difference with pipeline-live pipelines is they only return data for the current day. They are ‘live’ and not historical. You can get as much historical data as you wish inside custom factors etc, but the resulting dataframe will not be a multi-index dataframe with multiple days, Rather it will be a single index dataframe with only the data for the current day. This is very much like (if not identical to) the dataframe returned by a pipeline in an algo.

I hope that makes sense?

1 Like

Thanks Dan for detailed reply. It makes sense now.