Installers for Windows and Mac are available at the top of this article. Now we have the working app, the last step is to bundle it up for distribution. tTextAlignment(Qt.AlignRight | Qt.AlignVCenter) If currency in DEFAULT_DISPLAY_CURRENCIES: Self._data_items = self.add_data_row(currency) Python def get_or_create_data_row(self, currency): The market activity (volume) plot however is always there, so we can just perform a simple update to the existing line. We can also remove lines for currencies that we no longer want to draw (if they've been deselected in the currency list). This allows us to check on each update whether we already have a line defined, and update it rather than recreating it. References to plotted lines are kept in a dictionary self._data_lines keyed by the cryptocurrency identifier. # This line should not be visible, if it is delete it. Y_min, y_max = min(y_min, *low), max(y_max, *high) Pen=pg.mkPen(self.get_currency_color(currency), width=2, style=Qt.DotLine) X, high, # Unpack a list of tuples into two lists, passed as individual args. # This line should be visible, if it's not drawn draw it. # Pre-process data into lists of x, y values. We also set the axis names, and add an infinite vertical line, which is just to track through the plot to get per-day currency conversion rates. We only plot the currency lines only once we have the data back from the API (in case any currencies are not activated) so the initial setup is just of the axis and grid. The currency values are all plotted on the same scale, using the same axis. PyQtGraph plot with multiple currencies and volume data The currency axis These are plotted as a series of lines, with each cryptocurrency close value plotted in a different colour, with high and low values drawed as dotted lines either side. The API calls return high, low, open and close values for each day and for each cryptocurrency in addition to a separate market volume value. You can put the cache wherever you want on disk, the only requirement is that it is user-writeable (so it continues to work after the app is packaged). With the cache enabled API responses will be cached and subsequent requests to the same URL will fetch from the cache (until it expires, set to 1 day by the API). ![]() Requests_cache.install_cache(os.path.expanduser('~/.goodforbitcoin')) This uses a simple SQLite file database to store the results of previous requests. Since we're retrieving daily rates, there isn't any reason to download >1 time per day.Īs we're performing the API calls using the requests library we can use requests_cache to automatically cache all our API requests transparently. However, it's still polite not to waste other people's bandwidth if you can avoid it. The free API comes with a generous limit of 100,000 calls/month, which you're unlikely to hit. Once all requests are finished the resulting data is emitted using the earlier defined signals. ((e, traceback.format_exc()))Ī separate API reqeust is performed for each cryptocurrency, updating the progress bar (emitting (int(100 * n / len(AVAILABLE_CRYPTO_CURRENCIES))) on each iteration) and then a final request is made to retrieve the volume information. (int(100 * n / len(AVAILABLE_CRYPTO_CURRENCIES))) The daily market volume data, giving the amount of trades occurring.įor n, crypto in enumerate(AVAILABLE_CRYPTO_CURRENCIES, 1):.The daily historic exchange values for all supported cryptocurrencies ( BTC, ETH, LTC, EOS, XRP and BCH) against a set of base-currencies ( EUR, USD and GBP).We're using two separate API calls to plot our graphs. Here we're using which offers free developer API access for non-commercial purposes, including historic data. The first thing we need is a data source. The bundled app is available for Windows and Mac. The resulting exchange rates are plotted using PyQtGraph along with a currency exchange list-view which is updated as you move your mouse through the plotted timeline. The app is powered by the API from which we retrieve per-day high, low, open and close values, alongside market trading volume amounts. Read on for an overview of how the application is put together, including interacting with APIs from PyQt5, plotting data with PyQtGraph and packaging apps with PyInstaller. I am by no means knowledgeable about cryptocurrencies, this app is just for fun. The only Bitcoin I own I was given by some random chap on the internet. ![]() It comes with built-in support for BTC, ETH, LTC, EOS, XRP and BCH currencies, with EUR, USD and GBP as base currencies for valuations. It displays daily market rates, including high, low and close valuations, alongside market trade volume for a range of popular cryptocurrencies. Goodforbitcoin is a simple cryptocurrency market-tracker.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |