mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
hotfix/intrinio-options-date: Fix comparing values between str and datetime (#5997)
* fix compare between str and datetime * unused argument * get_weekday * lint --------- Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Intrinio Options Chains Model."""
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
from datetime import (
|
||||
date as dateType,
|
||||
datetime,
|
||||
@@ -116,11 +117,15 @@ class IntrinioOptionsChainsFetcher(
|
||||
date = datetime.now().date() if query.date is None else query.date
|
||||
date = get_weekday(date)
|
||||
|
||||
results = await amake_requests(await get_urls(date), callback, **kwargs)
|
||||
results = await amake_requests(
|
||||
await get_urls(date.strftime("%Y-%m-%d")), callback, **kwargs
|
||||
)
|
||||
|
||||
if not results:
|
||||
urls = await get_urls(get_weekday(date - timedelta(days=1)))
|
||||
results = await amake_requests(urls, callback, **kwargs)
|
||||
urls = await get_urls(
|
||||
get_weekday(date - timedelta(days=1)).strftime("%Y-%m-%d")
|
||||
)
|
||||
results = await amake_requests(urls, response_callback=callback, **kwargs)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
@@ -123,11 +123,11 @@ async def get_data_one(url: str, **kwargs: Any) -> Dict[str, Any]:
|
||||
return data
|
||||
|
||||
|
||||
def get_weekday(date: dateType) -> str:
|
||||
def get_weekday(date: dateType) -> dateType:
|
||||
"""Return the weekday date."""
|
||||
if date.weekday() in [5, 6]:
|
||||
return (date - timedelta(days=date.weekday() - 4)).strftime("%Y-%m-%d")
|
||||
return date.strftime("%Y-%m-%d")
|
||||
return date - timedelta(days=date.weekday() - 4)
|
||||
return date
|
||||
|
||||
|
||||
async def async_get_data_one(
|
||||
|
||||
Reference in New Issue
Block a user