Historical Token Portfolio
Historical token balance indexer
The Historical Portfolio Index is a purpose-built indexer that retrieves historical token balances for a specified wallet over a defined timeframe. It offers users a comprehensive view of their portfolio composition at various points in time, making it ideal for monitoring changes in portfolio value. The indexer supports balance queries at the end of each day, month, and year, as well as for custom time intervals, enabling flexible and detailed historical analysis.
Functionality
Flexible Timeframe-Based Balance Tracking:
Flexible Timeframe-Based Balance Tracking: Retrieves historical token balances for a wallet across a user-defined date range. Enhanced support for End of Day (EOD), End of Month (EOM), and End of Year (EOY) snapshots enables precise and periodic balance assessments.
Historical Insights: Delivers token balance data at specific points within the selected timeframe, supporting in-depth analysis of portfolio performance, asset allocation, and historical value trends.
Methodology
Index Creation with Filters:
The index is initialized with customizable filters that define:
Account ID: Specifies the target wallet address for historical analysis.
Time Range: Sets the desired timeframe using start and end timestamps, supporting balance snapshots at End of Day (EOD), End of Month (EOM), or End of Year (EOY).
Backfilling Historical Data: Once the index is created, a backfill process is triggered to populate historical token balances by querying on-chain data. This process captures snapshots of token holdings over the specified period, accounting for all balance-affecting events such as transfers, trades, and staking activities.
Data Retrieval: Users can access the aggregated historical balance data at any time via API endpoints. The data can be retrieved as cumulative totals or broken down day-by-day, and is organized by token—offering a granular view of portfolio composition and balance fluctuations over time.
Technical Insights
Data Collection: The indexer gathers data by parsing on-chain records and transaction histories within the defined timeframe, ensuring accurate and comprehensive tracking of wallet activity.
Time-Based Balance Tracking: Enables the generation of balance snapshots at the end of each day, month, or year within the selected period, providing structured and periodic portfolio insights.
Price Correlation: By capturing token balances over time, users can align this data with historical price feeds to analyze changes in portfolio value and assess performance trend
Use Cases
Historical Portfolio Analysis: Allows users to review past portfolio compositions and identify patterns or shifts in token holdings over time.
Performance Tracking: Facilitates the evaluation of historical performance for individual tokens or overall portfolio growth across specific time periods.
Tax and Compliance Reporting: Delivers precise historical balance records that support audits, tax filings, and adherence to regulatory requirements.
API Documentation
Authorization
Each request must include an x-api-key
header for authorization. Ensure that <your_api_key>
is replaced with your actual API key.
Index Creation Flow
Create New Index
POST {admin-base}/index/account
Purpose: Initializes a new historical portfolio index to begin tracking token balances for a specified wallet.Start Backfill Job
POST {admin-base}/backfill/{index_id}
Purpose: Launches a backfill job to fetch and populate historical balance data for the specified index ID.Check Backfill Status
GET {admin-base}/backfill/{index_id}
Purpose: Retrieves the current status of the backfill process, allowing users to monitor progress.Fetch Historical Portfolio Data
POST {index-dataset-url}/api/v1/portfolio/{index_id}/graphql
Purpose: Returns historical token balance data for the specified index ID across the selected time range.
Index Creation Example
Create New Index
POST {admin-base}/index/account
Headers:
x-api-key: <your_api_key>
Request Body: Example Config 1: This configuration sets up the index to track the historical token balances of a specified wallet, generating end-of-day (EOD) balance snapshots for each day within the defined timeframe.
Example Config 2: This configuration indexes the historical token balances of a specified wallet, generating daily end-of-day (EOD) balance snapshots over the defined time range.
Description: Initializes a new index to track historical portfolio data for a specified account.
Sample Response:
2. Start Backfill Job
POST {admin-base}/backfill/{index_id}
Headers:
x-api-key: <your_api_key>
URL Parameters:
index_id: The unique identifier of the index created in the previous step.
Request Body:
Description: Initiates the backfill process to populate historical token balance data for the specified index within the defined timeframe.
Sample Response:
3. Check Backfill Status
GET {admin-base}/backfill/{index_id}
Headers:
x-api-key: <your_api_key>
URL Parameters:
index_id: The unique identifier of the index for which to check the backfill status.
Description: Fetches the current status of the backfill job, including progress updates and estimated time to completion.
Sample Response:
4. Fetch Historical Portfolio Data
POST {index-dataset-url}/api/v1/portfolio/{index_id}/graphql
Or use the GraphQL Playground by pasting the following URL into your browser (replace {index_id}
with your actual index ID):
GraphQL Playground URL:
https://graphql.astralane.io/api/v1/portfolio/{index_id}/graphql
Headers:
x-api-key: <your_api_key>
URL Parameters:
index_id: The unique identifier of the index from which to retrieve historical portfolio data.
Description: Retrieves historical portfolio data for the specified index across the defined date range. This data includes token balances over time, enabling detailed analysis of portfolio changes.
sample Query:
Example responses for end of the day token balances
Example response for EOM (End of the month) token balances
Last updated