שלשום
import pandas as pd import numpy as np import talib # تحميل بيانات SPX data = pd.read_csv("SPX_data.csv") # استبدل ببيانات SPX data['EMA_9'] = talib.EMA(data['Close'], timeperiod=9) data['EMA_21'] = talib.EMA(data['Close'], timeperiod=21) data['RSI'] = talib.RSI(data['Close'], timeperiod=14) data['Upper'], data['Middle'], data['Lower'] = talib.BBANDS(data['Close'], timeperiod=20, nbdevup=2, nbdevdn=2) # إشارات الشراء والبيع data['Buy_Signal'] = (data['EMA_9'] > data['EMA_21']) & (data['RSI'] < 40) & (data['Close'] < data['Lower']) data['Sell_Signal'] = (data['EMA_9'] < data['EMA_21']) & (data['RSI'] > 60) & (data['Close'] > data['Upper']) print(data[['Close', 'Buy_Signal', 'Sell_Signal']])