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

View File

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