code: def test_Results_helper_functions_fi():
      names = ["foo", "bar"]
      dates = pd.date_range(
          start="2017-01-01",
          end="2017-12-31",
          freq=pd.tseries.offsets.BDay(),
      )
      n = len(dates)
      rdf = pd.DataFrame(
          np.zeros((n, len(names))), index=dates, columns=names
      )
  
      np.random.seed(1)
      rdf[names[0]] = np.random.normal(
          loc=0.1 / n, scale=0.2 / np.sqrt(n), size=n
      )
      rdf[names[1]] = np.random.normal(
          loc=0.04 / n, scale=0.05 / np.sqrt(n), size=n
      )
  
      pdf = 100 * np.cumprod(1 + rdf)
      notional = pd.Series(1e6, index=pdf.index)
  
      # algo to fire on the beginning of every month and to run on the first date
      runDailyAlgo = bt.algos.RunDaily(run_on_first_date=True)
  
      # algo to select all securities
      selectAll = bt.algos.SelectAll()
  
      # algo to set the weights
      #  it will only run when runMonthlyAlgo returns true
      #  which only happens on the first of every month
      weighRandomly = bt.algos.WeighRandomly()
  
      # algo to set the notional of the fixed income strategy
      setNotional = bt.algos.SetNotional("notional")
  
      # algo to rebalance the current weights to weights set by weighSpecified
      #  will only run when weighSpecifiedAlgo returns true
      #  which happens every time it runs
      rebalAlgo = bt.algos.Rebalance()
  
      # a strategy that rebalances monthly to specified weights
      strat = bt.FixedIncomeStrategy(
          "random",
          [
              runDailyAlgo,
              selectAll,
              weighRandomly,
              setNotional,
              rebalAlgo,
          ],
      )
  
      backtest = bt.Backtest(
          strat,
          pdf,
          initial_capital=0,
          integer_positions=False,
          progress_bar=False,
          additional_data={"mydata": pdf, "notional": notional},
      )
      bidoffer = 1.0
      backtest2 = bt.Backtest(
          strat,
          pdf,
          initial_capital=0,
          integer_positions=False,
          progress_bar=False,
          additional_data={
              "mydata": pdf,
              "notional": notional,
              "bidoffer": pd.DataFrame(
                  bidoffer, pdf.index, pdf.columns
              ),
          },
      )
      random.seed(1234)
      res = bt.run(backtest)
      random.seed(1234)
      res2 = bt.run(backtest2)
  
      assert type(res.get_security_weights()) is pd.DataFrame
  
      assert type(res.get_transactions()) is pd.DataFrame
      assert len(res.get_transactions()) > 0
  
      assert type(res.get_weights()) is pd.DataFrame
  
      # Make sure the insertion of the first row applies to additional data as well
      assert backtest.data.index.equals(
          backtest.additional_data["mydata"].index
      )
  
      # Check that bid/offer is accounted for
      transactions = res.get_transactions()
      transactions["price"] = transactions["price"] + 0.5 * bidoffer
      assert (
          res2.get_transactions().price - res2.get_transactions().price
      ).abs().sum() == 0
  
file_path: bt/tests/test_backtest.py
imports: from __future__ import division
  import numpy
  import pandas
  import pytest
  import random
  from unittest import mock
  import bt
label_desc: Use image node_id 8 for calling a global function with example usage: test_Results_helper_functions_fi() without return types