Skip to content

Commit

Permalink
Fix timing
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmysitu committed Nov 4, 2023
1 parent 23f630a commit dfd62dc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions msfinance/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def _get_valuation(self, ticker, exchange, statistics, update=False):

statistics_file = self.download_dir + f"/{unique_id}.xls"
os.rename(tmp_file, statistics_file)
time.sleep(1)

# Update database
df = pd.read_excel(statistics_file)
Expand Down Expand Up @@ -223,7 +224,11 @@ def _get_financials(self, ticker, exchange, statement, period='Annual', stage='R

# Select statement period
period_list_button = self.driver.find_element(By.XPATH, "//button[contains(., 'Annual') and @aria-haspopup='true']")
period_list_button.click()
try:
period_list_button.click()
time.sleep(1)
except ElementClickInterceptedException:
pass

if 'Annual' == period:
period_button = self.driver.find_element(By.XPATH, "//span[contains(., 'Annual') and @class='mds-list-group__item-text__sal']")
Expand All @@ -232,14 +237,15 @@ def _get_financials(self, ticker, exchange, statement, period='Annual', stage='R

try:
period_button.click()
time.sleep(1)
except ElementClickInterceptedException:
pass

# Select statement type
type_list_button = self.driver.find_element(By.XPATH, "//button[contains(., 'As Originally Reported') and @aria-haspopup='true']")

try:
type_list_button.click()
time.sleep(1)
except ElementClickInterceptedException:
pass

Expand All @@ -250,6 +256,7 @@ def _get_financials(self, ticker, exchange, statement, period='Annual', stage='R

try:
type_button.click()
time.sleep(1)
except ElementClickInterceptedException:
pass

Expand All @@ -271,6 +278,7 @@ def _get_financials(self, ticker, exchange, statement, period='Annual', stage='R

statement_file = self.download_dir + f"/{unique_id}.xls"
os.rename(tmp_file, statement_file)
time.sleep(1)

# Update datebase
df = pd.read_excel(statement_file)
Expand Down

0 comments on commit dfd62dc

Please sign in to comment.