Historical Solana Data
Historical data for Solana has finally been added for the EAP
option, where we are providing data starting from May 2024 to now.
However the options to use the historical data are quite limited and currently only works for the aggregate data on
DEXTradeByTokens
. In this section, we will see some working examples for the same.
Trade Side Account
field will not be available for aggregate queries in Archive and Combined Datasets
Historical OHLC on Solana
This query returns the historical OHLC data for a given pair along with volume and number of trades in the given interval.
For this example the pair between the tokens listed below is considered.
6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui
So11111111111111111111111111111111111111112
{
Solana(dataset: archive) {
DEXTradeByTokens(
orderBy: { descendingByField: "Block_Timefield" }
where: {
Trade: {
Currency: {
MintAddress: { is: "6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui" }
}
Side: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
PriceAsymmetry: { lt: 0.1 }
}
}
limit: { count: 10 }
) {
Block {
Timefield: Time(interval: { in: days, count: 1 })
}
volume: sum(of: Trade_Amount)
Trade {
high: Price(maximum: Trade_Price)
low: Price(minimum: Trade_Price)
open: Price(minimum: Block_Slot)
close: Price(maximum: Block_Slot)
}
count
}
}
}
Each OHLC data point is calculated independently per time interval (e.g., daily). There’s no enforcement to make the
Close
of one candle match theOpen
of the next.Gaps are possible: Since the data is based on actual trades, if no trades occur exactly at the start or end of a day, the nearest trades before and after those timestamps will define the open and close. For instance:
- Last trade on April 14:
23:58:12
- First trade on April 15:
00:03:45
These would represent the close of April 14 and open of April 15 respectively, leaving a gap in between.
- Last trade on April 14:
Derived from block time: All time-based grouping (daily, hourly, etc.) depends on block timestamps.
Alternative approach: You can get all trades and calculate OHLC locally in your own system. Complete guide here
Top 10 token traders
This query returns the all time top 10 token traders for a particular token,
which is 6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui
in this case.
query MyQuery {
Solana(dataset: combined) {
DEXTradeByTokens(
limit: { count: 10 }
orderBy: { descendingByField: "tokens" }
where: {
Trade: {
Currency: {
MintAddress: { is: "6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui" }
}
}
}
) {
Trade {
Account {
Owner
}
}
tokens: sum(of: Trade_Amount)
trades: count
}
}
}
Tokens Traded by an Account
This query returns the list of tokens traded by the wallet address over a period of time. The list is sorted by the amount of tokens traded, and returns token info such as mint address, name and symbol along with the total amount of tokens traded and the number of trades involving that token.
query MyQuery {
Solana(dataset: combined) {
DEXTradeByTokens(
orderBy: { descendingByField: "tokens" }
where: {
Trade: {
Account: {
Owner: { is: "3CgvbiM3op4vjrrjH2zcrQUwsqh5veNVRjFCB9N6sRoD" }
}
}
}
) {
Trade {
Currency {
MintAddress
Name
Symbol
}
}
tokens: sum(of: Trade_Amount)
trades: count
}
}
}
Change in Liquidity Over a Month
This query returns the change in liquidity
for a particular token
pair over the last month. For this example the parameters listed below are used.
- Primary Token -
6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui
. - Secondary Token -
So11111111111111111111111111111111111111112
, - Pool Address -
BSzedbEvWRqVksaF558epPWCM16avEpyhm2HgSq9WZyy
query MyQuery {
Solana(dataset: combined) {
DEXTradeByTokens(
where: {
Trade: {
Currency: {
MintAddress: { is: "6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui" }
}
Side: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
Market: {
MarketAddress: {
is: "BSzedbEvWRqVksaF558epPWCM16avEpyhm2HgSq9WZyy"
}
}
}
}
orderBy: { descendingByField: "Block_Timefield" }
limit: { count: 1 }
) {
tokenLiquidity: sum(
of: Trade_Amount
if: { Trade: { Side: { Type: { is: buy } } } }
)
wsolLiquidity: sum(
of: Trade_Side_Amount
if: { Trade: { Side: { Type: { is: sell } } } }
)
Block {
Timefield: Time(interval: { in: months, count: 1 })
}
Trade {
Market {
MarketAddress
}
}
}
}
}
Get ATH (All-Time High) of a Token
In this query we use the 99th percentile (level: 0.99
) to find the highest price of a token.
We also use PriceAsymmetry
and AmountInUSD
in combination to filter outliers as much as possible.
Read more about quantiles here You can run the query here
{
Solana(dataset: archive) {
DEXTradeByTokens(
where: {Trade: {Currency: {MintAddress: {is: "9dzSzFvPsKDoY2gdWErsuz2H1o4tbzvgBhrNZ9cvkD2j"}}, PriceAsymmetry: {lt: 0.01}, AmountInUSD: {gt: "10"}}}
limit: {count: 1}
orderBy: {descendingByField: "aATH"}
) {
aATH: quantile(of: Trade_PriceInUSD, level: 0.99)
}
}
}
Get ATH of Multiple Tokens
You can run it here
{
Solana(dataset: combined) {
DEXTradeByTokens(
where: {Trade: {Currency: {MintAddress: {in: ["8SVVCGzYwnAkDwwvc5fSHZdCenUyhPccnGirWecVpump", "FeR8VBqNRSUD5NtXAj2n3j1dAHkZHfyDktKuLXD4pump"]}}, PriceAsymmetry: {lt: 0.01}, AmountInUSD: {gt: "10"}}}
limit: {count: 2}
orderBy: {descendingByField: "aATH"}
limitBy: {by: Trade_Currency_MintAddress, count: 1}
) {
Trade {
Currency {
Name
}
}
aATH: quantile(of: Trade_PriceInUSD, level: 0.99)
}
}
}