RIZAEFE commited on
Commit
90b5942
·
verified ·
1 Parent(s): d89e2f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -20
app.py CHANGED
@@ -3,6 +3,7 @@ import yfinance as yf
3
  import pandas as pd
4
  from datetime import date
5
  from io import BytesIO
 
6
 
7
  st.set_page_config(page_title='Stock Chart')
8
 
@@ -28,36 +29,48 @@ if start_date > end_date:
28
  else:
29
  # Veri çekme işlemi
30
  df = yf.download(sembol_kodu, start=start_date, end=end_date)
31
-
32
  if df.empty:
33
  st.warning('No data found for selected symbol and date range.')
34
  else:
35
  # Zaman dilimi bilgisini kaldırma
36
  df.index = df.index.tz_localize(None)
37
-
38
  # Veri çerçevesini gösterme
39
  st.subheader('Stock Data')
40
  st.write(df)
41
-
42
- # Grafik çizme
43
- st.subheader('Closing Price Chart')
44
- st.line_chart(df['Close'])
45
-
46
- st.subheader('Opening Price Chart')
47
- st.line_chart(df['Open'])
48
-
49
- st.subheader('High Price Chart')
50
- st.plotly_chart(df['High'])
51
-
52
- st.subheader('Low Price Chart')
53
- st.plotly_chart(df['Low'])
54
-
 
 
 
 
 
 
 
 
 
 
 
 
55
  st.subheader('Volume Price Chart')
56
  st.plotly_chart(df['Volume'])
57
-
58
  # Excel dosyasını indirme
59
  st.subheader('Stock Data Excel File')
60
-
61
  def to_excel(df):
62
  output = BytesIO()
63
  writer = pd.ExcelWriter(output, engine='xlsxwriter')
@@ -65,11 +78,11 @@ else:
65
  writer.close()
66
  processed_data = output.getvalue()
67
  return processed_data
68
-
69
  excel_data = to_excel(df)
70
  st.download_button(
71
  label='Download as Excel',
72
  data=excel_data,
73
  file_name=f'{sembol_kodu}_data.xlsx',
74
  mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
75
- )
 
3
  import pandas as pd
4
  from datetime import date
5
  from io import BytesIO
6
+ import plotly.graph_objects as go
7
 
8
  st.set_page_config(page_title='Stock Chart')
9
 
 
29
  else:
30
  # Veri çekme işlemi
31
  df = yf.download(sembol_kodu, start=start_date, end=end_date)
32
+
33
  if df.empty:
34
  st.warning('No data found for selected symbol and date range.')
35
  else:
36
  # Zaman dilimi bilgisini kaldırma
37
  df.index = df.index.tz_localize(None)
38
+
39
  # Veri çerçevesini gösterme
40
  st.subheader('Stock Data')
41
  st.write(df)
42
+
43
+
44
+
45
+
46
+
47
+ # Mum (Candle) grafiği oluşturma
48
+ st.subheader('Candlestick Chart')
49
+ fig = go.Figure(data=[go.Candlestick(x=df.index,
50
+ open=df['Open'],
51
+ high=df['High'],
52
+ low=df['Low'],
53
+ close=df['Close'])])
54
+
55
+ # Grafik düzenleme
56
+ fig.update_layout(
57
+ title=f'{sembol} Candlestick Chart',
58
+ yaxis_title='Price',
59
+ xaxis_title='Date',
60
+ template='plotly_white'
61
+ )
62
+
63
+ # Grafiği gösterme
64
+ st.plotly_chart(fig)
65
+
66
+
67
+
68
  st.subheader('Volume Price Chart')
69
  st.plotly_chart(df['Volume'])
70
+
71
  # Excel dosyasını indirme
72
  st.subheader('Stock Data Excel File')
73
+
74
  def to_excel(df):
75
  output = BytesIO()
76
  writer = pd.ExcelWriter(output, engine='xlsxwriter')
 
78
  writer.close()
79
  processed_data = output.getvalue()
80
  return processed_data
81
+
82
  excel_data = to_excel(df)
83
  st.download_button(
84
  label='Download as Excel',
85
  data=excel_data,
86
  file_name=f'{sembol_kodu}_data.xlsx',
87
  mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
88
+ )