
mansour65horzadeh
@t_mansour65horzadeh
What symbols does the trader recommend buying?
Purchase History
پیام های تریدر
Filter
import pandas as pd import numpy as np import matplotlib.pyplot

import pandas as pd import numpy as np import matplotlib.pyplot as plt import yfinance as yf from datetime import datetime # دریافت دادههای تاریخی (مثال: بیتکوین) symbol = "BTC-USD" start_date = "2023-01-01" end_date = datetime.now().strftime("%Y-%m-%d") data = yf.download(symbol, start=start_date, end=end_date) df = data [ ['Close']].copy() # ۱. محاسبه میانگین متحرک (MA) def calculate_ma(df, window=20): df [f'MA_{window}'] = df ['Close'].rolling(window=window).mean() return df df = calculate_ma(df, window=20) df = calculate_ma(df, window=50) # ۲. محاسبه RSI def calculate_rsi(df, window=14): delta = df ['Close'].diff() gain = (delta.where(delta > 0, 0)).rolling(window=window).mean() loss = (-delta.where(delta < 0, 0)).rolling(window=window).mean() rs = gain / loss df ['RSI'] = 100 - (100 / (1 + rs)) return df df = calculate_rsi(df, window=14) # ۳. محاسبه MACD def calculate_macd(df, fast=12, slow=26, signal=9): df ['EMA_fast'] = df ['Close'].ewm(span=fast, adjust=False).mean() df ['EMA_slow'] = df ['Close'].ewm(span=slow, adjust=False).mean() df ['MACD'] = df ['EMA_fast'] - df ['EMA_slow'] df ['Signal_Line'] = df ['MACD'].ewm(span=signal, adjust=False).mean() df ['MACD_Histogram'] = df ['MACD'] - df ['Signal_Line'] return df df = calculate_macd(df) # ۴. رسم نمودارها fig, axes = plt.subplots(4, 1, figsize=(14, 10), gridspec_kw={'height_ratios': [3, 1, 1, 1]}) # نمودار قیمت و MA axes [0].plot(df.index, df ['Close'], label='Close Price', color='black', linewidth=1) axes [0].plot(df.index, df ['MA_20'], label='MA 20', color='blue', linewidth=1) axes [0].plot(df.index, df ['MA_50'], label='MA 50', color='red', linewidth=1) axes [0].set_title(f'{symbol} - Price & Moving Averages') axes [0].legend() axes [0].grid(True) # نمودار RSI axes [1].plot(df.index, df ['RSI'], label='RSI (14)', color='purple', linewidth=1) axes [1].axhline(y=70, color='red', linestyle='--', linewidth=0.7) axes [1].axhline(y=30, color='green', linestyle='--', linewidth=0.7) axes [1].fill_between(df.index, 30, 70, alpha=0.1, color='gray') axes [1].set_title('RSI Indicator') axes [1].legend() axes [1].grid(True) # نمودار MACD و Signal Line axes [2].plot(df.index, df ['MACD'], label='MACD', color='blue', linewidth=1) axes [2].plot(df.index, df ['Signal_Line'], label='Signal Line', color='red', linewidth=1) axes [2].set_title('MACD Indicator') axes [2].legend() axes [2].grid(True) # نمودار هیستوگرام MACD axes [3].bar(df.index, df ['MACD_Histogram'], label='MACD Histogram', color='gray') axes [3].axhline(y=0, color='black', linewidth=0.5) axes [3].set_title('MACD Histogram') axes [3].legend() axes [3].grid(True) plt.tight_layout() plt.show() # ۵. نمایش جدول دادههای اخیر print(df [ ['Close', 'MA_20', 'MA_50', 'RSI', 'MACD', 'Signal_Line']].tail(10))
Disclaimer
Any content and materials included in Sahmeto's website and official communication channels are a compilation of personal opinions and analyses and are not binding. They do not constitute any recommendation for buying, selling, entering or exiting the stock market and cryptocurrency market. Also, all news and analyses included in the website and channels are merely republished information from official and unofficial domestic and foreign sources, and it is obvious that users of the said content are responsible for following up and ensuring the authenticity and accuracy of the materials. Therefore, while disclaiming responsibility, it is declared that the responsibility for any decision-making, action, and potential profit and loss in the capital market and cryptocurrency market lies with the trader.