Calculate profit in XMR

This commit is contained in:
Mark Veidemanis 2023-05-05 14:58:58 +01:00
parent 0be1b98072
commit a84fff2492
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
6 changed files with 12 additions and 5 deletions

View File

@ -766,11 +766,14 @@ class LocalPlatformClient(ABC):
if not settings.DUMMY: if not settings.DUMMY:
rtrn = await self.release_funds(trade_id) rtrn = await self.release_funds(trade_id)
print("RELEASE FUNDS RETURN", rtrn)
else: else:
log.debug(f"DUMMY: release_funds({trade_id})") log.debug(f"DUMMY: release_funds({trade_id})")
rtrn = {"message": "OK"} rtrn = {"message": "OK"}
if rtrn["message"] == "OK": if rtrn["message"] == "OK":
print("MESSAGE IS OK")
if not settings.DUMMY: if not settings.DUMMY:
print("NOT SETTINGS DUMMY")
await self.api.contact_message_post( await self.api.contact_message_post(
trade_id, "Thanks! Releasing now :)" trade_id, "Thanks! Releasing now :)"
) )

View File

@ -31,9 +31,6 @@ class AgoraClient(LocalPlatformClient, BaseClient):
self.instance.password, self.instance.password,
) )
# Check if we can withdraw funds
await self.withdraw_funds()
return rtrn return rtrn
# TODO: write test before re-enabling adding total_trades # TODO: write test before re-enabling adding total_trades

View File

@ -340,6 +340,7 @@ class Money(object):
remaining = withdraw_threshold - total_usd remaining = withdraw_threshold - total_usd
profit = total_usd - total_base_usd profit = total_usd - total_base_usd
profit_in_xmr = profit / xmr_usd["monero"]["usd"]
# Convert the total USD price to GBP and SEK # Convert the total USD price to GBP and SEK
price_sek = rates["SEK"] * total_usd price_sek = rates["SEK"] * total_usd
@ -358,6 +359,7 @@ class Money(object):
total_remaining = withdraw_threshold - total_with_trades total_remaining = withdraw_threshold - total_with_trades
total_profit = total_with_trades - total_base_usd total_profit = total_with_trades - total_base_usd
total_profit_in_xmr = total_profit / xmr_usd["monero"]["usd"]
# cast = ( # cast = (
# ( # (
@ -392,6 +394,7 @@ class Money(object):
"total_withdrawal_limit": total_withdrawal_limit, "total_withdrawal_limit": total_withdrawal_limit,
"remaining": remaining, "remaining": remaining,
"profit": profit, "profit": profit,
"profit_in_xmr": profit_in_xmr,
"withdraw_threshold": withdraw_threshold, "withdraw_threshold": withdraw_threshold,
} }
if trades: if trades:
@ -399,6 +402,7 @@ class Money(object):
cast_es["total_with_trades"] = total_with_trades cast_es["total_with_trades"] = total_with_trades
cast_es["total_remaining"] = total_remaining cast_es["total_remaining"] = total_remaining
cast_es["total_profit"] = total_profit cast_es["total_profit"] = total_profit
cast_es["total_profit_in_xmr"] = total_profit_in_xmr
# await self.write_to_es("get_total", cast_es) # await self.write_to_es("get_total", cast_es)
return cast_es return cast_es

View File

@ -28,6 +28,7 @@ async def withdrawal_job(group=None):
checks = await money.check_all( checks = await money.check_all(
user=group.user, nordigen=NordigenClient, agora=AgoraClient user=group.user, nordigen=NordigenClient, agora=AgoraClient
) )
print("CHECKS", checks)
aggregators = Aggregator.objects.filter( aggregators = Aggregator.objects.filter(
user=group.user, user=group.user,
link_group=group, link_group=group,
@ -45,7 +46,7 @@ async def withdrawal_job(group=None):
requisitions, requisitions,
platforms, platforms,
group.user, group.user,
checks["total_profit"], checks["total_profit_in_xmr"],
) )
collapsed = money.collapse_pay_list(pay_list) collapsed = money.collapse_pay_list(pay_list)
if any(collapsed.values()): if any(collapsed.values()):

View File

@ -239,7 +239,7 @@ class LinkGroupSimulation(LoginRequiredMixin, OTPRequiredMixin, ObjectRead):
print("COLLAPSED", collapsed) print("COLLAPSED", collapsed)
self.extra_context = {"collapsed": collapsed} self.extra_context = {"collapsed": collapsed}
self.extra_context["pay_list"] = pay_list self.extra_context["pay_list"] = pay_list
self.extra_context["total_profit"] = checks["total_profit"] self.extra_context["total_profit"] = checks["total_profit_in_xmr"]
return pay_list return pay_list

View File

@ -29,9 +29,11 @@ class Profit(LoginRequiredMixin, OTPRequiredMixin, ObjectRead):
"Open trade value": res["open_trade_value"], "Open trade value": res["open_trade_value"],
"Total": res["total_with_trades"], "Total": res["total_with_trades"],
"Profit": res["total_profit"], "Profit": res["total_profit"],
"Profit in XMR": res["total_profit_in_xmr"],
"Remaining before withdrawal": res["total_remaining"], "Remaining before withdrawal": res["total_remaining"],
"Total (without open trades)": res["total_usd"], "Total (without open trades)": res["total_usd"],
"Profit (without open trades)": res["profit"], "Profit (without open trades)": res["profit"],
"Profit (without open trades) in XMR": res["profit_in_xmr"],
"Remaining before withdrawal (without open trades)": res["remaining"], "Remaining before withdrawal (without open trades)": res["remaining"],
"Base balance required": res["total_base_usd"], "Base balance required": res["total_base_usd"],
"Amount above base balance to trigger withdrawal": res[ "Amount above base balance to trigger withdrawal": res[