fork 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.38s 82708KB
stdin
Standard input is empty
stdout
Son Fiyat Verileri:
         Date        Price          Min          Max
0  2023-01-01  1767.784290          NaN          NaN
1  2023-01-02  1785.632729          NaN          NaN
2  2023-01-03  1728.984714          NaN          NaN
3  2023-01-04  1850.699969          NaN          NaN
4  2023-01-05  1659.516365  1659.516365  1850.699969
5  2023-01-06  1676.148284  1659.516365  1850.699969
6  2023-01-07  1733.439568  1659.516365  1850.699969
7  2023-01-08  1753.904403  1659.516365  1850.699969
8  2023-01-09  1749.969830  1659.516365  1753.904403
9  2023-01-10  1798.024621  1676.148284  1798.024621
10 2023-01-11  1766.432576  1733.439568  1798.024621
11 2023-01-12  1859.367344  1749.969830  1859.367344
12 2023-01-13  1793.262655  1749.969830  1859.367344
13 2023-01-14  1790.712189  1766.432576  1859.367344
14 2023-01-15  1854.813196  1766.432576  1859.367344
15 2023-01-16  1815.238177  1790.712189  1859.367344
16 2023-01-17  1908.723560  1790.712189  1908.723560
17 2023-01-18  1803.484781  1790.712189  1908.723560
18 2023-01-19  1882.878772  1803.484781  1908.723560
19 2023-01-20  1835.478459  1803.484781  1908.723560
20 2023-01-21  1786.370575  1786.370575  1908.723560
21 2023-01-22  1777.823219  1777.823219  1882.878772
22 2023-01-23  1916.187995  1777.823219  1916.187995
23 2023-01-24  1950.789029  1777.823219  1950.789029
24 2023-01-25  1803.805040  1777.823219  1950.789029
25 2023-01-26  1793.714869  1777.823219  1950.789029
26 2023-01-27  1899.699788  1793.714869  1950.789029
27 2023-01-28  1790.318729  1790.318729  1950.789029
28 2023-01-29  1834.825777  1790.318729  1899.699788
29 2023-01-30  1800.893774  1790.318729  1899.699788
30 2023-01-31  1879.882694  1790.318729  1899.699788
31 2023-02-01  1878.563766  1790.318729  1879.882694
32 2023-02-02  1703.965207  1703.965207  1879.882694
33 2023-02-03  1839.699040  1703.965207  1879.882694
34 2023-02-04  1816.682795  1703.965207  1879.882694
35 2023-02-05  1727.004342  1703.965207  1878.563766
36 2023-02-06  1821.553534  1703.965207  1839.699040
37 2023-02-07  1740.040606  1727.004342  1839.699040
38 2023-02-08  1802.447135  1727.004342  1821.553534
39 2023-02-09  1871.938320  1727.004342  1871.938320
40 2023-02-10  1831.555247  1740.040606  1871.938320
41 2023-02-11  1763.265767  1740.040606  1871.938320
42 2023-02-12  1727.322007  1727.322007  1871.938320
43 2023-02-13  1818.609659  1727.322007  1871.938320
44 2023-02-14  1877.931259  1727.322007  1877.931259
45 2023-02-15  1802.656211  1727.322007  1877.931259
46 2023-02-16  1782.195963  1727.322007  1877.931259
47 2023-02-17  1770.650032  1770.650032  1877.931259
48 2023-02-18  1828.902532  1770.650032  1877.931259
49 2023-02-19  1770.141664  1770.141664  1828.902532
50 2023-02-20  1911.062053  1770.141664  1911.062053
51 2023-02-21  1779.493007  1770.141664  1911.062053
52 2023-02-22  1774.607727  1770.141664  1911.062053
53 2023-02-23  1732.302571  1732.302571  1911.062053
54 2023-02-24  1832.244628  1732.302571  1911.062053
55 2023-02-25  1763.212096  1732.302571  1832.244628
56 2023-02-26  1820.127274  1732.302571  1832.244628
57 2023-02-27  1809.533726  1732.302571  1832.244628
58 2023-02-28  1734.330396  1734.330396  1832.244628
59 2023-03-01  1768.308681  1734.330396  1820.127274