1
0

Updated to match changes to fin-depo that use AssetAmount for more functionality

This commit is contained in:
Jon Michael Aanes 2024-11-28 21:56:36 +01:00
parent 86f41d7934
commit ede1dcfbef
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
3 changed files with 17 additions and 14 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) logger.info('Attempting to sell %s %s', amount_to_sell, config.input_asset)
order_details = config.seller.place_market_order( order_details = config.seller.place_market_order(
config.input_asset, fin_defs.AssetAmount(config.input_asset, amount_to_sell),
amount_to_sell,
config.output_asset, config.output_asset,
) )

View File

@ -32,4 +32,12 @@ class CsvFileLogger:
# Write row in CSV file # Write row in CSV file
with open(self.path, 'a') as f: with open(self.path, 'a') as f:
writer = csv.DictWriter(f, fieldnames=fieldnames) 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

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