ScottLogic / StockFlux

StockFlux is a desktop application developed by Scott Logic that uses the OpenFin HTML5 container together with React, Redux, ES2015 and d3fc
MIT License
124 stars 36 forks source link

Dynamic / Ticking data #964

Open msuperina opened 6 years ago

msuperina commented 6 years ago

BitFlux can provide a Bitcoin data feed, which comes from Coinbase - historic data stitched together with a streaming feed. It is disabled by default but trivial to enable:

bitflux
    .app()
    .fetchGdaxProducts(true) // enable Bitcoin
    ...

For testing purposes, it is possible to make the Products dropdown provided by BitFlux visible, by tweaking the css in dev console; it is hidden by default, because StockFlux uses its Favourites/Search sidebar instead. This dropdown allows testing what happens when a Bitcoin product (which is essentially a currency pair such as BTC-EUR) is selected. What currently happens is that we get a 400 Bad Request from Coinbase, and in the response body we see the message

granularity too small for the requested time range

In BitFlux, the default time periods for requested data are 200 hours for Coinbase (200 data points at 1 hour granularity) and 200 days for Quandl (200 data points at 1 day granularity), which for Coinbase is the maximum allowed number of data points in any single request (Quandl appears to have no limits). In contrast, the default requested time period in StockFlux for Coinbase appears to be 40 days, at 1 hour granularity, which is too much data and results in Coinbase responding with Bad Request. I will investigate these defaults further; more details to follow.

For the actual implementation, we will need to enable searching Bitcoin as well as Quandl, either both at the same time or with an explicit selector to switch between the two sources. We will also need to store the source of each product in StockFlux (Quandl or Coinbase) alongside the product name, because BitFlux will need to know from which source to fetch the chart data when a product is selected in the sidebar.

And finally, there is a big question mark over how to display streaming Bitcoin data as currently, BitFlux has 1 Hour as its finest granularity, and StockFlux has 1 Day. This means that even with Bitcoin products, you don't see a moving line of data points which shifts every time a new trade arrives; instead the most recent candle is updated with the new data. We will likely need a different view / chart for real-time, streaming data.

ColinEberhardt commented 5 years ago

https://docs.pro.coinbase.com/#websocket-feed