172 lines
7.0 KiB
Python
172 lines
7.0 KiB
Python
"""
|
|
|
|
AUTHOR:
|
|
|
|
Khushal P Soonderji
|
|
|
|
DATE:
|
|
|
|
Saturday, 21st Dec., 2024
|
|
|
|
OBJECTIVE:
|
|
|
|
To handle all trading related behaviour from one place.
|
|
|
|
REFERENCES:
|
|
|
|
N/A
|
|
|
|
DOWNLOADS:
|
|
|
|
N/A
|
|
|
|
"""
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** IMPORT ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# To make sibling directories accessible for imports:
|
|
import sys
|
|
sys.path.append(".")
|
|
sys.path.append("..")
|
|
|
|
# My async utils:
|
|
from utils_v2.database.async_mongo_v2 import AsyncMongo
|
|
from utils_v2.cache.async_redis_cache_v2 import AsyncRedisCache
|
|
|
|
# Controllers:
|
|
from controllers_v2.core.auth_token import CoreAuthTokenController
|
|
|
|
# Models:
|
|
from models.core.auth_token import CoreAuthTokenModel
|
|
|
|
# To work with datatypes:
|
|
from typing import List, Any
|
|
|
|
# To make HTTP requests:
|
|
import httpx
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MACROS / ONE-TIME INIT ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** VARIABLES ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** FUNCTIONS ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** CLASSES ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
class TradingController(CoreAuthTokenController):
|
|
|
|
# ┏┓
|
|
# ┃ ┏┓┏┓┏╋┏┓┓┏┏╋┏┓┏┓
|
|
# ┗┛┗┛┛┗┛┗┛ ┗┻┗┗┗┛┛
|
|
|
|
def __init__(
|
|
self,
|
|
cache: AsyncRedisCache = None,
|
|
http_client: httpx.AsyncClient = None,
|
|
alert_url: str = None,
|
|
base_filter: dict = None,
|
|
debug: bool = True,
|
|
debug_prefix: str = "Trading (C) | ",
|
|
debug_only_errors: bool = True
|
|
):
|
|
|
|
"""
|
|
This is the foundational controller for all SMS services. This is built on top of the core message controller,
|
|
and, in turn, all individual SMS client controllers must be built on top of this.
|
|
:param cache: The object to use for caching results from database calls.
|
|
:param http_client: The HTTP client
|
|
:param base_filter: The basic filter that will be applied to all fetching/updating queries. WARNING: THE BASE
|
|
FILTER WILL ALWAYS BE APPLIED AUTOMATICALLY. SET THIS UP WISELY.
|
|
:param debug: Whether, or not, you would like to print debugging messages:
|
|
:param debug_prefix: The prefix to print with the debugging messages.
|
|
:param debug_only_errors: Whether you would like to print only error messages or all messages.
|
|
:return: None.
|
|
"""
|
|
|
|
# Prepare the combined base filter:
|
|
this_filter = {}
|
|
for k, v in (base_filter or {}).items(): this_filter[k] = v
|
|
this_filter["serviceType"] = "stockTrading"
|
|
|
|
# Invoke the parent's constructor:
|
|
CoreAuthTokenController.__init__(
|
|
self,
|
|
cache = cache,
|
|
alert_url = alert_url,
|
|
http_client = http_client,
|
|
base_filter = this_filter,
|
|
debug = debug,
|
|
debug_prefix = debug_prefix,
|
|
debug_only_errors = debug_only_errors
|
|
)
|
|
|
|
# ┏┓ ┓
|
|
# ┣┫┓┏╋┣┓
|
|
# ┛┗┗┻┗┛┗
|
|
|
|
# async def login_url(
|
|
# self,
|
|
# mongo_data_conn: AsyncMongo,
|
|
# auth_token: CoreAuthTokenModel
|
|
# ) -> SMSSendOneResult:
|
|
#
|
|
# """
|
|
# To send one SMS message through the third-party client.
|
|
# :param mongo_data_conn: The database connection to use to perform this task.
|
|
# :param auth_token: The auth token that will be used to send this message.
|
|
# :param client: The third-party SMS client to use to send this message.
|
|
# :param message: The actual message that needs to be sent.
|
|
# :param tags: Any tags to attach with this SMS for filtering when querying in the listing service.
|
|
# :return: The structured result of sending one message.
|
|
# """
|
|
#
|
|
# pass
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MAIN PROGRAM ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
pass
|