From 0a4004e7e4569a8c6ba8468ed164d377ecfe607e Mon Sep 17 00:00:00 2001 From: tfukaza Date: Sat, 1 Jun 2024 19:40:16 -0700 Subject: [PATCH] update --- harvest/broker/dummy.py | 7 +++---- harvest/plugin/_base.py | 20 ++++++-------------- harvest/plugin/dolt_options_plugin.py | 3 --- setup.cfg | 26 ++++++++++++++------------ 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/harvest/broker/dummy.py b/harvest/broker/dummy.py index 2e702d6..d45f656 100644 --- a/harvest/broker/dummy.py +++ b/harvest/broker/dummy.py @@ -1,4 +1,5 @@ import datetime as dt +import itertools import time from typing import Callable, Dict, Union @@ -153,10 +154,8 @@ def fetch_chain_data(self, symbol: str, date: Union[str, dt.datetime]) -> pd.Dat # Create a permutation of all the data data = [] - for t in types: - for s in strikes: - for e in expirations: - data.append([symbol, e, t, s]) + for typ, strike, expiration in itertools.product(types, strikes, expirations): + data.append([symbol, expiration, typ, strike]) # Create a DataFrame from the data # Columns are exp_date, strike, and type, with the index being the OCC symbol diff --git a/harvest/plugin/_base.py b/harvest/plugin/_base.py index a1038d7..c24890a 100644 --- a/harvest/plugin/_base.py +++ b/harvest/plugin/_base.py @@ -1,3 +1,4 @@ +import sys from typing import List @@ -10,32 +11,23 @@ class Plugin: {Name of source}{Functionality added}Plugin """ - def __init__(self, name: str, dependencies: List[str] = None) -> None: + def __init__(self, name: str, dependencies: List[str]): """ :name: a string that will serve as the name of the plugin. Must be a valid python variable because in the algo class, this plugin - will be an attribute of the algo and accessable via algo.name. + will be an attribute of the algo and accessible via algo.name. :dependencies: a list of python packages as strings that will be checked to ensure they are installed. Put all imports here in order to test if we have them. If not then error and call the installation function. """ self.name = name - for dep in dependencies: - self._check_dependency(dep) + if dep not in sys.modules: + raise ImportError(f"Missing dependency: {dep}. Run the installation steps.") def installation(self) -> str: """ - Returns how to install the necessary prerequsites for this plugin. + Returns how to install the necessary prerequisites for this plugin. """ raise NotImplementedError(f"No installation steps for plugin: {type(self).__name__}") - - def _check_dependency(self, dep: str) -> None: - # try: - # exec(f"import {dep}") - # except ModuleNotFoundError as e: - # debugger.error(f"Error importing module!\n {e}") - # debugger.error(self.installation()) - # raise e - pass diff --git a/harvest/plugin/dolt_options_plugin.py b/harvest/plugin/dolt_options_plugin.py index df00b93..3727d9c 100644 --- a/harvest/plugin/dolt_options_plugin.py +++ b/harvest/plugin/dolt_options_plugin.py @@ -21,9 +21,6 @@ def __init__(self, name: str = "dolt_options", path: str = "options") -> None: self.read = read def installation(self) -> str: - """ - Returns how to install the necessary prerequsites for this plugin. - """ return """ Useful Links: https://www.dolthub.com/ diff --git a/setup.cfg b/setup.cfg index 5ecd2ba..6176998 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,18 +16,14 @@ classifiers = packages = find: python_requires = >=3.9 install_requires = - pandas == 2.2.2 - finta == 1.3 - pyyaml == 5.3 - tqdm == 4.66.4 - tzlocal == 5.2 - tzdata == 2024.1 - yfinance >= 0.2.38 - SQLAlchemy == 2.0.0 - flask-login == 0.6.3 - flask-cors == 3.0.10 - flask == 3.0.3 - rich == 13.7.1 + pandas >= 2.0.0 + finta >= 1.0 + pyyaml >= 5.0 + tqdm >= 4.0.0 + tzlocal >= 5.0 + tzdata >= 2020.1 + rich >= 13.0.0 + SQLAlchemy >= 2.0.0 [options.extras_require] Alpaca = @@ -39,6 +35,12 @@ install_requires = webull Kraken = krakenex + Yahoo = + yfinance >= 0.2.38 + Web = + flask + flask-login + flask-cors Dev = coverage