# Fetch historical price of asset

**URL:** https://community.bitquery.io/t/fetch-historical-price-of-asset/129
**Category:** GraphQL API
**Tags:** closed, support
**Created:** [June 8, 2021, 2:20am UTC](https://community.bitquery.io/t/fetch-historical-price-of-asset/129 "2021-06-08T02:20:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![FomoTrader](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@FomoTrader](https://community.bitquery.io/u/FomoTrader)
#### Post date: [June 8, 2021, 2:20am UTC](https://community.bitquery.io/t/fetch-historical-price-of-asset/129/1 "2021-06-08T02:20:35Z")

</div>

I’d like to be able to fetch historical price data of assets I’ve purchased so I can easily calculate PnL. At the moment the balances api does a fantastic of giving me the current balance of all the tokens in my wallet. But I don’t know how much was spent on each token.

---

<div class="post-metadata">

### Author: ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://community.bitquery.io/u/gaurav)
#### Post date: [June 8, 2021, 6:57am UTC](https://community.bitquery.io/t/fetch-historical-price-of-asset/129/2 "2021-06-08T06:57:09Z")

</div>

There are two ways, One if you purchased through DEX then you can get your DEX trades history.

> **[Trades for a specific wallet](https://graphql.bitquery.io/ide/WWPif54OtD)**
>
> Trades for a specific wallet

Another way to get all incoming(inbound) and outgoing(outbound) transaction history.

Inbound example - [All inbound transactions of a specific wallet](https://graphql.bitquery.io/ide/pEiqt70YFD)

outbound example - [All outbound transactions of a specific wallet](https://graphql.bitquery.io/ide/JFgqESFS9i)

---

<div class="post-metadata">

### Author: ![FomoTrader](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@FomoTrader](https://community.bitquery.io/u/FomoTrader)
#### Post date: [June 8, 2021, 9:26am UTC](https://community.bitquery.io/t/fetch-historical-price-of-asset/129/3 "2021-06-08T09:26:07Z")

</div>

Thanks Gaurav,

Unfortunately the first method does not return every trade made by a specific wallet for the given date range. It just returns some of the trades, not sure why?

As for the second/third method, they fetch the inbound/outbound txs in separate calls. That could get expensive quickly so not sure if that’s the best method going forward.

In essence all I’m trying to do is for a particular wallet, get all their trades and amount paid. Then get the current value of those some tokens and use that to calculate taxes.

---

<div class="post-metadata">

### Author: ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://community.bitquery.io/u/gaurav)
#### Post date: [June 9, 2021, 4:44am UTC](https://community.bitquery.io/t/fetch-historical-price-of-asset/129/4 "2021-06-09T04:44:56Z")

</div>

> [@FomoTrader](#):
>
> Unfortunately the first method does not return every trade made by a specific wallet for the given date range. It just returns some of the trades, not sure why?

Can you tell me which ones are missing?

> [@FomoTrader](#):
>
> As for the second/third method, they fetch the inbound/outbound txs in separate calls. That could get expensive quickly so not sure if that’s the best method going forward.

See this example of getting both inbound and outbound in one API call

> **[Inbound / outbound transactions for BTC address](https://ide.bitquery.io/PzGaeCK2hy)**
>
> Bitquery is analytical engine for blockchains

> **[inbound and outbound using alias](https://ide.bitquery.io/JVSPH2BbZI)**
>
> inbound and outbound using alias

> [@FomoTrader](#):
>
> In essence all I’m trying to do is for a particular wallet, get all their trades and amount paid. Then get the current value of those some tokens and use that to calculate taxes.

Let me know what else is missing here?

---

<div class="post-metadata">

### Author: ![FomoTrader](https://avatars.discourse-cdn.com/v4/letter/f/a3d4f5/32.png) [@FomoTrader](https://community.bitquery.io/u/FomoTrader)
#### Post date: [June 9, 2021, 5:28am UTC](https://community.bitquery.io/t/fetch-historical-price-of-asset/129/5 "2021-06-09T05:28:08Z")

</div>

The second example for getting inbound/outbound in one api call works well for BTC network, what do I need to do to fix it for bsc?

---

<div class="post-metadata">

### Author: ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://community.bitquery.io/u/gaurav)
#### Post date: [June 9, 2021, 5:52am UTC](https://community.bitquery.io/t/fetch-historical-price-of-asset/129/6 "2021-06-09T05:52:05Z")

</div>

```auto
{
  ethereum(network: bsc) {
    inbound: transfers(
      options: {desc: "block.timestamp.time", asc: "currency.symbol", limit: 10}
      amount: {gt: 0}
      receiver: {is: "0x239dd292f52cfb2523873993aac618ee1cb4f886"}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      address: sender {
        address
        annotation
      }
      currency {
        address
        symbol
      }
      gasValue
      amount
      transaction {
        hash
      }
      external
    }
    outbound: transfers(
      options: {desc: "block.timestamp.time", asc: "currency.symbol", limit: 10}
      amount: {gt: 0}
      sender: {is: "0x239dd292f52cfb2523873993aac618ee1cb4f886"}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      address: receiver {
        address
        annotation
      }
      currency {
        address
        symbol
      }
      amount
      transaction {
        hash
      }
      gasValue
      external
    }
  }
}

```
