Simulation Data Streamer

class algotradepy.streamers.sim_streamer.SimulationDataStreamer(historical_retriever=None)

A simulation data streamer.

This class provides data to the SimulationBroker during a simulation.

Parameters

historical_retriever (HistoricalRetriever) – The historical retriever to use when loading historical data.

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.

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.

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).

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.

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.

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.