Spaces:
Sleeping
Sleeping
Update performance.py
Browse files- performance.py +12 -10
performance.py
CHANGED
|
@@ -47,11 +47,11 @@ Revision history:
|
|
| 47 |
print("Shape (Rows, Columns):", dld_history.shape) # Shows the shape of the DataFrame
|
| 48 |
2025-02.23.2000: Add the test cases for unit testing of part 1,2,3,4
|
| 49 |
Comment out part 5 which is not used, for better performance.
|
| 50 |
-
2025-02.23.
|
| 51 |
-
|
| 52 |
'''
|
| 53 |
|
| 54 |
-
script_version = 'version: (2025-02.23.
|
| 55 |
import gradio as gr
|
| 56 |
import yfinance as yf
|
| 57 |
import pandas as pd
|
|
@@ -67,7 +67,7 @@ num_years_calculation=52 # total years for calculation
|
|
| 67 |
# Define a list of years to calculate the trailing returns, cumulative returns, and so on
|
| 68 |
# remove the row of current year row since it is not a full year.
|
| 69 |
#years_list = [1, 2, 3, 5, 10, 15, 20, 25, 30, 40, 50, 60]
|
| 70 |
-
years_list = [1, 2, 3, 4,
|
| 71 |
|
| 72 |
# Set the stock tickers list
|
| 73 |
tickers_lists = [["qqq","hxq.to","spy", "vfv.to","xiu.to", "xbb.to","xcb.to","xhb.to"], #0 checking ETF
|
|
@@ -496,9 +496,11 @@ def calculation_response(message):
|
|
| 496 |
#print("\ndebug2 output_dataframe\n", output_dataframe)
|
| 497 |
|
| 498 |
# annual_returns - at any given day, for calculating trailing and cumulative returns, not to be displayed
|
| 499 |
-
|
| 500 |
-
annual_returns_dataframe=get_annual_returns_anyday_df(data_adj_close_df,
|
| 501 |
-
#print("\ndebug2-T
|
|
|
|
|
|
|
| 502 |
|
| 503 |
# Trailing Return
|
| 504 |
if (leap_year):
|
|
@@ -591,7 +593,7 @@ cumulative_return_all_dataframe=get_cumulative_return_all(annual_returns_datafra
|
|
| 591 |
#print("\ndebug part 6 test\n", output_dataframe0)
|
| 592 |
|
| 593 |
#-------- testing calculation_response
|
| 594 |
-
|
| 595 |
-
#bot_message = calculation_response("SPY")
|
| 596 |
-
#print(bot_message)
|
| 597 |
|
|
|
|
| 47 |
print("Shape (Rows, Columns):", dld_history.shape) # Shows the shape of the DataFrame
|
| 48 |
2025-02.23.2000: Add the test cases for unit testing of part 1,2,3,4
|
| 49 |
Comment out part 5 which is not used, for better performance.
|
| 50 |
+
2025-02.23.2040: Fix the date errors
|
| 51 |
+
|
| 52 |
'''
|
| 53 |
|
| 54 |
+
script_version = 'version: (2025-02.23.2040)'
|
| 55 |
import gradio as gr
|
| 56 |
import yfinance as yf
|
| 57 |
import pandas as pd
|
|
|
|
| 67 |
# Define a list of years to calculate the trailing returns, cumulative returns, and so on
|
| 68 |
# remove the row of current year row since it is not a full year.
|
| 69 |
#years_list = [1, 2, 3, 5, 10, 15, 20, 25, 30, 40, 50, 60]
|
| 70 |
+
years_list = [1, 2, 3, 4,5,6,7,8,9,10,11,12,13,14,15, 20, 25, 30, 40, 50, 60]
|
| 71 |
|
| 72 |
# Set the stock tickers list
|
| 73 |
tickers_lists = [["qqq","hxq.to","spy", "vfv.to","xiu.to", "xbb.to","xcb.to","xhb.to"], #0 checking ETF
|
|
|
|
| 496 |
#print("\ndebug2 output_dataframe\n", output_dataframe)
|
| 497 |
|
| 498 |
# annual_returns - at any given day, for calculating trailing and cumulative returns, not to be displayed
|
| 499 |
+
calculation_end_date_for_others_str=calculation_end_date_str
|
| 500 |
+
annual_returns_dataframe=get_annual_returns_anyday_df(data_adj_close_df, calculation_end_date_for_others_str)
|
| 501 |
+
#print("\ndebug2-T get_annual_returns_anyday_df\n", annual_returns_dataframe)
|
| 502 |
+
#print("\ndebug2-T calculation_end_date_str\n", calculation_end_date_str)
|
| 503 |
+
#print("\ndebug2-T calculation_end_date_for_others_str\n", calculation_end_date_for_others_str)
|
| 504 |
|
| 505 |
# Trailing Return
|
| 506 |
if (leap_year):
|
|
|
|
| 593 |
#print("\ndebug part 6 test\n", output_dataframe0)
|
| 594 |
|
| 595 |
#-------- testing calculation_response
|
| 596 |
+
bot_message = calculation_response("8")
|
| 597 |
+
#bot_message = calculation_response("SPY MSFT")
|
| 598 |
+
#print("\ndebug calculation_response\n", bot_message)
|
| 599 |
|