finlab-python / finlab_crypto

Documentation
https://finlab-python.github.io/finlab_crypto/index.html
GNU General Public License v3.0
267 stars 98 forks source link

Mutable default arguments #4

Closed jrycw closed 3 years ago

jrycw commented 3 years ago
class Strategy(object):

    def backtest(self, ohlcv, variables=dict(),
                         filters=dict(), lookback=None, plot=False,
                         signals=False, side='long', cscv_nbins=10,
                         cscv_objective=lambda r: r.mean(), html=None, compounded=True, execution_price='close', **args):

There might be a potential issue if using dictionary as the default argument for variables and filters, since dictionary is mutable.

I will argue that using None as the default argument might be a safer approach.

koreal6803 commented 3 years ago

Thanks for the feedback, I updated ecea8d9 to fixed it.