Skip to content

Commit

Permalink
Merge pull request #640 from mraniki/dev
Browse files Browse the repository at this point in the history
📝 updated docstring /documentations
  • Loading branch information
mraniki authored Aug 7, 2023
2 parents e55aa9d + fb06f6c commit f833732
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 33 deletions.
15 changes: 9 additions & 6 deletions .requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cryptography==41.0.3 ; python_version >= "3.10" and python_version < "4.0"
curl-cffi==0.5.7 ; python_version >= "3.10" and python_version < "4.0"
cytoolz==0.12.2 ; python_version >= "3.10" and python_version < "4" and implementation_name == "cpython"
decorator==5.1.1 ; python_version >= "3.10" and python_version < "4.0"
dxsp==4.2.6 ; python_version >= "3.10" and python_version < "4.0"
dxsp==4.2.10 ; python_version >= "3.10" and python_version < "4.0"
dynaconf==3.2.0 ; python_version >= "3.10" and python_version < "4.0"
emoji==2.7.0 ; python_version >= "3.10" and python_version < "4.0"
eth-abi==4.1.0 ; python_version >= "3.10" and python_version < "4"
Expand All @@ -40,11 +40,11 @@ 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.8 ; python_version >= "3.10" and python_version < "4.0"
findmyorder==1.7.11 ; 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"
g4f==0.0.1.3 ; python_version >= "3.10" and python_version < "4.0"
g4f==0.0.1.4 ; python_version >= "3.10" and python_version < "4.0"
greenlet==2.0.2 ; python_version >= "3.10" and python_version < "4.0"
grpcio==1.56.2 ; python_version >= "3.10" and python_version < "4.0"
guilded-py==1.10.0 ; python_version >= "3.10" and python_version < "4.0"
Expand All @@ -56,9 +56,10 @@ html5lib==1.1 ; python_version >= "3.10" and python_version < "4.0"
httpcore==0.17.3 ; python_version >= "3.10" and python_version < "4.0"
httpx==0.24.1 ; python_version >= "3.10" and python_version < "4.0"
hyperframe==6.0.1 ; python_version >= "3.10" and python_version < "4.0"
iamlistening==3.1.4 ; python_version >= "3.10" and python_version < "4.0"
iamlistening==3.2.0 ; python_version >= "3.10" and python_version < "4.0"
idna==3.4 ; python_version >= "3.10" and python_version < "4.0"
jeepney==0.8.0 ; python_version >= "3.10" and (sys_platform == "bsd" or sys_platform == "linux") and python_version < "4.0"
js2py==0.74 ; python_version >= "3.10" and python_version < "4.0"
jsonschema-specifications==2023.7.1 ; python_version >= "3.10" and python_version < "4.0"
jsonschema==4.19.0 ; python_version >= "3.10" and python_version < "4.0"
logbook==1.6.0 ; python_version >= "3.10" and python_version < "4.0"
Expand All @@ -71,7 +72,7 @@ mastodon-py==1.8.1 ; python_version >= "3.10" and python_version < "4.0"
matrix-nio==0.20.2 ; python_version >= "3.10" and python_version < "4.0"
multidict==6.0.4 ; python_version >= "3.10" and python_version < "4.0"
multitasking==0.0.11 ; python_version >= "3.10" and python_version < "4.0"
myllm==1.1.0 ; python_version >= "3.10" and python_version < "4.0"
myllm==1.2.8 ; python_version >= "3.10" and python_version < "4.0"
numpy==1.25.2 ; python_version >= "3.10" and python_version < "4.0"
oauthlib==3.2.2 ; python_version >= "3.10" and python_version < "4.0"
packaging==23.1 ; python_version >= "3.10" and python_version < "4.0"
Expand All @@ -94,13 +95,15 @@ pydantic-core==2.4.0 ; python_version >= "3.10" and python_version < "4.0"
pydantic==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
pyee==9.0.4 ; python_version >= "3.10" and python_version < "4.0"
pyexecjs==1.5.1 ; python_version >= "3.10" and python_version < "4.0"
pyjsparser==2.7.1 ; python_version >= "3.10" and python_version < "4.0"
pyparsing==3.1.1 ; python_version >= "3.10" and python_version < "4.0"
python-cryptography-fernet-wrapper==1.0.4 ; python_version >= "3.10" and python_version < "4.0"
python-dateutil==2.8.2 ; python_version >= "3.10" and python_version < "4.0"
python-dotenv==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
python-magic-bin==0.4.14 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
python-magic==0.4.27 ; python_version >= "3.10" and python_version < "4.0" and platform_system != "Windows"
python-socks[asyncio]==2.3.0 ; python_version >= "3.10" and python_version < "4.0"
pythorhead==0.15.4 ; python_version >= "3.10" and python_version < "3.12"
pytz-deprecation-shim==0.1.0.post0 ; python_version >= "3.10" and python_version < "4.0"
pytz==2023.3 ; python_version >= "3.10" and python_version < "4.0"
pyunormalize==15.0.0 ; python_version >= "3.10" and python_version < "4.0"
Expand All @@ -121,7 +124,7 @@ six==1.16.0 ; python_version >= "3.10" and python_version < "4.0"
sniffio==1.3.0 ; python_version >= "3.10" and python_version < "4.0"
soupsieve==2.4.1 ; python_version >= "3.10" and python_version < "4.0"
starlette==0.27.0 ; python_version >= "3.10" and python_version < "4.0"
talkytrend==1.12.10 ; python_version >= "3.10" and python_version < "4.0"
talkytrend==1.12.11 ; python_version >= "3.10" and python_version < "4.0"
telethon==1.29.2 ; python_version >= "3.10" and python_version < "4.0"
tinode-grpc==0.22.3 ; python_version >= "3.10" and python_version < "4.0"
toml==0.10.2 ; python_version >= "3.10" and python_version < "4.0"
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ fastapi = "^0.101.0"
ping3 = "^4.0.4"
playwright = "^1.36.0"
ccxt = "^4.0.0"
dxsp = "^4.2.3"
findmyorder = "^1.6.1"
iamlistening = "^3.1.0"
talkytrend = "^1.12.3"
myllm = "^1.0.0"
dxsp = "^4.2.10"
findmyorder = "^1.7.11"
iamlistening = "^3.2.0"
talkytrend = "^1.12.11"
myllm = "^1.2.8"


