I am creating dynamic variables with:
import mplfinance as mpf
import pandas as pd
from polygon import RESTClient
def main():
with RESTClient('key') as client:
start = "2019-02-01"
end = "2019-02-02"
ticker = "TVIX"
intervals = [5,15,30,60]
for i in intervals:
print(f'downloading {i} minutes.')
vars()[f'df{i}'] = client.stocks_equities_aggregates(ticker, str(i), "minute", start, end, unadjusted=False)
print(df5)
if __name__ == '__main__':
main()
When running I get the error NameError: name 'df5' is not defined
.
I can debug and see the variable does exist under Spyder variable explorer as below.
It works for global()
but not vars()
what am I doing wrong please?