Skip to content

feat: custom subgrounds client for polars#48

Open
0xMochan wants to merge 17 commits into0xPlaygrounds:mainfrom
Evan-Kim2028:feat/polars-client
Open

feat: custom subgrounds client for polars#48
0xMochan wants to merge 17 commits into0xPlaygrounds:mainfrom
Evan-Kim2028:feat/polars-client

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