Skip to content

Commit

Permalink
Merge pull request #642 from mraniki/dev
Browse files Browse the repository at this point in the history
📝 ⬆️ Docs and Requirements Update
  • Loading branch information
mraniki authored Aug 8, 2023
2 parents aa38a63 + 8581b46 commit 11c88a7
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 121 deletions.
12 changes: 7 additions & 5 deletions .requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ beautifulsoup4==4.12.2 ; python_version >= "3.10" and python_version < "4.0"
bitarray==2.8.1 ; python_version >= "3.10" and python_version < "4"
blurhash==1.1.4 ; python_version >= "3.10" and python_version < "4.0"
browser-cookie3==0.19.1 ; python_version >= "3.10" and python_version < "4.0"
ccxt==4.0.52 ; python_version >= "3.10" and python_version < "4.0"
ccxt==4.0.54 ; python_version >= "3.10" and python_version < "4.0"
certifi==2023.7.22 ; python_version >= "3.10" and python_version < "4.0"
cffi==1.15.1 ; python_version >= "3.10" and python_version < "4.0"
charset-normalizer==3.2.0 ; python_version >= "3.10" and python_version < "4.0"
Expand All @@ -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.10 ; python_version >= "3.10" and python_version < "4.0"
dxsp==4.2.11 ; 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,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.11 ; python_version >= "3.10" and python_version < "4.0"
findmyorder==1.7.12 ; 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"
Expand All @@ -56,8 +56,9 @@ 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.2.0 ; python_version >= "3.10" and python_version < "4.0"
iamlistening==3.3.2 ; python_version >= "3.10" and python_version < "4.0"
idna==3.4 ; python_version >= "3.10" and python_version < "4.0"
iso8601==2.0.0 ; 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"
Expand Down Expand Up @@ -124,12 +125,13 @@ 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.11 ; python_version >= "3.10" and python_version < "4.0"
talkytrend==1.13.0 ; 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"
toolz==0.12.0 ; python_version >= "3.10" and python_version < "4" and (implementation_name == "pypy" or implementation_name == "cpython")
tradingview-ta==3.3.0 ; python_version >= "3.10" and python_version < "4.0"
twitchio==2.6.0 ; python_version >= "3.10" and python_version < "4.0"
typing-extensions==4.7.1 ; python_version >= "3.10" and python_version < "4.0"
tzdata==2023.3 ; python_version >= "3.10" and python_version < "4.0"
tzlocal==4.3.1 ; python_version >= "3.10" and python_version < "4.0"
Expand Down
16 changes: 11 additions & 5 deletions docs/03_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
TalkyTrader
===========

.. automodule:: tt.bot
:members:
:undoc-members:


API EndPoint
============

Expand Down Expand Up @@ -52,11 +57,9 @@ Plugins are the core of Talky Trader, they are loaded at startup and
are used to interact with the trading platform.


.. toctree::
:maxdepth: 2

plugins

.. automodule:: tt.plugins
:members:
:undoc-members:


TalkyTrader Module Reference
Expand All @@ -68,3 +71,6 @@ TalkyTrader Module Reference
:recursive:

tt



6 changes: 5 additions & 1 deletion docs/plugins/cex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ CEX
User Guide
==========
- Retrieve your CEX API Keys
- Refer to https://docs.ccxt.com for the supported exchange


Module Reference
================

.. automodule::tt.plugins.default_plugins.cex_exchange_plugin
.. automodule:: tt.plugins.default_plugins.cex_exchange_plugin
:members:
:undoc-members:

11 changes: 4 additions & 7 deletions docs/plugins/helper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ helper
Provide multiple function such as giving the list of
available command, network ping or restarting the bot

.. toctree::
:maxdepth: 2

plugins/helper


Function
=====

Expand Down Expand Up @@ -38,4 +32,7 @@ Restart
Module Reference
================

.. automodule::tt.plugins.default_plugins.helper_plugin
.. automodule:: tt.plugins.default_plugins.helper_plugin
:members:
:undoc-members:

42 changes: 21 additions & 21 deletions examples/example_settings.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
########################################
### EXAMPLE SETTINGS ###
### EXAMPLE SETTINGS ###
#######################################


# DISCORD BOT on ethereum chain using
# uniswap v2 router

# bot_token = '1212121212121'
# bot_channel_id = '121212121212'
# apprise_url = 'discord://1212121212121/121212121212'
# dex_wallet_address = '0x1234567890123456789012345678901234567890'
# dex_private_key = '0xdeadbeef'
# dex_block_explorer_api = '42342342342'
# bot_token = '12122121'
# bot_channel_id = '1221212'
# apprise_url = 'discord://12121/121212'
# dex_wallet_address = '0x123458901234567890'
# dex_private_key = '0xdeadbeef'
# dex_block_explorer_api = '42342342342'

# TELEGRAM BOT on CEX Binance
# bot_token = '1212121212121'
# bot_channel_id = '-112121212121'
# bot_api_id = '1212121212912'
# bot_api_hash = '121212121212121'
# apprise_url = 'tgram://1212121212121/-112121212121'
# bot_token = '121212121'
# bot_channel_id = '-1122121'
# bot_api_id = '1212912'
# bot_api_hash = '121212121'
# apprise_url = 'tgram://121221/-11211212121'
# cex_name = 'binance'
# cex_api = 'abcabcabcabcabcabc'
# cex_secret = 'abcabcabcabcabcabc'
# cex_api = 'abcabccabc'
# cex_secret = 'abcacabcabc'

