From 9e377ac6687bad121b7d40f71157a9bde94c7ebd Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 22:36:49 +0200 Subject: [PATCH 1/9] :bug: typo in docs --- docs/01_start.rst | 3 +++ docs/development/index.rst | 13 +++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/01_start.rst b/docs/01_start.rst index ebf04319f..617d6a9ac 100644 --- a/docs/01_start.rst +++ b/docs/01_start.rst @@ -15,9 +15,12 @@ Exchange Credentials ==================== Get your DEX or CEX credentials: + - DEX wallet address and private key: :doc:`talky:plugins/dex` + - CEX API Keys: :doc:`talky:plugins/cex` + Setup your config ================= diff --git a/docs/development/index.rst b/docs/development/index.rst index 1d498e113..c3431e736 100644 --- a/docs/development/index.rst +++ b/docs/development/index.rst @@ -1,11 +1,3 @@ -==================== -Build your own Plugin -===================== - - -You can fork this repo or you can use the current repo and add your own plugins - - ================= Community Plugins ================= @@ -14,9 +6,10 @@ Community Plugins :doc:`community:index` -Build Plugin -============ +Build Your Plugin +================ +Plugin example: .. literalinclude:: ../tt/plugins/default_plugins/example_plugin.py From 25f6d20a170a5385374ac15a6317e58c8f00eec9 Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 20:41:45 +0000 Subject: [PATCH 2/9] Update Requirements --- .requirements/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.requirements/requirements.txt b/.requirements/requirements.txt index 843e731b7..11dd60250 100644 --- a/.requirements/requirements.txt +++ b/.requirements/requirements.txt @@ -40,7 +40,7 @@ eth-typing==3.4.0 ; python_version >= "3.10" and python_version < "4" eth-utils==2.2.0 ; python_version >= "3.10" and python_version < "4" exceptiongroup==1.1.2 ; python_version >= "3.10" and python_version < "3.11" fastapi==0.101.0 ; python_version >= "3.10" and python_version < "4.0" -findmyorder==1.7.12 ; python_version >= "3.10" and python_version < "4.0" +findmyorder==1.7.13 ; python_version >= "3.10" and python_version < "4.0" frozendict==2.3.8 ; python_version >= "3.10" and python_version < "4.0" frozenlist==1.4.0 ; python_version >= "3.10" and python_version < "4.0" future==0.18.3 ; python_version >= "3.10" and python_version < "4.0" From ed80ac74ada5cffbfd31f42d7f192200e2768eed Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 23:01:43 +0200 Subject: [PATCH 3/9] :memo: improve documentation --- docs/03_module.rst | 38 +++----------------- docs/development/index.rst | 11 ++---- tt/bot.py | 16 +++++++-- tt/config.py | 8 +++-- tt/plugins/default_plugins/example_plugin.py | 2 +- tt/utils.py | 5 +-- 6 files changed, 30 insertions(+), 50 deletions(-) diff --git a/docs/03_module.rst b/docs/03_module.rst index ddf3b5511..853575d74 100644 --- a/docs/03_module.rst +++ b/docs/03_module.rst @@ -7,37 +7,6 @@ TalkyTrader :undoc-members: -API EndPoint -============ - -Talky Trader is an app built with FastAPI https://fastapi.tiangolo.com -It allows you to connect to a messaging chat platform to interact with -trading module. - -HealthCheck ------------ - -End point to know if the API is up and running - -.. autofunction::tt.bot.health_check - -Webhook -------- - -Webhook endpoint to send your trade generated via http://tradingview.com -or anyother platform you work with. -Endpoint is :file:`/webhook/{settings.webhook_secret}` so in trading view you can add: -https://talky.trader.com/webhook/123456 - -.. autofunction::tt.bot.webhook - -Startup -------- - -Starting the coroutine run_bot - -.. autofunction::tt.bot.start_bot_task - iamlistening ============ @@ -50,6 +19,7 @@ FindMyOrder :doc:`findmyorder:index` + Plugins ======= @@ -57,13 +27,13 @@ Plugins are the core of Talky Trader, they are loaded at startup and are used to interact with the trading platform. -.. automodule:: tt.plugins +.. automodule:: tt.plugins.plugin_manager :members: :undoc-members: -TalkyTrader Module Reference -===================== +TalkyTrader Module +================== .. autosummary:: :toctree: _autosummary diff --git a/docs/development/index.rst b/docs/development/index.rst index c3431e736..894e535f1 100644 --- a/docs/development/index.rst +++ b/docs/development/index.rst @@ -7,17 +7,12 @@ Community Plugins Build Your Plugin -================ +================= Plugin example: -.. literalinclude:: ../tt/plugins/default_plugins/example_plugin.py - - - -Use your Plugin -=============== +.. literalinclude:: ../tt/plugins/default_plugins/example_plugin.py + :linenos: -:doc:`community:index` diff --git a/tt/bot.py b/tt/bot.py index 6bcdcabe3..d0e442b24 100644 --- a/tt/bot.py +++ b/tt/bot.py @@ -1,7 +1,15 @@ """ TalkyTrader 🪙🗿 -==================== +================ + Bot Launcher and API +Talky Trader is an app +built with FastAPI +https://fastapi.tiangolo.com +It allows you to connect +to a messaging chat platform +to interact with trading module. + """ import asyncio @@ -36,7 +44,10 @@ async def root(): @app.get("/health") async def health_check(): - """ health check """ + """ + End point to know if + the API is up and running + """ return __version__ @@ -45,6 +56,7 @@ async def webhook(request: Request): """ Webhook endpoint to receive webhook requests with option to forward the data to another endpoint. + Webhook endpoint to send order signal generated via http://tradingview.com or anyother platform. Endpoint is :file:`/webhook/{settings.webhook_secret}` so in trading view you can add: https://YOURIPorDOMAIN/webhook/123456 """ data = await request.body() await send_notification(data) diff --git a/tt/config.py b/tt/config.py index 8a74aa899..088898f1c 100644 --- a/tt/config.py +++ b/tt/config.py @@ -1,7 +1,9 @@ """ - TalkyTrader Config - Used for Logging, Scheduleing and Settings +TalkyTrader Config +Used for Logging, +Scheduleing and Settings 🧐⏱️⚙️ + """ import logging @@ -13,7 +15,7 @@ from loguru import logger as loguru_logger ######################################## -### ⚙️ Settings ### +### ⚙️ Settings ### ######################################## ROOT = os.path.dirname(__file__) diff --git a/tt/plugins/default_plugins/example_plugin.py b/tt/plugins/default_plugins/example_plugin.py index 939af667a..84eebe835 100644 --- a/tt/plugins/default_plugins/example_plugin.py +++ b/tt/plugins/default_plugins/example_plugin.py @@ -7,7 +7,7 @@ #from myclass import MyClass - + class ExamplePlugin(BasePlugin): """Example Plugin Initialization of imported class MyClass diff --git a/tt/utils.py b/tt/utils.py index e0add671a..0e26e4128 100644 --- a/tt/utils.py +++ b/tt/utils.py @@ -35,7 +35,8 @@ async def send_notification(msg): async def run_bot(): """ - 🤖 Run the chat bot & the plugins. + 🤖 Run the chat bot & the plugins + via an asyncio loop. Returns: None @@ -55,7 +56,7 @@ async def start_plugins(plugin_manager): Returns: None - Refer to chat manager for the pl + Refer to chat manager for plugin info """ if settings.plugin_enabled: From 2f83a0b6471dc9407a64b5fba2c3168446c2c1d2 Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 23:13:50 +0200 Subject: [PATCH 4/9] :memo: improve documentation --- docs/01_start.rst | 1 - docs/02_config.rst | 7 +--- docs/plugins/helper.rst | 32 +-------------- tt/plugins/default_plugins/helper_plugin.py | 43 +++++++++++++++++---- 4 files changed, 40 insertions(+), 43 deletions(-) diff --git a/docs/01_start.rst b/docs/01_start.rst index 617d6a9ac..eadd26b8b 100644 --- a/docs/01_start.rst +++ b/docs/01_start.rst @@ -27,7 +27,6 @@ Setup your config Create your config file settings.toml or use env variables. Refer to :doc:`talky:02_config` for details. -example: .. literalinclude:: ../examples/example_settings.toml diff --git a/docs/02_config.rst b/docs/02_config.rst index b88090b5e..16d90cd74 100644 --- a/docs/02_config.rst +++ b/docs/02_config.rst @@ -26,8 +26,8 @@ Config will load: - user secrets: .secrets.toml Your settings should be setup in settings.toml, .secrets.toml, .env or environment variable. -Settings.toml or .env can be located in :file:`/app/settings.toml` or :file:`/app/.env` for docker. -If deployed locally, place your file in :file:`/tt/` folder. + Settings.toml or .env can be located in :file:`/app/settings.toml` or :file:`/app/.env` for docker. + If deployed locally, place your file in :file:`/tt/` folder. Talky Settings @@ -45,7 +45,6 @@ Settings Example Settings.toml ------------- -example: .. literalinclude:: ../examples/example_settings.toml :linenos: @@ -54,8 +53,6 @@ example: .env or ENV VARS ------------------ -place the .env at - .. literalinclude:: ../examples/example.env :linenos: diff --git a/docs/plugins/helper.rst b/docs/plugins/helper.rst index da4c7f2c5..a87019398 100644 --- a/docs/plugins/helper.rst +++ b/docs/plugins/helper.rst @@ -2,37 +2,9 @@ helper ===== -Provide multiple function such as giving the list of -available command, network ping or restarting the bot - -Function -===== - -Help ----- - -:file:`/help` command to return the list of available command - -Trading Switch --------------- - -:file:`/trading` command to turn off or on the trading capability - -Network -------- - -:file:`/network` command to retrieve the network ping latency and IP of the bot - -Restart --------- - -:file:`/restart` command to restart the bot - - -Module Reference -================ .. automodule:: tt.plugins.default_plugins.helper_plugin :members: :undoc-members: - \ No newline at end of file + + diff --git a/tt/plugins/default_plugins/helper_plugin.py b/tt/plugins/default_plugins/helper_plugin.py index ced752838..2fa5f051a 100644 --- a/tt/plugins/default_plugins/helper_plugin.py +++ b/tt/plugins/default_plugins/helper_plugin.py @@ -10,7 +10,14 @@ class HelperPlugin(BasePlugin): - """ Helper Plugin """ + """ + Helper Plugin + Provide multiple function + such as giving the list of + available command, network ping + or restarting the bot + + """ name = os.path.splitext(os.path.basename(__file__))[0] def __init__(self): super().__init__() @@ -53,31 +60,53 @@ async def handle_message(self, msg): await self.send_notification(f"{await function()}") async def get_helper_help(self): - """Help Message""" + """ + Help Message + :file:`/help` command to + return the list of + available command + """ return f"{self.help_message}" async def get_helper_info(self): - """Help Message""" + """ + return + TalkyTrader version + """ return self.version async def get_helper_network(self): - """Help Message""" + """ + :file:`/network` command to retrieve the network + ping latency and + the bot IP address + """ ping_result = ping3.ping(settings.ping, unit='ms') ping_result = round(ping_result, 2) if ping_result is not None else 0 return (f"️{self.host_ip}\n" f"🏓 {ping_result}\n") async def trading_switch_command(self): - """Trading switch command""" + """ + Trading switch command + :file:`/trading` command + to turn off or on the + trading capability + """ settings.trading_enabled = not settings.trading_enabled return f"Trading is {'enabled' if settings.trading_enabled else 'disabled'}." async def restart(self): - """Restart Bot """ + """ + :file:`/restart` command + to restart the bot + """ os.execl(sys.executable, os.path.abspath(__file__), sys.argv[0]) def get_host_ip(self): - """Returns host IP """ + """ + Returns bot IP + """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect((settings.ping, 80)) ip_address = s.getsockname()[0] From ba3abdf7f8f8ba3300d92055437b97a7b1e95947 Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 23:17:30 +0200 Subject: [PATCH 5/9] :memo: improve documentation --- docs/development/index.rst | 6 +----- tt/bot.py | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/development/index.rst b/docs/development/index.rst index 894e535f1..5f097f19a 100644 --- a/docs/development/index.rst +++ b/docs/development/index.rst @@ -2,17 +2,13 @@ Community Plugins ================= - :doc:`community:index` - Build Your Plugin ================= Plugin example: - -.. literalinclude:: ../tt/plugins/default_plugins/example_plugin.py +.. literalinclude:: ../../tt/plugins/default_plugins/example_plugin.py :linenos: - diff --git a/tt/bot.py b/tt/bot.py index d0e442b24..f1b673dec 100644 --- a/tt/bot.py +++ b/tt/bot.py @@ -3,9 +3,11 @@ ================ Bot Launcher and API + Talky Trader is an app built with FastAPI https://fastapi.tiangolo.com + It allows you to connect to a messaging chat platform to interact with trading module. From 43c75c1303777c69463a0b98bec28db6174bb9e9 Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 23:36:15 +0200 Subject: [PATCH 6/9] :memo: improve documentation --- docs/03_module.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/03_module.rst b/docs/03_module.rst index 853575d74..e6c4ea4ed 100644 --- a/docs/03_module.rst +++ b/docs/03_module.rst @@ -5,7 +5,6 @@ TalkyTrader .. automodule:: tt.bot :members: :undoc-members: - iamlistening @@ -13,12 +12,19 @@ iamlistening :doc:`iamlistening:index` +.. automodule:: iamlistening.main + :members: + :undoc-members: FindMyOrder =========== :doc:`findmyorder:index` +.. autoclass:: findmyorder.main.FindMyOrder + :members: + :undoc-members: + Plugins ======= @@ -42,5 +48,6 @@ TalkyTrader Module tt - + + From e0e61014b420cb5b5bc777def9a60b31e1a42422 Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 23:43:38 +0200 Subject: [PATCH 7/9] :memo: improve documentation --- docs/03_module.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/03_module.rst b/docs/03_module.rst index e6c4ea4ed..f1793fdfb 100644 --- a/docs/03_module.rst +++ b/docs/03_module.rst @@ -12,7 +12,7 @@ iamlistening :doc:`iamlistening:index` -.. automodule:: iamlistening.main +.. autoclass:: iamlistening.main.Listener :members: :undoc-members: @@ -41,6 +41,7 @@ are used to interact with the trading platform. TalkyTrader Module ================== + .. autosummary:: :toctree: _autosummary :template: custom-module-template.rst @@ -48,6 +49,7 @@ TalkyTrader Module tt + From 8b9b680eef4b2f533d7c97c8ef06cffa25cabb5b Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 23:46:34 +0200 Subject: [PATCH 8/9] :rotating_light:linter --- tt/bot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tt/bot.py b/tt/bot.py index f1b673dec..bc9550680 100644 --- a/tt/bot.py +++ b/tt/bot.py @@ -58,7 +58,14 @@ async def webhook(request: Request): """ Webhook endpoint to receive webhook requests with option to forward the data to another endpoint. - Webhook endpoint to send order signal generated via http://tradingview.com or anyother platform. Endpoint is :file:`/webhook/{settings.webhook_secret}` so in trading view you can add: https://YOURIPorDOMAIN/webhook/123456 + Webhook endpoint to + send order signal generated + via http://tradingview.com + or anyother platform. + Endpoint is + :file:`/webhook/{settings.webhook_secret}` + so in trading view you can add: + https://YOURIPorDOMAIN/webhook/123456 """ data = await request.body() await send_notification(data) From 99ab038929cbf5b059c135152f6cf2c66a9aca75 Mon Sep 17 00:00:00 2001 From: mraniki Date: Tue, 8 Aug 2023 21:49:18 +0000 Subject: [PATCH 9/9] Update Requirements --- .requirements/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.requirements/requirements.txt b/.requirements/requirements.txt index 11dd60250..79b281f32 100644 --- a/.requirements/requirements.txt +++ b/.requirements/requirements.txt @@ -111,7 +111,7 @@ pyunormalize==15.0.0 ; python_version >= "3.10" and python_version < "4.0" pywin32==306 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" pyyaml==6.0.1 ; python_version >= "3.10" and python_version < "4.0" referencing==0.30.2 ; python_version >= "3.10" and python_version < "4.0" -regex==2023.6.3 ; python_version >= "3.10" and python_version < "4" +regex==2023.8.8 ; python_version >= "3.10" and python_version < "4" requests-oauthlib==1.3.1 ; python_version >= "3.10" and python_version < "4.0" requests==2.31.0 ; python_version >= "3.10" and python_version < "4.0" revolt-py==0.1.11 ; python_version >= "3.10" and python_version < "4.0"