forked from bobcolner/pandas-polygon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarket_details_ray.py
30 lines (21 loc) · 890 Bytes
/
market_details_ray.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import ray
# from tenacity import retry, stop_after_attempt, wait_exponential
from polygon_rest_api import get_ticker_details
@ray.remote
# @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=2, max=10))
def get_symbol_details_ray(symbol: str) -> dict:
print(symbol)
return get_ticker_details(symbol)
def symbol_details_ray(symbols: list) -> list:
futures = []
for symbol in symbols:
result = get_symbol_details_ray.remote(symbol)
if result:
futures.append(result)
return ray.get(futures)
def dets_to_df(symbols):
results = symbol_details_ray(symbols)
results = [i for i in results if i] # remove empty/null items from list
return pd.DataFrame(results)
def get_remaining_symbols(requested_symbols: list, current_symbol_dets: list) -> list:
return list(set(requested_symbols) - set(current_symbol_dets))