GithubHelp home page GithubHelp logo

keychain's Introduction

keychain

Implementations and utilities for various cryptocurrency exchanges.

Usage

GDAX

You will find GDAX functionality in keychain.exchange.gdax

API Client

Most GDAX REST API requests will require credentials.

{:access-key "string"
 :access-secret "string"
 :access-passphrase "string"}

Keychain will look for three environment variables automatically:

  • KEYCHAIN_GDAX_ACCESS_KEY
  • KEYCHAIN_GDAX_ACCESS_SECRET
  • KEYCHAIN_GDAX_ACCESS_PASSPHRASE

Or you can supply your own function to source your credentials to the get-client function.

Example:

(use 'keychain.exchange.gdax)

(def gdax (get-client))

REST API

Get Product Order Book

(def product "ETH-USD")
;; Defaults to level 1
(get-product-order-book gdax product)

;; Level 2
(get-product-order-book gdax product :level 2)

;; Level 3
(get-product-order-book gdax product :level 3)

Get Trades

Returns a map containing the keys:

  • :data
  • :pagination

The pagination key is a map containing:

  • :before
  • :after
(def product "ETH-USD")

;; Default request
(get-trades gdax product)

;; With Limit
(get-trades gdax product :limit 10)

;; With Before
(get-trades gdax product :before "123")

;; With After
(get-trades gdax product :after "123")

Websockets Feed

Subscribe

The default implementation uses a sliding buffer with a of size 1000. You may provide your own core.async buffer with the :buffer option.

A message is a tuple where the first element is a string timestamp and the second is a type coerced, but unaltered, GDAX message.

By default the channels used are heartbeat and full. Custom channels can be provided as a vector of channel names only at this time to the subscribe arg map.

This function returns a map containing the following:

:feed

A core.async channel on which to receive messages

:errored

A core.async channel on which to receive a Throwable error.

:closed

A core.async channel on which to receive a code and reason for closing.

:connected

A core.async channel on which to receive an event upon initial connection.

:close

A zero argument function that will close the websocket subscription and all associated channels.

(use 'clojure.core.async)

(def products ["ETH-USD" "ETH-BTC"])

(def subscription (subscribe {:products products}))

(poll! (:feed subscription))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.