Skip to content

Commit

Permalink
Merge pull request #476 from mraniki/dev
Browse files Browse the repository at this point in the history
🎨 update main.py
  • Loading branch information
mraniki authored Jul 9, 2024
2 parents 6fbd691 + 243dd28 commit 63838d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 2 additions & 0 deletions cefi/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
DEX SWAP CONFIG
"""

import os

from dynaconf import Dynaconf
Expand All @@ -18,6 +19,7 @@
".op.toml",
],
load_dotenv=True,
merge_enabled=True,
environments=True,
default_env="default",
)
13 changes: 7 additions & 6 deletions cefi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def __init__(self):
logger.warning(
"No Client were created. Check your settings or disable the module."
)
return None

def _create_client(self, **kwargs):
"""
Expand Down Expand Up @@ -192,7 +193,7 @@ async def get_quotes(self, symbol):
Returns:
quotes
"""
_info = ["⚖️\n"]
_info = []
for client in self.clients:
_info.append(f"{client.name}: {await client.get_quote(symbol)}")
return "\n".join(_info)
Expand All @@ -208,7 +209,7 @@ async def get_balances(self):
balance
"""
_info = ["💵\n"]
_info = []
for client in self.clients:
_info.append(f"{client.name}:\n{await client.get_account_balance()}")
return "\n".join(_info)
Expand All @@ -224,7 +225,7 @@ async def get_positions(self):
position
"""
_info = ["📊\n"]
_info = []
for client in self.clients:
_info.append(f"{client.name}:\n{await client.get_account_position()}")
return "\n".join(_info)
Expand All @@ -239,7 +240,7 @@ async def get_pnls(self, **kwargs):
Returns:
pnl
"""
_info = ["🏆\n"]
_info = []
for client in self.clients:
client_name = f"{client.name}:\n"
account_pnl = await client.get_account_pnl(
Expand All @@ -263,7 +264,7 @@ async def submit_order(self, order_params):
trade_confirmation(dict)
"""
_order = ["🧾 Order\n"]
_order = []
for client in self.clients:
_order.append(
f"{client.name}:\n{await client.execute_order(order_params)}\n"
Expand All @@ -281,7 +282,7 @@ async def modify_position(self, order_params):
trade_confirmation(dict)
"""
_order = ["🧾 Order\n"]
_order = []
for client in self.clients:
_order.append(
f"{client.name}:\n{await client.modify_position(order_params)}\n"
Expand Down
11 changes: 4 additions & 7 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def test_cefi(CXTrader):
print(type(CXTrader))
result = await CXTrader.get_info()
assert "ℹ️" in result
assert "💱 binance" in result
assert ("binance" in result) or ("huobi" in result) or ("capital" in result)
assert CXTrader is not None
assert isinstance(CXTrader, CexTrader)
assert callable(CXTrader.get_balances)
Expand All @@ -69,7 +69,6 @@ async def test_quote(CXTrader, caplog):
"""Test quote"""
result = await CXTrader.get_quotes("BTC")
assert result is not None
assert "⚖️" in result
assert ("binance" in result) or ("huobi" in result) or ("capital" in result)
assert ("5" in result) or ("6" in result)

Expand All @@ -79,29 +78,27 @@ async def test_get_balances(CXTrader):
"""Test balance"""
result = await CXTrader.get_balances()
assert result is not None
assert "💵" in result
assert ("binance" in result) or ("huobi" in result)
assert ("binance" in result) or ("huobi" in result) or ("capital" in result)


@pytest.mark.asyncio
async def test_get_positions(CXTrader):
result = await CXTrader.get_positions()
assert "📊" in result
assert ("binance" in result) or ("huobi" in result) or ("capital" in result)


@pytest.mark.asyncio
async def test_get_pnls(CXTrader):
"""Test pnl"""
result = await CXTrader.get_pnls()
assert "🏆" in result
assert ("binance" in result) or ("huobi" in result) or ("capital" in result)


@pytest.mark.asyncio
async def test_submit_order(CXTrader, order):
result = await CXTrader.submit_order(order)
assert result is not None
print(result)
assert ("🧾" in result)
assert ("binance" in result) or ("huobi" in result) or ("capital" in result)
assert ("🔵" in result) or ("Error" in result)

Expand Down

0 comments on commit 63838d8

Please sign in to comment.