fork(1) download
  1.  
  2. import pandas as pd
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5.  
  6. # Örnek fiyat verisi
  7. data = {
  8. 'Date': pd.date_range(start='2023-01-01', periods=60, freq='D'),
  9. 'Price': np.random.normal(loc=1800, scale=50, size=60) # Rastgele fiyat verisi
  10. }
  11.  
  12. df = pd.DataFrame(data)
  13.  
  14. # Destek ve direnç seviyelerini bulmak için fonksiyon
  15. def calculate_support_resistance(df, window=5):
  16. df['Max'] = df['Price'].rolling(window=window).max() # Direnç
  17. df['Min'] = df['Price'].rolling(window=window).min() # Destek
  18. return df
  19.  
  20. # Destek ve direnç seviyelerini hesapla
  21. df = calculate_support_resistance(df)
  22.  
  23. # Sonuçları yazdır
  24. print("Son Fiyat Verileri:")
  25. print(df[['Date', 'Price', 'Min', 'Max']])
  26.  
  27. # Grafik Çizimi
  28. plt.figure(figsize=(12, 6))
  29. plt.plot(df['Date'], df['Price'], label='Fiyat', color='blue')
  30. plt.plot(df['Date'], df['Min'], label='Destek', linestyle='--', color='green')
  31. plt.plot(df['Date'], df['Max'], label='Direnç', linestyle='--', color='red')
  32. plt.title('Fiyat, Destek ve Direnç Seviyeleri')
  33. plt.xlabel('Tarih')
  34. plt.ylabel('Fiyat (USD)')
  35. plt.legend()
  36. plt.show()
  37.  
Success #stdin #stdout 1.89s 82668KB
stdin
Standard input is empty
stdout
Son Fiyat Verileri:
         Date        Price          Min          Max
0  2023-01-01  1828.482932          NaN          NaN
1  2023-01-02  1781.595900          NaN          NaN
2  2023-01-03  1854.245605          NaN          NaN
3  2023-01-04  1831.856253          NaN          NaN
4  2023-01-05  1769.022265  1769.022265  1854.245605
5  2023-01-06  1797.467145  1769.022265  1854.245605
6  2023-01-07  1786.678816  1769.022265  1854.245605
7  2023-01-08  1790.351872  1769.022265  1831.856253
8  2023-01-09  1785.280272  1769.022265  1797.467145
9  2023-01-10  1834.170369  1785.280272  1834.170369
10 2023-01-11  1842.209103  1785.280272  1842.209103
11 2023-01-12  1718.105130  1718.105130  1842.209103
12 2023-01-13  1874.261745  1718.105130  1874.261745
13 2023-01-14  1874.347378  1718.105130  1874.347378
14 2023-01-15  1807.436205  1718.105130  1874.347378
15 2023-01-16  1782.018336  1718.105130  1874.347378
16 2023-01-17  1807.526934  1782.018336  1874.347378
17 2023-01-18  1759.104604  1759.104604  1874.347378
18 2023-01-19  1899.383205  1759.104604  1899.383205
19 2023-01-20  1737.190323  1737.190323  1899.383205
20 2023-01-21  1879.085877  1737.190323  1899.383205
21 2023-01-22  1764.209825  1737.190323  1899.383205
22 2023-01-23  1778.968337  1737.190323  1899.383205
23 2023-01-24  1810.054931  1737.190323  1879.085877
24 2023-01-25  1811.872655  1764.209825  1879.085877
25 2023-01-26  1799.407222  1764.209825  1811.872655
26 2023-01-27  1878.207999  1778.968337  1878.207999
27 2023-01-28  1792.985112  1792.985112  1878.207999
28 2023-01-29  1737.513279  1737.513279  1878.207999
29 2023-01-30  1819.914228  1737.513279  1878.207999
30 2023-01-31  1845.800732  1737.513279  1878.207999
31 2023-02-01  1771.185602  1737.513279  1845.800732
32 2023-02-02  1861.095324  1737.513279  1861.095324
33 2023-02-03  1813.792843  1771.185602  1861.095324
34 2023-02-04  1816.865832  1771.185602  1861.095324
35 2023-02-05  1827.270680  1771.185602  1861.095324
36 2023-02-06  1830.891767  1813.792843  1861.095324
37 2023-02-07  1827.030117  1813.792843  1830.891767
38 2023-02-08  1758.575667  1758.575667  1830.891767
39 2023-02-09  1757.382464  1757.382464  1830.891767
40 2023-02-10  1793.579160  1757.382464  1830.891767
41 2023-02-11  1837.183224  1757.382464  1837.183224
42 2023-02-12  1900.532616  1757.382464  1900.532616
43 2023-02-13  1793.196515  1757.382464  1900.532616
44 2023-02-14  1775.495735  1775.495735  1900.532616
45 2023-02-15  1762.475350  1762.475350  1900.532616
46 2023-02-16  1836.741797  1762.475350  1900.532616
47 2023-02-17  1778.774552  1762.475350  1836.741797
48 2023-02-18  1822.488293  1762.475350  1836.741797
49 2023-02-19  1826.721289  1762.475350  1836.741797
50 2023-02-20  1777.641927  1777.641927  1836.741797
51 2023-02-21  1821.298540  1777.641927  1826.721289
52 2023-02-22  1815.981495  1777.641927  1826.721289
53 2023-02-23  1816.124011  1777.641927  1826.721289
54 2023-02-24  1836.514622  1777.641927  1836.514622
55 2023-02-25  1712.070511  1712.070511  1836.514622
56 2023-02-26  1825.832585  1712.070511  1836.514622
57 2023-02-27  1802.919496  1712.070511  1836.514622
58 2023-02-28  1769.601080  1712.070511  1836.514622
59 2023-03-01  1870.028444  1712.070511  1870.028444