import pandas as pd
import talib as ta
import datetime
start=datetime.datetime.now()
a = ["ACC.csv", "ADANIPORTS.csv", "AMBUJACEM.csv", 'ASHOKLEY.csv', 'ASIANPAINT.csv']
dataframes = {}
for file_name in a:
df = pd.read_csv(file_name)
df['SMA'] = ta.SMA(df['close'], timeperiod=14)
macd, signal, macd_histogram = ta.MACD(df['close'], fastperiod=12, slowperiod=26)
df['MACD'] = macd
df['MACD_Signal'] = signal
df['RSI'] = ta.RSI(df['close'], timeperiod=14)
file_key = file_name.replace(".csv", "")
dataframes[file_key] = df
for key, df in dataframes.items():
print(f"File: {key}")
print(df)
print("\n")
print(datetime.datetime.now()-start)
我现在就像上面那样计算TA。有没有什么方法可以使它更快或更有效地处理大量的数据。
1条答案
按热度按时间s1ag04yj1#
你可以使用下面的方法来应用多线程。