fork(1) download
  1. import pandas as pd
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5. # Örnek fiyat verisi
  6. data = {
  7. 'Date': pd.date_range(start='2023-01-01', periods=60, freq='D'),
  8. 'Price': np.random.normal(loc=1800, scale=50, size=60) # Rastgele fiyat verisi
  9. }
  10.  
  11. df = pd.DataFrame(data)
  12.  
  13. # Destek ve direnç seviyelerini bulmak için fonksiyon
  14. def calculate_support_resistance(df, window=5):
  15. df['Max'] = df['Price'].rolling(window=window).max() # Direnç
  16. df['Min'] = df['Price'].rolling(window=window).min() # Destek
  17. return df
  18.  
  19. # Destek ve direnç seviyelerini hesapla
  20. df = calculate_support_resistance(df)
  21.  
  22. # Sonuçları yazdır
  23. print("Son Fiyat Verileri:")
  24. print(df[['Date', 'Price', 'Min', 'Max']])
  25.  
  26. # Grafik Çizimi
  27. plt.figure(figsize=(12, 6))
  28. plt.plot(df['Date'], df['Price'], label='Fiyat', color='blue')
  29. plt.plot(df['Date'], df['Min'], label='Destek', linestyle='--', color='green')
  30. plt.plot(df['Date'], df['Max'], label='Direnç', linestyle='--', color='red')
  31. plt.title('Fiyat, Destek ve Direnç Seviyeleri')
  32. plt.xlabel('Tarih')
  33. plt.ylabel('Fiyat (USD)')
  34. plt.legend()
  35. plt.show()
  36.  
Success #stdin #stdout 2.31s 82632KB
stdin
Standard input is empty
stdout
Son Fiyat Verileri:
         Date        Price          Min          Max
0  2023-01-01  1744.127912          NaN          NaN
1  2023-01-02  1776.059040          NaN          NaN
2  2023-01-03  1799.661994          NaN          NaN
3  2023-01-04  1758.661402          NaN          NaN
4  2023-01-05  1754.209083  1744.127912  1799.661994
5  2023-01-06  1836.635988  1754.209083  1836.635988
6  2023-01-07  1834.735189  1754.209083  1836.635988
7  2023-01-08  1788.114054  1754.209083  1836.635988
8  2023-01-09  1802.081876  1754.209083  1836.635988
9  2023-01-10  1747.508834  1747.508834  1836.635988
10 2023-01-11  1799.143276  1747.508834  1834.735189
11 2023-01-12  1768.272876  1747.508834  1802.081876
12 2023-01-13  1828.686993  1747.508834  1828.686993
13 2023-01-14  1818.247238  1747.508834  1828.686993
14 2023-01-15  1774.448483  1768.272876  1828.686993
15 2023-01-16  1774.389159  1768.272876  1828.686993
16 2023-01-17  1769.033698  1769.033698  1828.686993
17 2023-01-18  1857.250878  1769.033698  1857.250878
18 2023-01-19  1770.996896  1769.033698  1857.250878
19 2023-01-20  1916.123755  1769.033698  1916.123755
20 2023-01-21  1761.605785  1761.605785  1916.123755
21 2023-01-22  1855.403924  1761.605785  1916.123755
22 2023-01-23  1791.145468  1761.605785  1916.123755
23 2023-01-24  1785.701225  1761.605785  1916.123755
24 2023-01-25  1857.776329  1761.605785  1857.776329
25 2023-01-26  1802.894596  1785.701225  1857.776329
26 2023-01-27  1845.583060  1785.701225  1857.776329
27 2023-01-28  1780.437818  1780.437818  1857.776329
28 2023-01-29  1823.562706  1780.437818  1857.776329
29 2023-01-30  1820.210853  1780.437818  1845.583060
30 2023-01-31  1739.311041  1739.311041  1845.583060
31 2023-02-01  1769.904965  1739.311041  1823.562706
32 2023-02-02  1792.456545  1739.311041  1823.562706
33 2023-02-03  1793.366259  1739.311041  1820.210853
34 2023-02-04  1859.961793  1739.311041  1859.961793
35 2023-02-05  1803.991951  1769.904965  1859.961793
36 2023-02-06  1781.842197  1781.842197  1859.961793
37 2023-02-07  1936.330172  1781.842197  1936.330172
38 2023-02-08  1830.050030  1781.842197  1936.330172
39 2023-02-09  1807.504290  1781.842197  1936.330172
40 2023-02-10  1851.661120  1781.842197  1936.330172
41 2023-02-11  1843.117719  1807.504290  1936.330172
42 2023-02-12  1872.218206  1807.504290  1872.218206
43 2023-02-13  1827.557503  1807.504290  1872.218206
44 2023-02-14  1757.909022  1757.909022  1872.218206
45 2023-02-15  1808.146404  1757.909022  1872.218206
46 2023-02-16  1918.961928  1757.909022  1918.961928
47 2023-02-17  1854.745303  1757.909022  1918.961928
48 2023-02-18  1792.622589  1757.909022  1918.961928
49 2023-02-19  1840.368876  1792.622589  1918.961928
50 2023-02-20  1777.607566  1777.607566  1918.961928
51 2023-02-21  1789.905736  1777.607566  1854.745303
52 2023-02-22  1786.126078  1777.607566  1840.368876
53 2023-02-23  1737.346562  1737.346562  1840.368876
54 2023-02-24  1875.959645  1737.346562  1875.959645
55 2023-02-25  1765.651232  1737.346562  1875.959645
56 2023-02-26  1790.201356  1737.346562  1875.959645
57 2023-02-27  1768.367927  1737.346562  1875.959645
58 2023-02-28  1698.480825  1698.480825  1875.959645
59 2023-03-01  1785.855864  1698.480825  1790.201356