code: def test_sma2():
      indicator_name = "SMA2"
      tech_params.sma_period = 2
      tech_params.sma2_period = 3
  
      # Test Case 1: Increasing prices
      cols = get_cols_name(1)
      signals = ["SMA", "SMA2"]
      data_df = pd.DataFrame(
          index=dates, columns=cols, data=list(range(1, 9))
      )
      tech_ind.create_tech_ind(data_df, indicator_name, tech_params)
      expected_signal_df = pd.DataFrame(
          index=dates,
          columns=[
              " ".join([col, indicator_name, "Signal"]) for col in cols
          ],
          data=1,
      )
      expected_df = pd.DataFrame(
          index=dates,
          columns=[
              " ".join([col, sig]) for col in cols for sig in signals
          ],
          data=[
              [np.nan, np.nan],
              [1.5, np.nan],
              [2.5, 2.0],
              [3.5, 3.0],
              [4.5, 4.0],
              [5.5, 5.0],
              [6.5, 6.0],
              [7.5, 7.0],
          ],
      )
      expected_signal_df.iloc[: tech_params.sma2_period] = np.nan
      df = tech_ind.get_techind()
      signal_df = tech_ind.get_signal()
  
      assert_frame_equal(df, expected_df)
      assert_frame_equal(signal_df, expected_signal_df)
  
      # Test Case 2: Decreasing prices
      cols = get_cols_name(1)
      signals = ["SMA", "SMA2"]
      data_df = pd.DataFrame(
          index=dates, columns=cols, data=list(range(8, 0, -1))
      )
      tech_ind.create_tech_ind(data_df, indicator_name, tech_params)
      expected_signal_df = pd.DataFrame(
          index=dates,
          columns=[
              " ".join([col, indicator_name, "Signal"]) for col in cols
          ],
          data=-1,
      )
      expected_df = pd.DataFrame(
          index=dates,
          columns=[
              " ".join([col, sig]) for col in cols for sig in signals
          ],
          data=[
              [np.nan, np.nan],
              [7.5, np.nan],
              [6.5, 7.0],
              [5.5, 6.0],
              [4.5, 5.0],
              [3.5, 4.0],
              [2.5, 3.0],
              [1.5, 2.0],
          ],
      )
      expected_signal_df.iloc[: tech_params.sma2_period] = np.nan
      df = tech_ind.get_techind()
      signal_df = tech_ind.get_signal()
  
      assert_frame_equal(df, expected_df)
      assert_frame_equal(signal_df, expected_signal_df)
  
      # Test Case 3: Costant prices
      cols = get_cols_name(1)
      signals = ["SMA", "SMA2"]
      data_df = pd.DataFrame(index=dates, columns=cols, data=1)
      tech_ind.create_tech_ind(data_df, indicator_name, tech_params)
      expected_signal_df = pd.DataFrame(
          index=dates,
          columns=[
              " ".join([col, indicator_name, "Signal"]) for col in cols
          ],
          data=-1,
      )
      expected_df = pd.DataFrame(
          index=dates,
          columns=[
              " ".join([col, sig]) for col in cols for sig in signals
          ],
          data=np.tile(np.ones(len(dates)), (2, 1)).T,
      )
      expected_signal_df.iloc[: tech_params.sma2_period] = np.nan
      expected_df.iloc[: tech_params.sma2_period - 1] = np.nan
      expected_df.set_value("2018-01-02", "Asset1.close SMA", 1.0)
      df = tech_ind.get_techind()
      signal_df = tech_ind.get_signal()
  
      assert_frame_equal(df, expected_df)
      assert_frame_equal(signal_df, expected_signal_df)
  
file_path: finmarketpy/tests/test_techindicator.py
imports: import pytest
  import pandas
  import numpy
  from pandas.testing import assert_frame_equal
  from finmarketpy.economics.techindicator import TechParams, TechIndicator
label_desc: Use image node_id 4 for calling a global function with example usage: test_sma2() without return types