Use AssetAmount for function place_market_order argument
This commit is contained in:
parent
95c82d698c
commit
d810b0cf61
|
@ -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'])
|
||||||
|
|
|
@ -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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user