1
0

Use AssetAmount for function place_market_order argument
All checks were successful
Python Ruff Code Quality / ruff (push) Successful in 22s
Run Python tests (through Pytest) / Test (push) Successful in 28s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 24s

This commit is contained in:
Jon Michael Aanes 2024-11-28 21:51:31 +01:00
parent 95c82d698c
commit d810b0cf61
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 10 additions and 13 deletions

View File

@ -124,8 +124,7 @@ class KucoinDepoFetcher(DepoFetcher):
def place_market_order(
self,
input_asset: fin_defs.Asset,
input_amount: Decimal,
input_: fin_defs.AssetAmount,
output_asset: fin_defs.Asset,
) -> TradeOrderDetails:
"""Executes a market order through the Kucoin market.
@ -155,22 +154,22 @@ class KucoinDepoFetcher(DepoFetcher):
msg = 'KucoinDepoFetcher.allow_trades is not enabled: Cannot make trades'
raise PermissionError(msg)
if fin_defs.USDT not in [input_asset, output_asset]:
if fin_defs.USDT not in [input_.asset, output_asset]:
msg = 'Non-USDT Markets are not supported'
raise NotImplementedError(msg)
# Convert arguments to kucoin client arguments
if input_asset == fin_defs.USDT:
if input_.asset == fin_defs.USDT:
symbol: str = (
f'{output_asset.raw_short_name()}-{input_asset.raw_short_name()}'
f'{output_asset.raw_short_name()}-{input_.asset.raw_short_name()}'
)
side: str = 'buy'
size = None
funds = str(input_amount)
funds = str(input_.amount)
else:
symbol = f'{input_asset.raw_short_name()}-{output_asset.raw_short_name()}'
symbol = f'{input_.asset.raw_short_name()}-{output_asset.raw_short_name()}'
side = 'sell'
size = str(input_amount)
size = str(input_.amount)
funds = None
# Place order
@ -181,7 +180,7 @@ class KucoinDepoFetcher(DepoFetcher):
size=size,
funds=funds,
)
del symbol, side, size, funds, input_amount
del symbol, side, size, funds, input_
# Determine order details
return self._get_order_details(response['orderId'])

View File

@ -49,8 +49,7 @@ def test_place_buy_side_order():
input_amount = Decimal('0.1')
order_details = fetcher.place_market_order(
fin_defs.USDT,
input_amount,
fin_defs.AssetAmount(fin_defs.USDT, input_amount),
fin_defs.MPC,
)
@ -85,8 +84,7 @@ def test_place_sell_side_order():
input_amount = Decimal('1')
order_details = fetcher.place_market_order(
fin_defs.MPC,
input_amount,
fin_defs.AssetAmount(fin_defs.MPC, input_amount),
fin_defs.USDT,
)