From bdd7780dd7b701d430ee0309a6c28619faa79068 Mon Sep 17 00:00:00 2001 From: realiti4 Date: Fri, 29 Nov 2024 21:52:37 +0300 Subject: [PATCH] remove preceding nan data for uber method --- pyproject.toml | 29 +++++++++++++++++++++++++++++ setup.py | 26 -------------------------- tradingfeatures/uber.py | 26 ++++---------------------- 3 files changed, 33 insertions(+), 48 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1811040 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,29 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "tradingfeatures" +version = "0.8.0" +description = "A useful tool to download market history from popular exchanges." +readme = { file = "README.md", content-type = "text/markdown" } +requires-python = ">=3.11" +keywords = ["download", "market", "history", "binance", "bitfinex", "bitmex", "bitstamp"] +license = { text = "MIT License" } +authors = [ + { name = "Onur Cetinkol", email = "realiti44@gmail.com" } +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent" +] +dependencies = [ + "numpy", + "pandas", + "requests", + "tqdm" +] + +[tool.setuptools.packages.find] +exclude = ["test", "test.*", "examples", "examples.*", "docs", "docs.*"] \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index d1b5fb5..0000000 --- a/setup.py +++ /dev/null @@ -1,26 +0,0 @@ -from setuptools import setup, find_packages - -with open("README.md", "r") as fh: - long_description = fh.read() - -setup( - name="tradingfeatures", - version="0.7.4", - author="Onur Cetinkol", - author_email="realiti44@gmail.com", - description="A useful tool to download market history from popular exchanges.", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/realiti4/tradingfeatures", - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - python_requires='>=3.6', - keywords="download market history binance bitfinex bitmex bitstamp", - packages=find_packages( - exclude=["test", "test.*", "examples", "examples.*", "docs", "docs.*"] - ), - install_requires=["numpy", "pandas", "requests", "tqdm"], -) diff --git a/tradingfeatures/uber.py b/tradingfeatures/uber.py index 5cd20c3..f867da9 100644 --- a/tradingfeatures/uber.py +++ b/tradingfeatures/uber.py @@ -28,9 +28,6 @@ def __init__( self.apis = [self.apis_dict.get(key) for key in api_to_use] - self.bitmex = bitmex() - # self.google_trends = google_trends() - self.columns = ( ["open", "low", "high", "close", "volume"] if columns is None else columns ) @@ -53,15 +50,16 @@ def eval_get(self, limit=1000, **kwargs): datasets = [[item[0], item[1].result()[-limit:]] for item in futures] - merged = self.get( - datasets=datasets, save=False, trends=False, date=False, **kwargs - ) + merged = self.get(datasets=datasets, save=False, date=False, **kwargs) # Fix for 0 and nan - check here again later merged = merged.replace(0, np.nan) if merged.isnull().values.any(): # Check here later merged = merged.interpolate() + # Remove preceding nan data + merged = merged.loc[merged.first_valid_index():] + return merged def get( @@ -69,7 +67,6 @@ def get( path="", datasets=None, merge=True, - trends=False, date=True, save=True, **kwargs, @@ -139,37 +136,22 @@ def get( if date: df_final["date"] = pd.to_datetime(df_final.index, unit="s", utc=True) - if trends: - df_trends = self.google_trends.update("uber_data") - df_final = df_final.join(df_trends) - - df_final["google_trends"].replace(0, np.nan, inplace=True) - df_final["google_trends"] = ( - df_final["google_trends"].astype(float).interpolate() - ) - if save: df_final.to_csv(path + "/merged_final.csv") return df_final def update(self, path="uber_data", **kwargs): # Fix path - working_directory = os.getcwd() datasets = [] for api in self.apis: path_df = path + f"/{api.name}.csv" - # df = pd.read_csv(path_df, index_col=0) - # datasets.append([api.name, df]) - # # break if os.path.exists(path_df): df = api.update(path_df) else: print(f"Couldn't find {api.name} data, downloading from strach..") raise Exception - # df = api.get_hist() - # df.to_csv(path_df) datasets.append([api.name, df])