Spaces:
Running
Running
Update stock.py
Browse files
stock.py
CHANGED
|
@@ -5,6 +5,8 @@ import pandas as pd
|
|
| 5 |
import traceback
|
| 6 |
from ta_indi_pat import *
|
| 7 |
|
|
|
|
|
|
|
| 8 |
# ================================================================
|
| 9 |
# BASIC YFINANCE FETCHERS
|
| 10 |
# ================================================================
|
|
@@ -67,7 +69,8 @@ def fetch_intraday(symbol, indicators=None):
|
|
| 67 |
|
| 68 |
if isinstance(df.columns, pd.MultiIndex):
|
| 69 |
df.columns = df.columns.get_level_values(0)
|
| 70 |
-
|
|
|
|
| 71 |
#chart_html = build_chart(df, indicators=indicators)
|
| 72 |
table_html = make_table(df.tail(50))
|
| 73 |
return wrap_html(f"<h2>Last 50 Rows</h2>{table_html}",
|
|
@@ -86,7 +89,8 @@ def fetch_daily(symbol, source="yfinance", max_rows=200):
|
|
| 86 |
|
| 87 |
if isinstance(df.columns, pd.MultiIndex):
|
| 88 |
df.columns = df.columns.get_level_values(0)
|
| 89 |
-
|
|
|
|
| 90 |
df_disp = df.head(max_rows)
|
| 91 |
combined_df = talib_df(df_disp)
|
| 92 |
table_html = combined_df.to_html(
|
|
@@ -113,7 +117,8 @@ def fetch_qresult(symbol):
|
|
| 113 |
df = qresult(symbol)
|
| 114 |
if df.empty:
|
| 115 |
return wrap_html(f"<h1>No quarterly results for {symbol}</h1>")
|
| 116 |
-
|
|
|
|
| 117 |
df_fmt = df.copy()
|
| 118 |
for col in df_fmt.columns:
|
| 119 |
df_fmt[col] = df_fmt[col].apply(
|
|
@@ -135,7 +140,8 @@ def fetch_result(symbol):
|
|
| 135 |
df = result(symbol)
|
| 136 |
if df.empty:
|
| 137 |
return wrap_html(f"<h1>No annual results for {symbol}</h1>")
|
| 138 |
-
|
|
|
|
| 139 |
df_fmt = df.copy()
|
| 140 |
for col in df_fmt.columns:
|
| 141 |
df_fmt[col] = df_fmt[col].apply(
|
|
@@ -157,7 +163,8 @@ def fetch_balance(symbol):
|
|
| 157 |
df = balance(symbol)
|
| 158 |
if df.empty:
|
| 159 |
return wrap_html(f"<h1>No balance sheet for {symbol}</h1>")
|
| 160 |
-
|
|
|
|
| 161 |
df_fmt = df.copy()
|
| 162 |
for col in df_fmt.columns:
|
| 163 |
df_fmt[col] = df_fmt[col].apply(
|
|
@@ -179,7 +186,8 @@ def fetch_cashflow(symbol):
|
|
| 179 |
df = cashflow(symbol)
|
| 180 |
if df.empty:
|
| 181 |
return wrap_html(f"<h1>No cashflow for {symbol}</h1>")
|
| 182 |
-
|
|
|
|
| 183 |
df_fmt = df.copy()
|
| 184 |
for col in df_fmt.columns:
|
| 185 |
df_fmt[col] = df_fmt[col].apply(
|
|
|
|
| 5 |
import traceback
|
| 6 |
from ta_indi_pat import *
|
| 7 |
|
| 8 |
+
#file_name = f"bhav/bhav_{date_str.replace('-', '_')}.csv"
|
| 9 |
+
#upload_file("eshanhf",file_name,df)
|
| 10 |
# ================================================================
|
| 11 |
# BASIC YFINANCE FETCHERS
|
| 12 |
# ================================================================
|
|
|
|
| 69 |
|
| 70 |
if isinstance(df.columns, pd.MultiIndex):
|
| 71 |
df.columns = df.columns.get_level_values(0)
|
| 72 |
+
file_name = f"intraday/{symbol}_{date_str.replace('-', '_')}.csv"
|
| 73 |
+
upload_file("eshanhf",file_name,df)
|
| 74 |
#chart_html = build_chart(df, indicators=indicators)
|
| 75 |
table_html = make_table(df.tail(50))
|
| 76 |
return wrap_html(f"<h2>Last 50 Rows</h2>{table_html}",
|
|
|
|
| 89 |
|
| 90 |
if isinstance(df.columns, pd.MultiIndex):
|
| 91 |
df.columns = df.columns.get_level_values(0)
|
| 92 |
+
file_name = f"daily/{symbol}_{date_str.replace('-', '_')}.csv"
|
| 93 |
+
upload_file("eshanhf",file_name,df)
|
| 94 |
df_disp = df.head(max_rows)
|
| 95 |
combined_df = talib_df(df_disp)
|
| 96 |
table_html = combined_df.to_html(
|
|
|
|
| 117 |
df = qresult(symbol)
|
| 118 |
if df.empty:
|
| 119 |
return wrap_html(f"<h1>No quarterly results for {symbol}</h1>")
|
| 120 |
+
file_name = f"qresult/{symbol}_{date_str.replace('-', '_')}.csv"
|
| 121 |
+
upload_file("eshanhf",file_name,df)
|
| 122 |
df_fmt = df.copy()
|
| 123 |
for col in df_fmt.columns:
|
| 124 |
df_fmt[col] = df_fmt[col].apply(
|
|
|
|
| 140 |
df = result(symbol)
|
| 141 |
if df.empty:
|
| 142 |
return wrap_html(f"<h1>No annual results for {symbol}</h1>")
|
| 143 |
+
file_name = f"result/{symbol}_{date_str.replace('-', '_')}.csv"
|
| 144 |
+
upload_file("eshanhf",file_name,df)
|
| 145 |
df_fmt = df.copy()
|
| 146 |
for col in df_fmt.columns:
|
| 147 |
df_fmt[col] = df_fmt[col].apply(
|
|
|
|
| 163 |
df = balance(symbol)
|
| 164 |
if df.empty:
|
| 165 |
return wrap_html(f"<h1>No balance sheet for {symbol}</h1>")
|
| 166 |
+
file_name = f"balance/{symbol}_{date_str.replace('-', '_')}.csv"
|
| 167 |
+
upload_file("eshanhf",file_name,df)
|
| 168 |
df_fmt = df.copy()
|
| 169 |
for col in df_fmt.columns:
|
| 170 |
df_fmt[col] = df_fmt[col].apply(
|
|
|
|
| 186 |
df = cashflow(symbol)
|
| 187 |
if df.empty:
|
| 188 |
return wrap_html(f"<h1>No cashflow for {symbol}</h1>")
|
| 189 |
+
file_name = f"cashflow/{symbol}_{date_str.replace('-', '_')}.csv"
|
| 190 |
+
upload_file("eshanhf",file_name,df)
|
| 191 |
df_fmt = df.copy()
|
| 192 |
for col in df_fmt.columns:
|
| 193 |
df_fmt[col] = df_fmt[col].apply(
|