bugfixign
This commit is contained in:
parent
a1b187f9f2
commit
1cdf66b5ad
@ -62,8 +62,8 @@ def correct_weekday(selected_date):
|
|||||||
return selected_date
|
return selected_date
|
||||||
|
|
||||||
# Create a semaphore to limit concurrent requests
|
# Create a semaphore to limit concurrent requests
|
||||||
REQUEST_LIMIT = 500
|
REQUEST_LIMIT = 30
|
||||||
PAUSE_TIME = 5
|
PAUSE_TIME = 1
|
||||||
|
|
||||||
def check_existing_file(symbol):
|
def check_existing_file(symbol):
|
||||||
file_path = f"json/wiim/company/{symbol}.json"
|
file_path = f"json/wiim/company/{symbol}.json"
|
||||||
@ -95,8 +95,8 @@ def check_existing_file(symbol):
|
|||||||
else:
|
else:
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
print(f"Deleted file for {symbol} as all entries were older than two weeks.")
|
print(f"Deleted file for {symbol} as all entries were older than two weeks.")
|
||||||
except Exception as e:
|
except:
|
||||||
print(f"Error processing existing file for {symbol}: {e}")
|
pass
|
||||||
|
|
||||||
async def get_endpoint(session, symbol, con, semaphore):
|
async def get_endpoint(session, symbol, con, semaphore):
|
||||||
async with semaphore:
|
async with semaphore:
|
||||||
@ -144,8 +144,7 @@ async def get_endpoint(session, symbol, con, semaphore):
|
|||||||
change_percent = round((df['close'].iloc[1] / df['close'].iloc[0] - 1) * 100, 2)
|
change_percent = round((df['close'].iloc[1] / df['close'].iloc[0] - 1) * 100, 2)
|
||||||
else:
|
else:
|
||||||
change_percent = '-'
|
change_percent = '-'
|
||||||
except Exception as e:
|
except:
|
||||||
print(f"Error fetching stock data for {symbol}: {e}")
|
|
||||||
change_percent = '-'
|
change_percent = '-'
|
||||||
|
|
||||||
res_list.append({
|
res_list.append({
|
||||||
@ -163,8 +162,8 @@ async def get_endpoint(session, symbol, con, semaphore):
|
|||||||
else:
|
else:
|
||||||
check_existing_file(symbol)
|
check_existing_file(symbol)
|
||||||
|
|
||||||
except Exception as e:
|
except:
|
||||||
print(f"Error fetching data for {symbol}: {e}")
|
pass
|
||||||
|
|
||||||
async def run():
|
async def run():
|
||||||
con = sqlite3.connect('stocks.db')
|
con = sqlite3.connect('stocks.db')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user