Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved efficiency of async_websocket_rest_handler.py #591

Merged
merged 4 commits into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ApiCallHandler:
def __init__(self):
self.api_call_queue = asyncio.Queue()
self.executor = ThreadPoolExecutor() # Thread pool for running synchronous code
self.client = RESTClient() # Assumes POLYGON_API_KEY is set in the environment

async def enqueue_api_call(self, options_ticker):
await self.api_call_queue.put(options_ticker)
Expand All @@ -33,8 +34,7 @@ async def start_processing_api_calls(self):
self.api_call_queue.task_done()

def get_options_contract(self, options_ticker):
client = RESTClient() # Assumes POLYGON_API_KEY is set in the environment
return client.get_options_contract(options_ticker)
return self.client.get_options_contract(options_ticker)


class MessageHandler:
Expand Down
Loading