How to use the prophet.portfolio.Portfolio function in prophet

To help you get started, we’ve selected a few prophet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Emsu / prophet / prophet / app.py View on Github external
def run_backtest(self,
                     start,
                     end=None,
                     lookback=0,
                     slippage=0.0,
                     commission=0.0,
                     cash=1000000,  # $1,000,000
                     initial_portfolio=Portfolio(),
                     ):
        """ Runs a backtest over a given time period.

        Args:
            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

        Return:
            prophet.backtest.BackTest
        """
github Emsu / prophet / prophet / app.py View on Github external
def generate_orders(self,
                        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.

        Args:
            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
        """
        target_datetime_index = trading_days.get_loc(target_datetime)
        start = trading_days[target_datetime_index - buffer_days]
        data = self._generate_data(start,