I have a Python question that is more syntax related than anything else. I know that you can access variables dynamically with evaluate, like so, which is useful in a function:
def price_checker(coin):
if float(eval(coin + 'price')) >= 5:
do_something
This logic has been working very well for me. I have hundreds of variable names, updated constantly through API requests in hundreds of threads. My main loop compares prices with my trading strategy to see what fits the criteria through the usage of functions. An example of the code that would be accessed is:
BTCUSDTprice = 7000
ETHUSDTprice = 500
I would then call the function and input whatever coin matched a previous criteria to then check its price, along with some other variables named like so. I am now trying to accomplish the same thing with arrays. I would have an array, like so:
BTCUSDTclosingpricearray = [7000, 7010, 10, 5000000]
ETHUSDTclosingpricearray = [500, 600, 1000, 600]
I need to be able to access these arrays dynamically in the very same way that I access variables, and changing my method to do so is not an option, as all of the functions are already created and must stay as they are. With the usage of functions, how can I dynamically access these variables based on function parameters in a way similar to how I access variables with function parameters? Thank you all in advance. This is very much appreciated.