diff --git a/.requirements/requirements.txt b/.requirements/requirements.txt index 843e731b7..79b281f32 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" @@ -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" diff --git a/docs/01_start.rst b/docs/01_start.rst index ebf04319f..eadd26b8b 100644 --- a/docs/01_start.rst +++ b/docs/01_start.rst @@ -15,16 +15,18 @@ 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 ================= 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/03_module.rst b/docs/03_module.rst index ddf3b5511..f1793fdfb 100644 --- a/docs/03_module.rst +++ b/docs/03_module.rst @@ -5,38 +5,6 @@ TalkyTrader .. automodule:: tt.bot :members: :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 @@ -44,12 +12,20 @@ iamlistening :doc:`iamlistening:index` +.. autoclass:: iamlistening.main.Listener + :members: + :undoc-members: FindMyOrder =========== :doc:`findmyorder:index` +.. autoclass:: findmyorder.main.FindMyOrder + :members: + :undoc-members: + + Plugins ======= @@ -57,13 +33,14 @@ 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 @@ -72,5 +49,7 @@ TalkyTrader Module Reference tt - + + + diff --git a/docs/development/index.rst b/docs/development/index.rst index 1d498e113..5f097f19a 100644 --- a/docs/development/index.rst +++ b/docs/development/index.rst @@ -1,30 +1,14 @@ -==================== -Build your own Plugin -===================== - - -You can fork this repo or you can use the current repo and add your own plugins - - ================= Community Plugins ================= - :doc:`community:index` +Build Your Plugin +================= -Build Plugin -============ - - -.. literalinclude:: ../tt/plugins/default_plugins/example_plugin.py - - - -Use your Plugin -=============== - +Plugin example: -:doc:`community:index` +.. literalinclude:: ../../tt/plugins/default_plugins/example_plugin.py + :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/bot.py b/tt/bot.py index 6bcdcabe3..bc9550680 100644 --- a/tt/bot.py +++ b/tt/bot.py @@ -1,7 +1,17 @@ """ 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 +46,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 +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 """ 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/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] diff --git a/tt/utils.py b/tt/utils.py index 65eee4683..64c828bf9 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: