Git Product home page Git Product logo

go-deribit's Introduction

Build Status Go Report Card codebeat badge

go-deribit

V3

This project is now using go1.13 with Go Modules, but should remain compatible with dep. Also, as there are some breaking changes introduced by the latest schema changes from the remote API, I have decided to carry on development in the new v3 namespace with the project root containing the code tagged v2.x.

import "github.com/adampointer/go-deribit/v3"

We now have the latest API methods which were recently released such as public/get_tradingview_chart_data.

I recommend using the v3 project in your projects as all onward development will now be within this project.

GoDoc API Documentation

Overview

Go library for using the Deribit's v2 Websocket API.

Deribit is a modern, fast BitCoin derivatives exchange.

This library is a port of the official wrapper libraries to Go.

If you wish to try it out, be kind and use my affiliate link https://www.deribit.com/reg-3027.8327

Or tip me!

btc: 3HmLfHJvrJuM48zHFY6HstUCxbuwV3dvxd

eth: 0x9Dc9129185E79211534D0039Af1C6f1ff585F5e3

ltc: MEpFjCdR3uXd6QjuJTSu3coLtcSWY3S2Hg

p.s. If you want a good BitMEX client library then try go-bitmex

V2 API Documentation

Example Usage

Look at cmd/example/main.go

make build
example --access-key XXX --secret-key YYYYYY

Reconnect Behaviour

There is a heartbeat which triggers every 10 seconds to keep the websocket connection alive. In the event of a connection error, the library will automatically attempt to reconnect, re-authenticate and reestablish subscriptions.

This behaviour is overrideable with the SetDisconnectHandler method.

// Example reconnect code
exchange.SetDisconnectHandler(func (core *deribit.RPCCore) {
    exg := &deribit.NewExchangeFromCore(true, core)
	log.Warn("Disconnected from exchange. Attempting reconnection...")
	if err := exg.Connect(); err != nil {
		log.Fatalf("Error re-connecting to exchange: %s", err)
	}
	log.Info("Reconnected")
})

Logging

The standard logger has been used within the library. You can plug this into your own application's logger by overriding the output io.Writer.

logger := logrus.New()
exchange.SetLogOutput(logger.Writer())

Development

The models and client directories are where all the requests and responses are stored. The contents is automatically generated from the schema directory by go-swagger.

If you need to rebuild these use make generate-models.

The RPC subscriptions are also auto-generated. Use make generate-methods to rebuild these. They are in rpc_subscriptions.go.

go-deribit's People

Contributors

adampointer avatar adampointer-form3 avatar krisa avatar kprimice avatar

Watchers

James Cloos avatar  avatar

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.