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

feat: custom subgrounds client for polars #48

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

0xMochan
Copy link
Collaborator

@0xMochan 0xMochan commented Nov 8, 2023

Related to this issue, #29

from polars_client import SubgroundsPolars
from subgrounds.subgraph import FieldPath, Subgraph

# from polars_utils.py import *

import polars as pl

sg = SubgroundsPolars()

snx_endpoint = "https://api.thegraph.com/subgraphs/name/synthetix-perps/perps"

snx = sg.load_subgraph(
    url=snx_endpoint,
)

trades_json = sg.query_json(
    [
        # set the first parameter to a larger size to query more rows.
        snx.Query.futuresTrades(
            first=2500,
            orderBy="timestamp",
            orderDirection="desc",
            # where=[{"timestamp_lte": "1694131200"}],  # 1694131200 = 9/8/23
        )
    ]
)

Features

  • create a custom subgrounds client to support polars dataframes

Originally #43

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

Successfully merging this pull request may close these issues.

2 participants