import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Örnek fiyat verisi
data = {
'Date': pd.date_range(start='2023-01-01', periods=60, freq='D'),
'Price': np.random.normal(loc=1800, scale=50, size=60) # Rastgele fiyat verisi
}
df = pd.DataFrame(data)
# Destek ve direnç seviyelerini bulmak için fonksiyon
def calculate_support_resistance(df, window=5):
df['Max'] = df['Price'].rolling(window=window).max() # Direnç
df['Min'] = df['Price'].rolling(window=window).min() # Destek
return df
# Destek ve direnç seviyelerini hesapla
df = calculate_support_resistance(df)
# Sonuçları yazdır
print("Son Fiyat Verileri:")
print(df[['Date', 'Price', 'Min', 'Max']])
# Grafik Çizimi
plt.figure(figsize=(12, 6))
plt.plot(df['Date'], df['Price'], label='Fiyat', color='blue')
plt.plot(df['Date'], df['Min'], label='Destek', linestyle='--', color='green')
plt.plot(df['Date'], df['Max'], label='Direnç', linestyle='--', color='red')
plt.title('Fiyat, Destek ve Direnç Seviyeleri')
plt.xlabel('Tarih')
plt.ylabel('Fiyat (USD)')
plt.legend()
plt.show()
CmltcG9ydCBwYW5kYXMgYXMgcGQKaW1wb3J0IG51bXB5IGFzIG5wCmltcG9ydCBtYXRwbG90bGliLnB5cGxvdCBhcyBwbHQKCiMgw5ZybmVrIGZpeWF0IHZlcmlzaQpkYXRhID0gewogICAgJ0RhdGUnOiBwZC5kYXRlX3JhbmdlKHN0YXJ0PScyMDIzLTAxLTAxJywgcGVyaW9kcz02MCwgZnJlcT0nRCcpLAogICAgJ1ByaWNlJzogbnAucmFuZG9tLm5vcm1hbChsb2M9MTgwMCwgc2NhbGU9NTAsIHNpemU9NjApICAjIFJhc3RnZWxlIGZpeWF0IHZlcmlzaQp9CgpkZiA9IHBkLkRhdGFGcmFtZShkYXRhKQoKIyBEZXN0ZWsgdmUgZGlyZW7DpyBzZXZpeWVsZXJpbmkgYnVsbWFrIGnDp2luIGZvbmtzaXlvbgpkZWYgY2FsY3VsYXRlX3N1cHBvcnRfcmVzaXN0YW5jZShkZiwgd2lu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