1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
c2174b5081
Code and test quality
All checks were successful
Run Python tests (through Pytest) / Test (push) Successful in 27s
Verify Python project can be installed, loaded and have version checked / Test (push) Successful in 25s
2024-11-28 22:03:03 +01:00
ede1dcfbef
Updated to match changes to fin-depo that use AssetAmount for more functionality 2024-11-28 21:56:36 +01:00
6 changed files with 29 additions and 21 deletions

View File

@ -217,8 +217,7 @@ def run_auto_sell(config: AutoSellConfig) -> AutoSellRunResults:
logger.info('Attempting to sell %s %s', amount_to_sell, config.input_asset)
order_details = config.seller.place_market_order(
config.input_asset,
amount_to_sell,
fin_defs.AssetAmount(config.input_asset, amount_to_sell),
config.output_asset,
)

View File

@ -32,4 +32,12 @@ class CsvFileLogger:
# Write row in CSV file
with open(self.path, 'a') as f:
writer = csv.DictWriter(f, fieldnames=fieldnames)
writer.writerow(trade_order.__dict__)
d = trade_order.__dict__
d['input_asset'] = d['input'].asset
d['input_amount'] = d['input'].amount
d['output_asset'] = d['output'].asset
d['output_amount'] = d['output'].amount
d['fee_asset'] = d['fee'].asset
d['fee_amount'] = d['fee'].amount
del d['fee'], d['input'], d['output']
writer.writerow(d)

View File

@ -2,7 +2,11 @@
from secret_loader import SecretLoader
__all__ = ['KUCOIN_KEY', 'KUCOIN_SECRET', 'KUCOIN_PASS']
__all__ = [
'KUCOIN_KEY',
'KUCOIN_PASS',
'KUCOIN_SECRET',
]
secret_loader = SecretLoader()

View File

@ -23,23 +23,19 @@ class SellerMock(fin_depo.data.DepoFetcher):
def place_market_order(
self,
input_asset: fin_defs.Asset,
input_amount: Decimal,
input_: fin_defs.AssetAmount,
output_asset: fin_defs.Asset,
) -> fin_depo.data.Depo:
assert input_amount <= self.amount_left, 'Attempt to sell too much'
self.amount_left -= input_amount
) -> fin_depo.data.TradeOrderDetails:
assert input_.amount <= self.amount_left, 'Attempt to sell too much'
self.amount_left -= input_.amount
executed_time = datetime.datetime.now(tz=datetime.UTC)
return fin_depo.data.TradeOrderDetails(
executed_time=executed_time,
input_asset=input_asset,
input_amount=input_amount,
output_asset=output_asset,
output_amount=input_amount,
fee_asset=input_asset,
fee_amount=Decimal(0),
input=input_,
output=fin_defs.AssetAmount(output_asset, input_.amount),
fee=fin_defs.AssetAmount(input_.asset, Decimal(0)),
order_id=10000000 - self.amount_left,
raw_order_details={'TEST': 1, 'DATA': 2},
)

2
test/test_init.py Normal file
View File

@ -0,0 +1,2 @@
def test_init_main():
import crypto_seller.__main__ # noqa: F401

View File

@ -1,7 +1,6 @@
import pytest
def test_secrets():
try:
import crypto_seller.secrets_config
except ModuleNotFoundError:
raise
except:
pass
with pytest.raises(ValueError, match='Failed to load secret with key:.*'):
import crypto_seller.secrets_config # noqa: F401