je-suis-tm / quant-trading

Python quantitative trading strategies including VIX Calculator, Pattern Recognition, Commodity Trading Advisor, Monte Carlo, Options Straddle, Shooting Star, London Breakout, Heikin-Ashi, Pair Trading, RSI, Bollinger Bands, Parabolic SAR, Dual Thrust, Awesome, MACD
https://je-suis-tm.github.io/quant-trading
Apache License 2.0
5.94k stars 1.2k forks source link

Eliminating module level global statement and fixing dangerous default arguement #47

Closed devfinwiz closed 1 year ago

devfinwiz commented 1 year ago

The global statement is used to specify that the assignment to that name is an assignment to the variable in the global (module) scope, rather than in the local scope. At the module level, this statement is redundant because the local scope and global scope are the same. It is recommended to remove the global statement.

Do not use a mutable like list or dictionary as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.