Base Data Streamer

class algotradepy.streamers.base.ADataStreamer
abstract subscribe_to_bars(contract, bar_size, func, fn_kwargs=None, rth=False)

Subscribe to receiving historical bar data.

The bars are fed back as pandas.Series objects.

Parameters
  • contract (AContract) – The contract for which to request historical data.

  • bar_size (timedelta) – The bar size to request.

  • func (Callable) – The function to which to feed the bars.

  • fn_kwargs (Dict) – Keyword arguments to feed to the callback function along with the bars.

  • rth (bool, default False) – Whether to return regular trading hours only.

abstract cancel_bars(contract, func)

Cancel bar data updates.

Parameters
  • contract (AContract) – The contract definition for which to cancel bar updates.

  • func (Callable) – The function for which to cancel bar updates.

abstract subscribe_to_tick_data(contract, func, fn_kwargs=None, price_type=<PriceType.MARKET: 'MARKET'>)

Subscribe to tick updates.

Parameters
  • contract (AContract) – The contract definition for which to request price updates.

  • func (Callable) – The callback function. It must accept a float as its sole positional argument.

  • fn_kwargs (dict) – The keyword arguments to pass to the callback function along with the positional arguments.

  • price_type (PriceType) – The price type (market, bid, ask).

abstract cancel_tick_data(contract, func)

Cancel tick updates.

Parameters
  • contract (AContract) – The contract definition for which to cancel tick updates.

  • func (Callable) – The function for which to cancel tick updates.

abstract subscribe_to_trades(contract, func, fn_kwargs=None)

Subscribe to trade updates.

Parameters
  • contract (AContract) – The contract definition for which to request trade updates.

  • func (Callable) – The callback function. It must accept a pandas.Series as its sole positional argument.

  • fn_kwargs (dict) – The keyword arguments to pass to the callback function along with the positional arguments.

abstract cancel_trades(contract, func)

Cancel trade updates.

Parameters
  • contract (AContract) – The contract definition for which to cancel trade updates.

  • func (Callable) – The function for which to cancel trade updates.