dimitri-xyz / haskell-coinbase-pro

A Haskell client for the Coinbase Pro API
MIT License
11 stars 6 forks source link

[INCOMPLETE] Begin writing a new README #8

Closed ericpashman closed 4 years ago

ericpashman commented 4 years ago

I've started writing an updated README, but this isn't ready to merge.

In particular, when I got to the point of writing a basic usage example, I realized that I'd written my own code to encapsulate the rigamarole of setting up a connection: making a TLS manager, reading in the environment variables, making an auth token, making a config from all of that, and passing everything to defaultMain. Does the library really not provide a convenience function that does that basic setup? If not, I'll submit one. Or if you have one you prefer, let's get that added.

Otherwise, we're still missing a CONTRIBUTING file. And I think we should consider stealing the feature checklist from the README at mdunnio/coinbase-pro (or something similar from one of the other projects implementing the API in various languages) and editing it to reflect our status. Anything else? Please feel free to edit this as you see fit, and to commit whenever.

Oh, will you add a description in the repo settings? Something like "A Haskell client for the Coinbase Pro API".

ericpashman commented 4 years ago

It turns out there is a convenience function for configuring the Websocket API that's similar to what I had rolled on my own, the withCoinbase function in sbox/Main.hs. But that's an executable module (providing an app that just prints everything coming off one of the Websocket feeds), not a library module, so it's inaccessible elsewhere. And it's not even used where it's defined.

There don't seem to be any other convenience functions for basic configuration anywhere, so I'll go ahead and provide them.

ericpashman commented 4 years ago

Commit 4e853ed adds a configure action that reads in the relevant environment variables, creates a new TLS manager, and produces an ExchangeConf. Commit 06d3e7f provides basic usage examples relying on configure.

But note that the example usage for the Websocket API returns a message from the exchange indicating that the subscription fails because a channel wasn't specified:

"{\"type\":\"error\",\"message\":\"Failed to subscribe\",\"reason\":\"No channels provided\"}"

I'm not entirely sure, but I think this reflects a change in the API's behavior: in the past, if I remember correctly, the "full" channel was the default channel if none was specified. I'm already working on fully implementing channels (see #9), so when I have a fix for this I'll update the README with a working example.

dimitri-xyz commented 4 years ago

This is a much better intro to the library. I think examples are key to making the library usable. This is a very good start.