Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-v3-bug] Operations do not appear atomic. Retries should not be so necessary #10

Open
brianddk opened this issue Apr 2, 2024 · 0 comments

Comments

@brianddk
Copy link
Owner

brianddk commented Apr 2, 2024

Normally, most REST operations are rather atomic. When an asset is bought, the balance should update, when sold, the balance should decrement. This is not the case for many endpoints. Order fills and order opens take a finite amount of time to propagate to the underlying wallet.

while abs(balance - target) > 1 and balance < target:
sleep(1)
print(f"Waiting: balance={balance:.2f}, target={target:.2f}")
balance = get_balance(cbv3, account_id)

Whats worse, even orders placed will disappear when read back, requiring retries to verify that placed orders are placed.

if resp["success"]:
for i in range(retry):
try:
resp = cbv3.v3_client.get_order(resp["order_id"])
except Exception:
print("retrying")
sleep(1)
continue
if resp["order"]:
break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant