API
This part of the documentation covers all the interfaces of Prophet.
For parts where Flask depends on external libraries, we document the
most important right here and provide links to the canonical
documentation.
Prophet Object
-
class prophet.Prophet
The application object. Serves as the primary interface for using the
Prophet library.
-
config
dict
Dictionary of settings to make available to other
functions. Useful for things like RISK_FREE_RATE.
-
analyze_backtest(backtest)
Analyzes a backtest with the registered portfolio analyzers.
-
generate_orders(target_datetime, lookback=0, cash=1000000, buffer_days=0, portfolio=Portfolio())
Generates orders for a given day. Useful for generating trade
orders for a your personal account.
Parameters: |
- target_datetime (datetime) – The datetime you want to
generate orders for.
- lookback (int) – Number of trading days you want data for before the
(target_datetime - buffer_days)
- cash (int) – Amount of starting cash
- buffer_days (int) – number of trading days you want extra data
generated for. Acts as a data start date.
- portfolio (prophet.portfolio.Portfolio) – Starting portfolio
|
-
register_data_generators(*functions)
Registers functions that generate data to be assessed in
the order generator.
Parameters: | functions (list) – List of functions. |
-
register_portfolio_analyzers(functions)
Registers a list of functions that are sequentially executed to
generate data. This list is appended to list of existing data
generators.
Parameters: | functions (list of function) – Each function in the list of args is
executed in sequential order. |
-
run_backtest(start, end=None, lookback=0, slippage=0.0, commission=0.0, cash=1000000, initial_portfolio=Portfolio())
Runs a backtest over a given time period.
Parameters: |
- start (datetime) – The start of the backtest window
- end (datetime) – The end of the backtest windows
- lookback (int) – Number of trading days you want data for
before the start date
- slippage (float) – Percent price slippage when executing order
- commission (float) – Amount of commission paid per order
- cash (int) – Amount of starting cash
- portfolio (prophet.portfolio.Portfolio) – Starting portfolio
|
Returns: | pandas.backtest.BackTest
|
-
set_order_generator(order_generator)
Sets the order generator for backtests.
Parameters: | order_generator – Instance of class with a run method that generates |
-
set_universe(symbols)
Sets the list of all tickers symbols that will be used.
Parameters: | symbols (list of str) – Ticker symbols to be used by Prophet. |
Order Objects
-
class prophet.orders.Order
Order(symbol, shares)
-
class prophet.orders.Orders(*args)
Orders object that an OrderGenerator should return.
-
add_order(symbol, shares)
Add an order to the orders list.
Parameters: |
- symbol (str) – Stock symbol to purchase
- shares (int) – Number of shares to purchase. Can be negative.
|
Backtest Object
-
prophet.backtest.BackTest
Portfolio Objects
-
class prophet.portfolio.Portfolio
Portfolio object where keys are stock symbols and
values are share counts. You can pass thise into a backtest
to start with an initial basket of stocks.
Note
Subclasses dict in v0.1
Analyzer Objects
-
class prophet.analyze.Analyzer
-
class prophet.analyze.Volatility
-
class prophet.analyze.AverageReturn
-
class prophet.analyze.Sharpe
-
class prophet.analyze.CumulativeReturn
-
prophet.analyze.default_analyzers = [volatility, average_return, sharpe, cumulative_return]
list() -> new empty list
list(iterable) -> new list initialized from iterable’s items
Data Objects
-
class prophet.data.DataGenerator(cache_path=None, data_path=None)
-
class prophet.data.PandasDataGenerator(cache_path=None, data_path=None)
-
class prophet.data.YahooCloseData(cache_path=None, data_path=None)
-
class prophet.data.YahooVolumeData(cache_path=None, data_path=None)