plotter – Strategy plotter

class pyalgotrade.plotter.StrategyPlotter(strat, plotAllClosingPrices=True, plotBuySell=True, plotPortfolio=True)

Class responsible for plotting a strategy execution.

Parameters:
  • strat (pyalgotrade.strategy.Strategy.) – The strategy to plot.
  • plotAllClosingPrices (boolean.) – Set to True to get the closing prices plotted.
  • plotBuySell (boolean.) – Set to True to get the buy/sell events plotted.
  • plotPortfolio (boolean.) – Set to True to get the portfolio value (shares + cash) plotted.
getMainSubplot()

Returns the main subplot, where closing prices and buy/sell events get plotted.

Return type:Subplot.
getOrCreateSubplot(name)

Returns a Subplot by name. If the subplot doesn’t exist, it gets created.

Parameters:name (string.) – The name of the Subplot to get or create.
Return type:Subplot.
getPortfolioSubplot()

Returns the subplot where the portfolio values get plotted.

Return type:Subplot.
plot(fromDateTime=None, toDateTime=None)

Plots the strategy execution. Must be called after running the strategy.

Parameters:
  • fromDateTime (datetime.datetime) – An optional starting datetime.datetime. Everything before it won’t get plotted.
  • toDateTime (datetime.datetime) – An optional ending datetime.datetime. Everything after it won’t get plotted.
class pyalgotrade.plotter.Subplot
addDataSeries(label, dataSeries)

Adds a DataSeries to the subplot.

Parameters:

Previous topic

strategy – Basic strategy classes

Next topic

broker – Order management classes

This Page