docstr: Use a history window with non-monotonically increasing dates.
  A scenario which does not occur during simulations, but useful
  for using a history loader in a notebook.
docstr_tok: ["Use","a","history","window","with","non-monotonically","increasing","dates",".","A","scenario","which","does","not","occur","during","simulations",",","but","useful","for","using","a","history","loader","in","a","notebook","."]
code: def test_history_window_out_of_order_dates(self):
      """
      Use a history window with non-monotonically increasing dates.
      A scenario which does not occur during simulations, but useful
      for using a history loader in a notebook.
      """
  
      window_1 = self.data_portal.get_history_window(
          [self.ASSET1],
          pd.Timestamp("2014-02-07", tz="UTC"),
          4,
          "1d",
          "close",
          "daily",
      )
  
      window_2 = self.data_portal.get_history_window(
          [self.ASSET1],
          pd.Timestamp("2014-02-05", tz="UTC"),
          4,
          "1d",
          "close",
          "daily",
      )
  
      window_3 = self.data_portal.get_history_window(
          [self.ASSET1],
          pd.Timestamp("2014-02-07", tz="UTC"),
          4,
          "1d",
          "close",
          "daily",
      )
  
      window_4 = self.data_portal.get_history_window(
          [self.ASSET1],
          pd.Timestamp("2014-01-22", tz="UTC"),
          4,
          "1d",
          "close",
          "daily",
      )
  
      # Calling 02-07 after resetting the window should not affect the
      # results.
      np.testing.assert_almost_equal(window_1.values, window_3.values)
  
      offsets = np.arange(4)
  
      def assert_window_prices(window, prices):
          np.testing.assert_almost_equal(
              window.loc[:, self.ASSET1], prices
          )
  
      # Window 1 starts on the 23rd day of data for ASSET 1.
      assert_window_prices(window_1, 23 + offsets)
      # Window 2 starts on the 21st day of data for ASSET 1.
      assert_window_prices(window_2, 21 + offsets)
      # Window 3 starts on the 23rd day of data for ASSET 1.
      assert_window_prices(window_3, 23 + offsets)
  
      # Window 4 starts on the 11th day of data for ASSET 1.
      if not self.trading_calendar.is_session("2014-01-20"):
          assert_window_prices(window_4, 11 + offsets)
      else:
          # If not on the NYSE calendar, it is possible that MLK day
          # (2014-01-20) is an active trading session. In that case,
          # we expect a nan value for this asset.
          assert_window_prices(window_4, [12, nan, 13, 14])
  
imports: from textwrap import dedent
  from nose_parameterized import parameterized
  import numpy
  from numpy import nan
  import pandas
  from six import iteritems
  from catalyst import TradingAlgorithm
  from catalyst._protocol import handle_non_market_minutes, BarData
  from catalyst.assets import Asset, Equity
  from catalyst.errors import HistoryInInitialize, HistoryWindowStartsBeforeData
  from catalyst.finance.trading import SimulationParameters
  from catalyst.finance.asset_restrictions import NoRestrictions
  from catalyst.testing import create_minute_df_for_asset, str_to_seconds, MockDailyBarReader
  from catalyst.testing.fixtures import WithCreateBarData, WithDataPortal, CatalystTestCase, alias
label_desc: Use image node_id 12 for calling the DailyEquityHistoryTestCase obj's underlying member method code with example usage: obj.test_history_window_out_of_order_dates() without return types