How to use the prophet.utils.trading_days.get_loc 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 / data.py View on Github external
def get_data_start(self, start, lookback):
        start_index = trading_days.get_loc(start)
        return trading_days[start_index - lookback]
github Emsu / prophet / prophet / app.py View on Github external
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,
                                   target_datetime,
                                   lookback)
        prices = data.get('prices')
        if prices is None:
            raise ProphetException("Price data is required to run a backtest. "
                                   "Please add a data generator with the name "
                                   "property set to 'prices'.")
        return self._order_generator.run(prices=prices,
                                         data=data,
                                         timestamp=target_datetime,
                                         cash=cash,
                                         portfolio=portfolio)