title: Can one replace keywords in functions by a dict or sth?
body: <p>I have a function with plenty of predefined parameters (test.addstrategy within the function runstrat).</p>
  <p>I would like to change the keywords <strong>selcperc</strong>=p1, <strong>mperiod</strong>=int(p2) to <strong>rperiod</strong> and <strong>zperiod</strong>. These are also parameters in the St function.</p>
  <p>Is that possible by forinstance a dict like the globalparams dict?</p>
  <pre><code>globalparams = dict(fromdate=datetime.datetime(2005, 11, 3),
                      todate=datetime.datetime(2020, 6, 18),
                      strategy=&quot;St&quot;,                                  
                      
                      #Heatmap section
                      heatmap=True,  
                      heatmapparams= {'selcperc': &quot;p1&quot;},
                      heatmapparams2= {'mperiod': &quot;int(p2)&quot;,
                                      'printlog': &quot;False&quot;},
                      )
  
  if globalparams[&quot;heatmap&quot;]:
      results_list = []
      for i in np.arange(0.02, 0.12, 0.02):
          for j in np.arange(60, 250, 10):
              PnL = runstrat(p1=i, p2=j)
              results_list.append([i, j, i, PnL])
      my_heatmap1(results_list)
      return
  
  def runstrat(p1, p2):
      test= bt.Cerebro()
      test.addstrategy(eval(globalparams[&quot;strategy&quot;], selcperc=p1, mperiod=int(p2),printlog=False)
  
      for fname in glob.glob(os.path.join(globalparams[&quot;path&quot;], '*')):
          df = pd.read_csv(fname, index_col=0, parse_dates=True)
          if len(df)&gt;200:
              test.adddata(bt.feeds.PandasData(dataname=df,name=os.path.basename(fname).replace(&quot;.csv&quot;, &quot;&quot;),fromdate=fromdate, todate=todate, plot=False))        
  
      test.run(maxcpus=0)
      return test.broker.getvalue()
  
                       
  def my_heatmap1(data):
      data = np.array(data)
      xs = np.unique(data[:, 1].astype(int))
      ys = np.unique(data[:, 0].astype(float))
      vals = data[:, 3].reshape(len(ys), len(xs))
      min_val_ndx = np.unravel_index(np.argmin(vals, axis=None), vals.shape)
      max_val_ndx = np.unravel_index(np.argmax(vals, axis=None), vals.shape)
  
      cmap = LinearSegmentedColormap.from_list('', ['red', 'orange', 'yellow', 'chartreuse', 'limegreen'])
      ax = sns.heatmap(vals, xticklabels=xs, yticklabels=ys, cmap='viridis', annot=True, fmt='.2f')
  
      ax.add_patch(Rectangle(min_val_ndx[::-1], 1, 1, fill=False, edgecolor='blue', lw=3, clip_on=False))
      ax.add_patch(Rectangle(max_val_ndx[::-1], 1, 1, fill=False, edgecolor='blue', lw=3, clip_on=False))
      print(data)
      plt.tight_layout()
      plt.show()
  </code></pre>
  <p>St is another very lengthy class.</p>
  <p>Edit:</p>
  <p>I did now a poor workaround by incl. all parameters i potentially want to change. in the global params I set up a dictionary that contains all cases, which will replace the arguments with the relevant case...</p>