feat: Implement multi-source weather data collection from various APIs and integrate Polymarket API functionality.
This commit is contained in:
@@ -375,7 +375,9 @@ class PolymarketClient:
|
||||
continue
|
||||
|
||||
c_id = m.get("conditionId")
|
||||
if c_id and c_id not in seen_condition_ids:
|
||||
# 对于多选一市场,不同档位共享 conditionId,但 tokenId 不同
|
||||
unique_key = f"{c_id}_{m.get('activeTokenId')}"
|
||||
if c_id and unique_key not in seen_condition_ids:
|
||||
all_weather_markets.append(
|
||||
{
|
||||
"condition_id": c_id,
|
||||
@@ -387,7 +389,7 @@ class PolymarketClient:
|
||||
"slug": event_slug,
|
||||
}
|
||||
)
|
||||
seen_condition_ids.add(c_id)
|
||||
seen_condition_ids.add(unique_key)
|
||||
new_markets_count += 1
|
||||
if new_markets_count > 0:
|
||||
logger.debug(f"[{source_label}] 发现 {new_markets_count} 个新市场合约")
|
||||
|
||||
@@ -17,9 +17,7 @@ class WeatherDataCollector:
|
||||
|
||||
def __init__(self, config: dict):
|
||||
self.config = config
|
||||
self.openweather_key = config.get("openweather_api_key")
|
||||
self.wunderground_key = config.get("wunderground_api_key")
|
||||
self.visualcrossing_key = config.get("visualcrossing_api_key")
|
||||
|
||||
self.timeout = 10
|
||||
self.session = requests.Session()
|
||||
@@ -45,8 +43,7 @@ class WeatherDataCollector:
|
||||
Returns:
|
||||
dict: Weather data
|
||||
"""
|
||||
if not self.openweather_key:
|
||||
logger.warning("OpenWeatherMap API key not configured")
|
||||
if not getattr(self, "openweather_key", None):
|
||||
return None
|
||||
|
||||
query = f"{city},{country}" if country else city
|
||||
@@ -123,8 +120,7 @@ class WeatherDataCollector:
|
||||
Returns:
|
||||
dict: Historical weather data
|
||||
"""
|
||||
if not self.visualcrossing_key:
|
||||
logger.warning("Visual Crossing API key not configured")
|
||||
if not getattr(self, "visualcrossing_key", None):
|
||||
return None
|
||||
|
||||
# Default to last 30 days if no dates provided
|
||||
@@ -391,16 +387,6 @@ class WeatherDataCollector:
|
||||
if open_meteo:
|
||||
results["open-meteo"] = open_meteo
|
||||
|
||||
# OpenWeatherMap (Requires Key)
|
||||
openweather = self.fetch_from_openweather(city, country)
|
||||
if openweather:
|
||||
results["openweathermap"] = openweather
|
||||
|
||||
# Visual Crossing (Requires Key)
|
||||
visualcrossing = self.fetch_from_visualcrossing(city)
|
||||
if visualcrossing:
|
||||
results["visualcrossing"] = visualcrossing
|
||||
|
||||
return results
|
||||
|
||||
def check_consensus(self, forecasts: Dict) -> Dict:
|
||||
|
||||
Reference in New Issue
Block a user