-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Weather API for better trade improvements (#13)
Related to #3 Add Weather API integration to improve trading strategies. * **Configuration Changes:** - Add `WEATHER_API_KEY` and `WEATHER_API_ENDPOINT` to `config/api_config.py` and `.env`. - Add weather API configurations to `config/config.py`. * **Weather Data Fetching:** - Create `data/weather_data_fetcher.py` to fetch weather data from the Weather API. - Initialize `WeatherDataFetcher` in `data/data_fetcher.py` and add method `fetch_and_process_weather_data`. * **Strategy Updates:** - Modify `strategies/futures_strategy.py` and `strategies/options_strategy.py` to incorporate weather data in trading decisions. - Add methods to analyze weather data and generate signals based on weather conditions. * **Main Function Updates:** - Import and initialize `WeatherDataFetcher` in `main.py`. - Modify `process_market_data` function to include weather data processing and notifications.
- Loading branch information
Showing
8 changed files
with
184 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import requests | ||
import logging | ||
|
||
class WeatherDataFetcher: | ||
""" | ||
Fetches weather data from the Weather API. | ||
""" | ||
|
||
def __init__(self, api_key: str, api_endpoint: str): | ||
""" | ||
Initialize the WeatherDataFetcher with API key and endpoint. | ||
Args: | ||
api_key: API key for the Weather API | ||
api_endpoint: Endpoint URL for the Weather API | ||
""" | ||
self.api_key = api_key | ||
self.api_endpoint = api_endpoint | ||
self.logger = logging.getLogger(__name__) | ||
|
||
def fetch_weather_data(self, location: str) -> dict: | ||
""" | ||
Fetch weather data for a given location. | ||
Args: | ||
location: Location for which to fetch weather data | ||
Returns: | ||
Dictionary containing weather data | ||
""" | ||
try: | ||
self.logger.info(f"Fetching weather data for location: {location}") | ||
response = requests.get( | ||
self.api_endpoint, | ||
params={"q": location, "appid": self.api_key} | ||
) | ||
response.raise_for_status() | ||
weather_data = response.json() | ||
self.logger.info(f"Weather data fetched successfully for location: {location}") | ||
return weather_data | ||
except requests.RequestException as e: | ||
self.logger.error(f"Error fetching weather data: {str(e)}") | ||
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters