Closed forReason closed 4 years ago
Hi Julian,
The price does change. There is no caching in the API. You might need to increase the your polling interval to see price changes.
async Task Main()
{
var client = new CoinbaseClient();
while (true)
{
var price = await client.Data.GetSpotPriceAsync("BTC-USD");
price.Data.Amount.Dump();
await Task.Delay(TimeSpan.FromSeconds(30));
}
}
7096.855
7096.855
7097.235
7097.235
7097.23
7097.235
7098.125
7097.775
Also, see https://developers.coinbase.com/api/v2#get-spot-price
Note that exchange rates fluctuates so the price is only correct for seconds at the time.
The price you get from Coinbase (for consumer customers) is derived from and lags behind the Coinbase Pro exchange price. So, you'll have to account for that in your code.
If you need more real-time market exchange prices, consider using the Coinbase.Pro library that connects directly to the exchange and supports real-time socket feeds.
https://github.com/bchavez/Coinbase.Pro
There are 3 ways:
(polling) Level 1 - best bid/ask: https://docs.pro.coinbase.com/#get-product-order-book
(polling) GetProductTicker - best bid/ask: https://docs.pro.coinbase.com/#get-product-ticker
Polling is discouraged in favor of connecting via the websocket stream and listening for match messages.
recommended: (push) Websocket Ticker Channel: https://docs.pro.coinbase.com/#the-ticker-channel
The ticker channel provides real-time price updates every time a match happens. It batches updates in case of cascading matches, greatly reducing bandwidth requirements.
I hope that helps.
Thanks, Brian
What is the expected behavior?
The exchange rates change
What is the actual behavior?
The exchange rates are staying the same forever
Any possible solutions?
How do you reproduce the issue?
Can you identify the location in the source code where the problem exists?
The Rest Api might cash the prices
If the bug is confirmed, would you be willing to submit a PR?
Yes / No (Help can be provided if you need assistance submitting a PR)