Calculate profit in XMR

master
Mark Veidemanis 1 year ago
parent 0be1b98072
commit a84fff2492
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

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

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

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

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

@ -239,7 +239,7 @@ class LinkGroupSimulation(LoginRequiredMixin, OTPRequiredMixin, ObjectRead):
print("COLLAPSED", collapsed)
self.extra_context = {"collapsed": collapsed}
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

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

Loading…
Cancel
Save