From 4e7dd924ddb663e691458118982bc67b22203ed9 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 10 May 2020 14:47:18 +0700 Subject: [PATCH] Move to package --- setup.py | 21 +++++++++++++++++++++ tradingview_ta/__init__.py | 1 + tradingview_ta.py => tradingview_ta/main.py | 20 -------------------- 3 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 setup.py create mode 100644 tradingview_ta/__init__.py rename tradingview_ta.py => tradingview_ta/main.py (90%) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..17c92f5 --- /dev/null +++ b/setup.py @@ -0,0 +1,21 @@ +import setuptools + +with open("README.md", "r") as fh: + long_description = fh.read() + +setuptools.setup( + name='tradingview_ta', + version='2.0.0', + description="A python module to scrape tradingview's technical analysis.", + long_description=long_description, + long_description_content_type="text/markdown", + url='https://github.com/deathlyface/python-tradingview-ta', + author='deathlyface', + author_email='bri4nong@gmail.com', + packages=['tradingview_ta'], + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], + python_requires='>=3.6') diff --git a/tradingview_ta/__init__.py b/tradingview_ta/__init__.py new file mode 100644 index 0000000..653a0ca --- /dev/null +++ b/tradingview_ta/__init__.py @@ -0,0 +1 @@ +from .main import ta_handler diff --git a/tradingview_ta.py b/tradingview_ta/main.py similarity index 90% rename from tradingview_ta.py rename to tradingview_ta/main.py index ed2e1df..3cef859 100644 --- a/tradingview_ta.py +++ b/tradingview_ta/main.py @@ -8,14 +8,12 @@ class ta_handler: """ ta_handler class Create an instance of this class to get TradingView's technical analysis. - Values: pair (string): Pair name, not case-sensitive (ex: "btcusd"). interval (string): Interval rate, not case-sensitive (default: "1m" for 1 minute). str_driver (string): Webdriver name, not case-sensitive (default: "chrome"). headless (bool): Use headless browser for chrome and firefox (default: True). last_analysis (list): return the last analysis. - Functions: start_driver(): Start the webdriver. get_analysis(): Return a list of analysis. @@ -31,7 +29,6 @@ class ta_handler: #Set webdriver def start_driver(self): """ start_driver Function - This function will set up a webdriver. Returns: @@ -70,7 +67,6 @@ def start_driver(self): #Get analysis def get_analysis(self): """ get_analysis Function - This function will return a list containing recommendation (buy/sell) and counters (number of analysis of sell, neutral, and buy). Returns: @@ -110,19 +106,3 @@ def get_analysis(self): self.last_analysis = analysis return analysis - - -if __name__ == "__main__": - btcusd = ta_handler() - - btcusd.pair = "btcusd" - btcusd.interval = "1m" - btcusd.driver = "chrome" - btcusd.headless = True - - btcusd.start_driver() - analysis = btcusd.get_analysis() - print("Recommendation: {}".format(analysis[0])) - print("Sell: {}".format(analysis[1])) - print("Neutral: {}".format(analysis[2])) - print("Buy: {}".format(analysis[3]))