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

get_perpetual_market_candles specifications ? #92

Open
svax974 opened this issue Dec 11, 2023 · 1 comment
Open

get_perpetual_market_candles specifications ? #92

svax974 opened this issue Dec 11, 2023 · 1 comment

Comments

@svax974
Copy link

svax974 commented Dec 11, 2023

Hello,

I can't find precise information on that function : does it always return the last 100 candles of the given resolution ?

Thanks !

Edit : I also wonder if there is a plan to add mainnet api urls as there are only the testnet ones in the Netwokr constants.

@samtin0x
Copy link
Contributor

samtin0x commented Aug 4, 2024

Hi @svax974,

The get_perpetual_market_candles method of the IndexerClient (Python v2 SDK) does not always return the last 100 candles of the given resolution. Its behavior is as follows:

  • Default behavior: If no limit is specified, the function returns up to 100 candles by default.
  • Customizable limit: You can adjust the number of candles returned by specifying a value for the limit parameter. For example:
from dydx_v4_client.indexer.rest.indexer_client import IndexerClient

client = IndexerClient(TESTNET.rest_indexer)
response = await client.markets.get_perpetual_market_candles(
    market=MARKET_BTC_USD,
    resolution=CandlesResolution.ONE_MINUTE,
    limit=50  # This will return up to 50 candles
)

Note that the maximum limit depends on the REST endpoint provider for the IndexerClient - some providers will limit the response size. In any case, you can further refine the data retrieval by using the from_iso and to_iso parameters to specify a specific time range and run a loop.

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

No branches or pull requests

2 participants