0
votes

I have pulled data for the transactions using the API. The problem is the "amount" is always using the current coin value and not the value at the time of executing the transaction. This makes it impossible to have correct history what was actually spent for the transaction.

for example. 10 hours ago I bought some DNT and received an email with " You converted 98.88 kr. of USD Coin to district0x ".. but if I look at the data I pull from server it will say that the amount is 108kr!!! this is not correct, it is adjusting the value to the current market price.

How do I get the price at the time of purchase? (and yes my values are in Danish Kroners).

1

1 Answers

0
votes

Depending on the transaction type for example a "buy":

from the transaction, you can get the buy_id and query the API for the buy details

buy_data = https://api.coinbase.com/v2/accounts/:account_id/buys/:buy_id;

and then

price = (buy_data['subtotal']['amount'] / buy_data['amount']['amount'])

Hope this helps, it's how we are managing it in-house.