https://github.com/druids/clj-bitstamp
A client for Bitstamp API based on core.async
https://github.com/druids/clj-bitstamp
Last synced: over 1 year ago
JSON representation
A client for Bitstamp API based on core.async
- Host: GitHub
- URL: https://github.com/druids/clj-bitstamp
- Owner: druids
- License: mit
- Created: 2018-03-29T13:48:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-01T12:19:23.000Z (about 8 years ago)
- Last Synced: 2025-01-30T02:14:13.632Z (over 1 year ago)
- Language: Clojure
- Size: 28.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
clj-bitstamp
=================
A client for [Bitstamp API](https://www.bitstamp.net/websocket) based on [core.async](https://github.com/clojure/core.async).
[](https://circleci.com/gh/druids/clj-bitstamp)
[](https://jarkeeper.com/druids/clj-bitstamp)
[](https://opensource.org/licenses/MIT)
Leiningen/Boot
--------------
```clojure
[clj-bitstamp "0.4.0"]
```
Documentation
-------------
This library is a thin wrapper around `com.pusher/pusher-java-client` within a simple usage. A function `new-pusher`
opens a new connection with the Pusher server, subscribes a requested channel and returns a following tuple
`[pusher pusher-channel status-ch data-ch]` where
- `pusher` a Pusher instance
- `pusher` a subscribed Channel instance
- `status-ch` an async channel containing a pusher and channel messages as a tuple `[action data]`
- `data-ch` an async channel containing data for the subscribed channel as a tuple `[channel-name event-name data]`
The function takes an option object:
- `channel-name` a channel name to subscribe, required
- `pusher-key` a Pusher key, default de504dc5763aeef9ff52, optional
- `event-name` an event name to bind on the subscribed channel, optional
- `status-buffer-or-n` a buffer-or-n for the status channel, optional
- `data-buffer-or-n` a buffer-or-n for the data channel, optional
- `str-big-decimals?` when `true` coerce a volume and price (in strings) as `BigDecimal`, default `true`
Data channel returns a tuple of channel-name, event-name (as `keyword`), and data.
Status channel returns a tuple of event-name (as `keyword`), and data. Expected events:
- `:change`
- `:connecting`
- `:connected`
- `:disconnecting`
- `:disconnected`
Example:
```clojure
(require '[clojure.core.async :as async])
(require '[clj-bitstamp.async :as bitstamp])
(let [[pusher pusher-channel status-ch data-ch]
(bitstamp/new-pusher {:channel-name "order_book_btceur" ;; required
:event-name "data" ;; required
:data-buffer-or-n (async/sliding-buffer 16) ;; optinal
:status-buffer-or-n 16})] ;; optional
(async/go-loop []
(let [[channel-name event-name data] (async/