Skip to content

Commit dd2342a

Browse files
Merge pull request #154 from Divyn/main
crypto price API updates
2 parents d9af54e + 54ea2c5 commit dd2342a

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

docs/trading/crypto-price-api/examples.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,79 @@ subscription{
625625
}
626626
```
627627

628+
## Drawdown of an Asset in the Last Hour
629+
630+
Calculate the percentage drawdown (price decline) for tokens of a specific currency (e.g., Bitcoin) over a 1-hour interval.
631+
632+
This query uses [expressions](http://docs.bitquery.io/docs/graphql/capabilities/expression/) to calculate drawdown as: `((Close - Open) / Open) * 100`.
633+
634+
> **Note:** You can use `Token: {Address: {is: "token_address"}}` filter instead of `Currency: {Id: {is: "bid:bitcoin"}}` to filter by token address. We include `Volume: { Usd: { gt: 10 } }` to filter out tokens with very low trading volume.
635+
636+
[Run query](https://ide.bitquery.io/Drawdown-of-a-token-last-hour)
637+
638+
```graphql
639+
{
640+
Trading {
641+
Tokens(
642+
limit: { count: 1 }
643+
orderBy: { ascendingByField: "drawdown" }
644+
where: {
645+
Volume: { Usd: { gt: 10 } }
646+
Interval: { Time: { Duration: { eq: 3600 } } }
647+
Currency: { Id: { is: "bid:bitcoin" } }
648+
}
649+
) {
650+
Token {
651+
Address
652+
Did
653+
Id
654+
IsNative
655+
Name
656+
Network
657+
Symbol
658+
TokenId
659+
}
660+
Currency {
661+
Symbol
662+
Id
663+
Name
664+
}
665+
Interval {
666+
VolumeBased
667+
Time {
668+
Start
669+
End
670+
Duration
671+
}
672+
}
673+
Volume {
674+
Base
675+
Quote
676+
Usd
677+
}
678+
Price {
679+
IsQuotedInUsd
680+
Ohlc {
681+
Close
682+
High
683+
Low
684+
Open
685+
}
686+
Average {
687+
Estimate
688+
ExponentialMoving
689+
Mean
690+
SimpleMoving
691+
WeightedSimpleMoving
692+
}
693+
}
694+
diff: calculate(expression: "Price_Ohlc_Close - Price_Ohlc_Open")
695+
drawdown: calculate(expression: "($diff / Price_Ohlc_Open) * 100")
696+
}
697+
}
698+
}
699+
```
700+
628701
## Volume-Based Bitcoin Price Stream
629702

630703
Stream Bitcoin price data (USD OHLC) with a focus on volume-based intervals, useful for detecting price action tied to trading activity rather than fixed time windows.

0 commit comments

Comments
 (0)