Skip to content

Commit

Permalink
Bitmex exchange (thrasher-corp#160)
Browse files Browse the repository at this point in the history
* Added REST support for Bitmex

* Added Bitmex documentation updates

* Update config_example.json

* Added final REST functions for user account operations.

* Added initial websocket support

* Change function access
Added reconnection logic

* Added initial routine management
Updated wrapper functions

* General fixes
  • Loading branch information
shazbert authored and thrasher- committed Aug 9, 2018
1 parent a0de1b7 commit 06a0cae
Show file tree
Hide file tree
Showing 17 changed files with 10,245 additions and 6 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
| Bitfinex | Yes | Yes | NA |
| Bitflyer | Yes | No | NA |
| Bithumb | Yes | NA | NA |
| BitMEX | Yes | No | NA |
| Bitstamp | Yes | Yes | No |
| Bittrex | Yes | No | NA |
| BTCC | Yes | Yes | No |
Expand Down Expand Up @@ -175,6 +176,3 @@ Binaries will be published once the codebase reaches a stable condition.
| askew- | https://github.com/askew- | 1 |
| whilei | https://github.com/whilei | 1 |
| snipesjr | https://github.com/snipesjr | 1 |



4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestGetEnabledExchanges(t *testing.T) {
}

exchanges := cfg.GetEnabledExchanges()
if len(exchanges) != 29 {
if len(exchanges) != 30 {
t.Error(
"Test failed. TestGetEnabledExchanges. Enabled exchanges value mismatch",
)
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestGetDisabledExchanges(t *testing.T) {
}

func TestCountEnabledExchanges(t *testing.T) {
defaultEnabledExchanges := 29
defaultEnabledExchanges := 30
GetConfigEnabledExchanges := GetConfig()
err := GetConfigEnabledExchanges.LoadConfig(ConfigTestFile)
if err != nil {
Expand Down
36 changes: 35 additions & 1 deletion config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,40 @@
}
]
},
{
"Name": "Bitmex",
"Enabled": true,
"Verbose": false,
"Websocket": false,
"UseSandbox": false,
"RESTPollingDelay": 10,
"HTTPTimeout": 15000000000,
"AuthenticatedAPISupport": false,
"APIKey": "Key",
"APISecret": "Secret",
"AvailablePairs": "XRPXBT",
"EnabledPairs": "XRPXBT",
"BaseCurrencies": "USD",
"AssetTypes": "SPOT",
"SupportsAutoPairUpdates": false,
"ConfigCurrencyPairFormat": {
"Uppercase": true
},
"RequestCurrencyPairFormat": {
"Uppercase": true
},
"BankAccounts": [
{
"BankName": "",
"BankAddress": "",
"AccountName": "",
"AccountNumber": "",
"SWIFTCode": "",
"IBAN": "",
"SupportedCurrencies": ""
}
]
},
{
"name": "Bitstamp",
"enabled": true,
Expand Down Expand Up @@ -1202,4 +1236,4 @@
"supportedExchanges": "ANX,Kraken"
}
]
}
}
3 changes: 3 additions & 0 deletions exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/thrasher-/gocryptotrader/exchanges/bitfinex"
"github.com/thrasher-/gocryptotrader/exchanges/bitflyer"
"github.com/thrasher-/gocryptotrader/exchanges/bithumb"
"github.com/thrasher-/gocryptotrader/exchanges/bitmex"
"github.com/thrasher-/gocryptotrader/exchanges/bitstamp"
"github.com/thrasher-/gocryptotrader/exchanges/bittrex"
"github.com/thrasher-/gocryptotrader/exchanges/btcc"
Expand Down Expand Up @@ -145,6 +146,8 @@ func LoadExchange(name string, useWG bool, wg *sync.WaitGroup) error {
exch = new(bitflyer.Bitflyer)
case "bithumb":
exch = new(bithumb.Bithumb)
case "bitmex":
exch = new(bitmex.Bitmex)
case "bitstamp":
exch = new(bitstamp.Bitstamp)
case "bittrex":
Expand Down
133 changes: 133 additions & 0 deletions exchanges/bitmex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# GoCryptoTrader package Bitmex

<img src="https://github.com/thrasher-/gocryptotrader/blob/master/web/src/assets/page-logo.png?raw=true" width="350px" height="350px" hspace="70">


[![Build Status](https://travis-ci.org/thrasher-/gocryptotrader.svg?branch=master)](https://travis-ci.org/thrasher-/gocryptotrader)
[![Software License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](https://github.com/thrasher-/gocryptotrader/blob/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/thrasher-/gocryptotrader?status.svg)](https://godoc.org/github.com/thrasher-/gocryptotrader/exchanges/bitmex)
[![Coverage Status](http://codecov.io/github/thrasher-/gocryptotrader/coverage.svg?branch=master)](http://codecov.io/github/thrasher-/gocryptotrader?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/thrasher-/gocryptotrader)](https://goreportcard.com/report/github.com/thrasher-/gocryptotrader)


This bitmex package is part of the GoCryptoTrader codebase.

## This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: [https://trello.com/b/ZAhMhpOy/gocryptotrader](https://trello.com/b/ZAhMhpOy/gocryptotrader).

Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader Slack](https://gocryptotrader.herokuapp.com/)

## Bithumb Exchange

### Current Features

+ REST Support

### How to enable

+ [Enable via configuration](https://github.com/thrasher-/gocryptotrader/tree/master/config#enable-exchange-via-config-example)

+ Individual package example below:

```go
// Exchanges will be abstracted out in further updates and examples will be
// supplied then
```

### How to do REST public/private calls

+ If enabled via "configuration".json file the exchange will be added to the
IBotExchange array in the ```go var bot Bot``` and you will only be able to use
the wrapper interface functions for accessing exchange data. View routines.go
for an example of integration usage with GoCryptoTrader. Rudimentary example
below:

main.go
```go
var b exchange.IBotExchange

for i := range bot.exchanges {
if bot.exchanges[i].GetName() == "Bitmex" {
b = bot.exchanges[i]
}
}

// Public calls - wrapper functions

// Fetches current ticker information
tick, err := b.GetTickerPrice()
if err != nil {
// Handle error
}

// Fetches current orderbook information
ob, err := b.GetOrderbookEx()
if err != nil {
// Handle error
}

// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
// set and AuthenticatedAPISupport is set to true

// Fetches current account information
accountInfo, err := b.GetExchangeAccountInfo()
if err != nil {
// Handle error
}
```

+ If enabled via individually importing package, rudimentary example below:

```go
// Public calls

// Fetches current ticker information
ticker, err := b.GetTicker()
if err != nil {
// Handle error
}

// Fetches current orderbook information
ob, err := b.GetOrderBook()
if err != nil {
// Handle error
}

// Private calls - make sure your APIKEY and APISECRET are set and
// AuthenticatedAPISupport is set to true

// GetUserInfo returns account info
accountInfo, err := b.GetUserInfo(...)
if err != nil {
// Handle error
}

// Submits an order and the exchange and returns its tradeID
tradeID, err := b.Trade(...)
if err != nil {
// Handle error
}
```

### Please click GoDocs chevron above to view current GoDoc information for this package

## Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

+ Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
+ Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
+ Code must adhere to our [coding style](https://github.com/thrasher-/gocryptotrader/blob/master/doc/coding_style.md).
+ Pull requests need to be based on and opened against the `master` branch.

## Donations

<img src="https://github.com/thrasher-/gocryptotrader/blob/master/web/src/assets/donate.png?raw=true" hspace="70">

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

***1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB***

Loading

0 comments on commit 06a0cae

Please sign in to comment.