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

Perp positions delay in API call to /v2/positions #104

Closed
pfeiler opened this issue Jan 30, 2025 · 7 comments
Closed

Perp positions delay in API call to /v2/positions #104

pfeiler opened this issue Jan 30, 2025 · 7 comments

Comments

@pfeiler
Copy link

pfeiler commented Jan 30, 2025

I send an order for SOL-PERP via API call /v2/orders and in the GUI (https://app.drift.trade/overview/positions) I see it popping up first as "Open Orders" and then after seconds in "Open Positions". Great!

But when I query /v2/positions I dont see any perp data for quite a while in the reponse.
Even after 5 minutes still no data in json key "perp".

Also */v2/positionInfo/0 * gives me an error "{"code": 400,"reason": "no position"}, allthough I see the position in the GUI in "Open Positions".
Can you reproduce this?

Is there another way to do a "Close all positions" API call, instead of creating a order with the data from /v2/positions?

Thanks in advance!

@jordy25519
Copy link
Collaborator

hi, thanks for the report.

But when I query /v2/positions I dont see any perp data for quite a while in the reponse.
Even after 5 minutes still no data in json key "perp".

It should be patched in the latest release/commit.

Is there another way to do a "Close all positions" API call, instead of creating a order with the data from /v2/positions?

can you describe your usecase more? would they all market close?

@pfeiler
Copy link
Author

pfeiler commented Feb 6, 2025

Fixed it straight away!
With the positions data I can do "Close all position" call now.
Thanks a lot.

@pfeiler pfeiler closed this as completed Feb 6, 2025
@pfeiler
Copy link
Author

pfeiler commented Feb 6, 2025

I am very sorry, I have to reopen. I just had a brief look this morning.

It does work fine for the first order via gateway. But for all (successful) consecutive orders, /v2/positions does not show the correct perp data. It only returns the data from the first order. You have this as well?

@pfeiler pfeiler reopened this Feb 6, 2025
@jordy25519
Copy link
Collaborator

I am very sorry, I have to reopen. I just had a brief look this morning.

It does work fine for the first order via gateway. But for all (successful) consecutive orders, /v2/positions does not show the correct perp data. It only returns the data from the first order. You have this as well?

apologies, somehow missed this comment. I can't reproduce this issue.

can you try running gateway with this env var set and sharing any logs that come out of it:

RUST_LOG="info,solana_rpc_client::http_sender=debug,wsaccsub=debug,ws=debug,rpc=debug,marketmap=debug,oraclemap=debug"

also which RPC provider do you use?

@pfeiler
Copy link
Author

pfeiler commented Feb 17, 2025

By activating debug on the gateway I get a lot of the same error:

[2025-02-17T12:12:41Z DEBUG solana_rpc_client::http_sender] Too many requests: server responded with Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("api.mainnet-beta.solana.com")), port: None, path: "/", query: None, fragment: None }, status: 429, headers: {"content-type": "application/json", "retry-after": "10", "access-control-allow-methods": "POST, GET, OPTIONS", "access-control-allow-origin": "*", "content-length": "109", "cache-control": "no-cache", "access-control-max-age": "86400", "x-rpc-node": "fra120", "x-ratelimit-tier": "free", "x-ratelimit-method-limit": "5", "x-ratelimit-method-remaining": "-1", "x-ratelimit-rps-limit": "100", "x-ratelimit-rps-remaining": "92", "x-ratelimit-endpoint-limit": "unlimited", "x-ratelimit-endpoint-remaining": "-2299", "x-ratelimit-conn-limit": "40", "x-ratelimit-conn-remaining": "38", "x-ratelimit-connrate-limit": "40", "x-ratelimit-connrate-remaining": "38", "x-ratelimit-pubsub-limit": "5", "x-ratelimit-pubsub-remaining": "4"} }, 4 retries left, pausing for 10s

Gateway is basically working, but I understand that using the RPC endpoint https://api.mainnet-beta.solana.com is not recommended for stable environment.

Can you give some advice for other possibilities?
I checked this link https://github.com/arddluma/awesome-list-rpc-nodes-providers?tab=readme-ov-file#solana .

  • All free RPC endpoints do throw errors, like pub sub is not supported . Did I miss some free ones that work with the DRIFT gateway?
  • I registered with chainstack.com but the free tier instantly gave me a quota exceeded error. Looks like I need to spend $50/mo for a bigger tier.

I am basically making 50 API requets a day, maybe 500 if there is congestion due to retries.

Thanks for advice and helping out.

@jordy25519
Copy link
Collaborator

the https://www.helius.dev free plan is a great place to start, I frequently use it to test gateway without issue

@pfeiler
Copy link
Author

pfeiler commented Feb 17, 2025

Helius works great. No problems so far.

@pfeiler pfeiler closed this as completed Feb 17, 2025
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

2 participants