🗿 TalkyTrader#
TalkyTrader 🪙🗿#
Bot Launcher and API
Talky Trader is an app built with FastAPI tiangolo/fastapi
It allows you to connect to a messaging chat platform to interact with trading module.
- tt.app.lifespan(app)[source]#
An asynchronous context manager that manages the lifespan of the application.
Parameters: - app: The application to manage the lifespan of.
Returns: - None
This function creates an event loop, starts a task to run the bot, and yields control to the caller. The caller is responsible for cleaning up any resources after the lifespan of the application has ended.
- async tt.app.root(request: Request)[source]#
Get the root endpoint.
- Returns:
The HTML response
- Return type:
HTMLResponse
Note
If settings.ui_enabled is True, user will be redirected to the UI frontend
- async tt.app.webhook(request: Request)[source]#
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
/webhook/settings.webhook_secretso in trading view you can add: https://YOURIPorDOMAIN/webhook/123456
Plugins#
- class tt.plugins.plugin_manager.PluginManager(plugin_directory=None)[source]#
🔌 Plugins are the core of Talky Trader, they are loaded at startup, to interact with the trading platform.
Plugin Manager is used to load, start and dispatch message to the plugins
- Parameters:
plugin_directory (str) – Directory
plugins (of)
- Returns:
None
- load_plugins(plugin_names=None)[source]#
🔌Load plugins from directory
- Parameters:
plugin_names (list) – List of plugin names to load
None (if)
self.plugin_directory (load all plugins from)
time (You can use this to minimize the load)
CPU. (memory and)
- Returns:
None
- Raises:
Exception – If there was an error loading a plugin
- load_plugin(module, plugin_name)[source]#
Load a plugin from a module
- Parameters:
module (Module) – Module
plugin_name (str) – Plugin name
- Returns:
None
- class tt.plugins.plugin_manager.BasePlugin[source]#
⚡ Base Plugin Class This class is inherited by Talky Plugins for the scheduling, notification and message handling.
Scheduling is manage via asyncz lib More info: tarsil/asyncz
- Parameters:
None
- Returns:
None
- should_filter(message)[source]#
Returns True if the plugin should NOT handle the message if plugin is not enabled and if ignore characters are in the message via bot_ignore
- Parameters:
message (str) – Message
- Returns:
bool
- should_filter_in(message)[source]#
Returns True if the given word is found in the message :param message: Message :type message: str :param word: Word to search for :type word: str
- Returns:
bool
- should_handle(message)[source]#
Determines if the plugin should handle the message based on certain conditions.
- Parameters:
message (str) – The message
checked. (to be)
- Returns:
True if the plugin should handle the message, False otherwise.
- Return type:
bool
- is_command_to_handle(message)[source]#
Determines if the plugin should handle the message based on certain conditions.
- Parameters:
message (str) – The message to be checked.
- Returns:
True if the plugin should handle the message, False otherwise.
- Return type:
bool
- async plugin_notify_schedule_task(user_name=None, frequency=8, frequency_unit='hours', function=None)[source]#
Handles task notification every X hours. Defaulted to 8 hours
- Parameters:
user_name (str) – User name
frequency (int) – Frequency
frequency_unit (str) – Frequency unit
function (function) – Function
- Returns:
None
- async plugin_notify_cron_task(user_name=None, user_day_of_week=None, user_hours=None, user_timezone=None, function=None)[source]#
Handles task cron scheduling for notification default set to Tuesday to Thursday at 6AM, 12PM and 6PM UTC via settings
- Parameters:
user_name (str) – User name
user_day_of_week (str) – Day of week
user_hours (str) – Hours
user_timezone (str) – Timezone
function (function) – Function
- Returns:
None
Utils#
UI#
- tt.frontend.main.init(fastapi_app: FastAPI) None[source]#
Frontend component activated via settings.ui_enabled = True and using zauberzeug/nicegui
Initializes the UI for the provided fastapi_app instance.
- Parameters:
fastapi_app (FastAPI) – The FastAPI application instance to be initialized.
- Returns:
None
Note
This function defines a nested function show which is decorated with @ui.page(“/show”, dark=True). The show function displays a label and a video using the ui.label and ui.video functions respectively. It also includes an HTML content that embeds a TradingView widget. The ui.html function is used to display the HTML content.
Finally, the ui.run_with function is called to run the FastAPI application with the provided fastapi_app instance.