| 1996 | ) |
| 1997 | |
| 1998 | def get_history_window(self, bar_count, frequency, assets, field, ffill): |
| 1999 | if not self._in_before_trading_start: |
| 2000 | return self.data_portal.get_history_window( |
| 2001 | assets, |
| 2002 | self.datetime, |
| 2003 | bar_count, |
| 2004 | frequency, |
| 2005 | field, |
| 2006 | self.data_frequency, |
| 2007 | ffill, |
| 2008 | ) |
| 2009 | else: |
| 2010 | # If we are in before_trading_start, we need to get the window |
| 2011 | # as of the previous market minute |
| 2012 | adjusted_dt = \ |
| 2013 | self.trading_calendar.previous_minute( |
| 2014 | self.datetime |
| 2015 | ) |
| 2016 | |
| 2017 | window = self.data_portal.get_history_window( |
| 2018 | assets, |
| 2019 | adjusted_dt, |
| 2020 | bar_count, |
| 2021 | frequency, |
| 2022 | field, |
| 2023 | self.data_frequency, |
| 2024 | ffill, |
| 2025 | ) |
| 2026 | |
| 2027 | # Get the adjustments between the last market minute and the |
| 2028 | # current before_trading_start dt and apply to the window |
| 2029 | adjs = self.data_portal.get_adjustments( |
| 2030 | assets, |
| 2031 | field, |
| 2032 | adjusted_dt, |
| 2033 | self.datetime |
| 2034 | ) |
| 2035 | window = window * adjs |
| 2036 | |
| 2037 | return window |
| 2038 | |
| 2039 | #################### |
| 2040 | # Account Controls # |