[tool.poetry.group.dev.dependencies]
Expand Down
5 changes: 5 additions & 0 deletions tt/plugins/default_plugins/ __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Plugins location
"""

119 changes: 108 additions & 11 deletions tt/plugins/default_plugins/cex_exchange_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@


class CexExchangePlugin(BasePlugin):
"""CEX Plugin"""
"""
Class CexExchangePlugin to support CEX Exchange
Args:
None
Returns:
None
"""
name = os.path.splitext(os.path.basename(__file__))[0]
def __init__(self):
super().__init__()
Expand All @@ -34,7 +43,17 @@ def should_handle(self, message):
return self.enabled

async def handle_message(self, msg):
"""Handles incoming messages"""
"""
Handles incoming messages
to route to the respective function
Args:
msg (str): The incoming message
Returns:
None
"""
if not self.enabled:
return

Expand Down Expand Up @@ -69,7 +88,18 @@ async def handle_message(self, msg):


class CexExchange():
"""CEX Object"""
"""
CEX Object to support CEX
via CCXT library to be reviewed
to be stored in different file/package
Args:
None
Returns:
None
"""
def __init__(self):
if settings.cex_name:
client = getattr(ccxt, settings.cex_name)
Expand All @@ -86,25 +116,61 @@ def __init__(self):
self.commands = settings.ccxt_commands

async def get_info(self):
"""info_message"""
"""
info_message
"""
exchange_name = self.cex.id
account_info = self.cex.uid
#account_info = self.cex.fetchAccounts().get('main')
# account_info = self.cex.fetchAccounts().get('main')
# method not implemented yet
return f"💱 {exchange_name}\n🪪 {account_info}"

async def get_help(self):
"""
Get the help information for the current instance.
Returns:
A string containing the available commands.
"""
return (f"{self.commands}\n")

async def get_quote(self, symbol):
"""return main asset balance."""
"""
return main asset balance.
Args:
symbol
Returns:
quote
"""

return f"🏦 {self.cex.fetchTicker(symbol).get('last')}"

async def get_trading_asset_balance(self):
"""return main asset balance."""
"""
return main asset balance.
Args:
None
Returns:
balance
"""
return self.cex.fetchBalance()[f"{settings.trading_asset}"]["free"]

async def get_account_balance(self):
"""return account balance."""
"""
return account balance.
Args:
None
Returns:
balance
"""
raw_balance = self.cex.fetch_free_balance()
filtered_balance = {k: v for k, v in
raw_balance.items()
Expand All @@ -118,19 +184,50 @@ async def get_account_balance(self):
return balance

async def get_account_position(self):
"""return account position."""
"""
return account position.
Args:
None
Returns:
position
"""
open_positions = self.cex.fetch_positions()
open_positions = [p for p in open_positions if p['type'] == 'open']
position = "📊 Position\n" + str(open_positions)
position += str(await self.cex.fetch_balance({'type': 'margin',}))
return position

async def get_account_pnl(self):
"""return account pnl."""
"""
return account pnl.
Args:
None
Returns:
pnl
"""

return 0

async def execute_order(self, order_params):
"""Execute order."""
"""
Execute order
Args:
order_params (dict):
action(str)
instrument(str)
quantity(int)
Returns:
trade_confirmation(dict)
"""

action = order_params.get('action')
instrument = order_params.get('instrument')
quantity = order_params.get('quantity', settings.trading_risk_amount)
Expand Down
Loading

0 comments on commit f833732

Please sign in to comment.