Skip to content

Commit

Permalink
Added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaron committed Mar 6, 2024
1 parent 873eb1d commit d60a3cc
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions roboquant/feeds/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,40 @@


class Feed(ABC):
"""A feed (re-)plays events"""
"""
A Feed represents a source of (financial) events that can be (re-)played.
It provides methods for playing events, plotting prices, and playing events in the background on a separate thread.
"""

@abstractmethod
def play(self, channel: EventChannel):
"""(re-)play the events in the feed and put them on the provided event channel"""
"""
(Re-)plays the events in the feed and puts them on the provided event channel.
Parameters
----------
channel : EventChannel
EventChannel where the events will be placed.
"""
...

def play_background(self, timeframe: Timeframe | None = None, channel_capacity: int = 10) -> EventChannel:
"""Play this feed in the background on its own thread.
The returned event-channel will be closed after the playing has finished.
"""
Plays this feed in the background on its own thread.
Parameters
----------
timeframe : Timeframe or None, optional
The timeframe in which to limit the events in the feed. If None, all events will be played.
channel_capacity : int, optional
The capacity of the event channel (default is 10)
Returns
-------
EventChannel
The EventChannel used for playback.
"""

channel = EventChannel(timeframe, channel_capacity)

def __background():
Expand All @@ -33,7 +56,23 @@ def __background():
return channel

def plot(self, plt, symbol: str, price_type: str = "DEFAULT", timeframe: Timeframe | None = None, **kwargs):
"""Plot the prices of one or more symbols"""
"""
Plot the prices of a symbol.
Parameters
----------
plt : matplotlib.pyplot
The matplotlib.pyplot object where the plot will be drawn.
symbol : str
The symbol for which to plot prices.
price_type : str, optional
The type of price to plot, e.g. open, close, high, low. (default is "DEFAULT")
timeframe : Timeframe or None, optional
The timeframe over which to plot prices. If None, the entire feed timeframe is used. (default is None)
**kwargs
Additional keyword arguments to pass to the plt.plot() function.
"""

channel = self.play_background(timeframe)
times = []
prices = []
Expand Down

0 comments on commit d60a3cc

Please sign in to comment.