#DISCORD BOT on BSC chain using pancakeswap v2 router and custom plugin setup
# bot_token = '1212121212121'
# bot_channel_id = '121212121212'
# apprise_url = 'discord://1212121212121/121212121212'
# dex_wallet_address = '0x1234567890123456789012345678901234567890'
# apprise_url = 'discord://121121/1212212'
# dex_wallet_address = '0x123467890'
# dex_private_key = '0xdeadbeef'
# dex_router_contract_addr = "0x10ED43C718714eb63d5aA57B78B54704E256024E"
# dex_factory_contract_addr = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"
# dex_block_explorer_url = 'https://api.bscscan.com/api'
# dex_block_explorer_api = '42342342342'
# dex_block_explorer_api = '423442'
# trading_asset_address = "0xe9e7cea3dedca5984780bafc599bd69add087d56"
# action_identifier = "PUMP DUMP"
# mapping = [
Expand All @@ -41,13 +41,13 @@
# live_tv_url ='https://reuters-reutersnow-1.plex.wurl.com/manifest/playlist.m3u8'

#MATRIX BOT on Polygon chain using zerox protocol
# bot_token = '1212121212121'
# bot_channel_id = '121212121212'
# bot_token = '12122121'
# bot_channel_id = '12121212'
# bot_hostname='matrix.org'
# bot_user='itsme'
# bot_pass='mario'
# apprise_url = 'discord://1212121212121/121212121212'
# dex_wallet_address = '0x1234567890123456789012345678901234567890'
# apprise_url = 'discord://1212121/1211212'
# dex_wallet_address = '0x12345678901234567890'
# dex_private_key = '0xdeadbeef'
# dex_protocol_type = "0x"
# dex_rpc = "https://rpc.ankr.com/polygon"
Expand Down
42 changes: 15 additions & 27 deletions tests/test_dex_exchange_plugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@

from unittest.mock import AsyncMock

import iamlistening
import pytest
from dxsp import DexSwap
from findmyorder import FindMyOrder
from iamlistening import Listener

from tt.config import settings
from tt.plugins.default_plugins.dex_exchange_plugin import DexExchangePlugin
Expand All @@ -21,6 +18,7 @@ def order():
"""return valid order"""
return "buy WBTC sl=200 tp=400 q=1%"


@pytest.fixture(name="plugin")
def test_fixture_plugin():
return DexExchangePlugin()
Expand All @@ -29,17 +27,6 @@ def test_fixture_plugin():
def test_dynaconf_is_in_testing_env_DEX56():
print(settings.VALUE)
assert settings.VALUE == "On Testing DEX_56"
assert settings.cex_name == ""
assert settings.dex_wallet_address == "0x1234567890123456789012345678901234567899"


# @pytest.mark.asyncio
# async def test_listener_discord():
# print(settings.VALUE)
# listener_test = Listener()
# print(listener_test)
# assert listener_test is not None
# assert isinstance(listener_test, iamlistening.main.Listener)


@pytest.mark.asyncio
Expand Down Expand Up @@ -68,46 +55,47 @@ async def test_parse_valid_order(plugin, order_message):

@pytest.mark.asyncio
async def test_parse_quote(plugin, caplog):
"""Test parse_message balance """
"""Test parse_message balance"""
plugin.exchange.get_quote = AsyncMock()
await plugin.handle_message('/q WBTC')
plugin.exchange.get_quote.assert_awaited_once_with('WBTC')
await plugin.handle_message("/q WBTC")
plugin.exchange.get_quote.assert_awaited_once_with("WBTC")


@pytest.mark.asyncio
async def test_parse_balance(plugin):
"""Test balance """
"""Test balance"""
plugin.exchange.get_account_balance = AsyncMock()
await plugin.handle_message('/bal')
await plugin.handle_message("/bal")
plugin.exchange.get_account_balance.assert_awaited_once()


@pytest.mark.asyncio
async def test_parse_position(plugin):
"""Test position """
"""Test position"""
plugin.exchange.get_account_position = AsyncMock()
await plugin.handle_message('/pos')
await plugin.handle_message("/pos")
plugin.exchange.get_account_position.assert_awaited_once()


@pytest.mark.asyncio
async def test_parse_pnl(plugin):
"""Test balance """
"""Test balance"""
plugin.exchange.get_account_pnl = AsyncMock()
await plugin.handle_message('/d')
await plugin.handle_message("/d")
plugin.exchange.get_account_pnl.assert_awaited_once()


@pytest.mark.asyncio
async def test_parse_help(plugin):
"""Test help """
"""Test help"""
plugin.exchange.get_help = AsyncMock()
await plugin.handle_message('/help')
await plugin.handle_message("/help")
plugin.exchange.get_help.assert_awaited_once()


@pytest.mark.asyncio
async def test_parse_info(plugin):
"""Test help """
"""Test help"""
plugin.exchange.get_info = AsyncMock()
await plugin.handle_message('/info')
await plugin.handle_message("/info")
plugin.exchange.get_info.assert_awaited_once()
8 changes: 7 additions & 1 deletion tt/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@

@app.on_event("startup")
async def start_bot_task():
"""⛓️🤖BOT"""
"""
⛓️🤖BOT
Run the talky bot on startup
asynchronously
"""
event_loop = asyncio.get_event_loop()
event_loop.create_task(run_bot())

Expand Down
Loading

0 comments on commit 11c88a7

Please sign in to comment.