Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Commit

Permalink
Timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
vmpartner committed May 5, 2018
1 parent 15f0fed commit ba7c43f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
6 changes: 4 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"Master": {
"Host": "www.bitmex.com",
"Key": "123",
"Secret": "abc"
"Secret": "abc",
"Timeout": 20
},
"Dev": {
"Host": "testnet.bitmex.com",
"Key": "123",
"Secret": "abc"
"Secret": "abc",
"Timeout": 20
}
}
13 changes: 7 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package config

import (
"os"
"encoding/json"
"github.com/vmpartner/bitmex/tools"
"os"
)

type Config struct {
Host string
Key string
Secret string
DB struct {
Host string
Key string
Secret string
Timeout int64
DB struct {
Host string
Login string
Password string
Expand Down Expand Up @@ -52,4 +53,4 @@ func LoadMasterConfig(path string) MasterConfig {
tools.CheckErr(err)

return config
}
}
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package main

import (
"fmt"
"github.com/vmpartner/bitmex/bitmex"
"github.com/vmpartner/bitmex/config"
"github.com/vmpartner/bitmex/rest"
"github.com/vmpartner/bitmex/tools"
"github.com/vmpartner/bitmex/websocket"
"fmt"
"strings"
"github.com/vmpartner/bitmex/bitmex"
"github.com/vmpartner/bitmex/tools"
)

// Usage example
func main() {

// Load config
cfg := config.LoadConfig("config.json")
ctx := rest.MakeContext(cfg.Key, cfg.Secret, cfg.Host)
ctx := rest.MakeContext(cfg.Key, cfg.Secret, cfg.Host, cfg.Timeout)

// Get wallet
w, response, err := rest.GetWallet(ctx)
Expand Down
11 changes: 6 additions & 5 deletions rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"net/http"
)

func MakeContext(key string, secret string, host string) context.Context {
func MakeContext(key string, secret string, host string, timeout int64) context.Context {
return context.WithValue(context.TODO(), swagger.ContextAPIKey, swagger.APIKey{
Key: key,
Secret: secret,
Host: host,
Key: key,
Secret: secret,
Host: host,
Timeout: timeout,
})
}

Expand Down Expand Up @@ -76,4 +77,4 @@ func GetWallet(ctx context.Context) (swagger.Wallet, *http.Response, error) {
wallet, response, err := client.UserApi.UserGetWallet(ctx, params)

return wallet, response, err
}
}
13 changes: 7 additions & 6 deletions swagger/configuration.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
/*
* BitMEX API
*
* ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](https://www.bitmex.com/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section.
* ## REST API for the BitMEX Trading Platform [View Changelog](/app/apiChangelog) #### Getting Started ##### Fetching Data All REST endpoints are documented below. You can try out any query right from this interface. Most table queries accept `count`, `start`, and `reverse` params. Set `reverse=true` to get rows newest-first. Additional documentation regarding filters, timestamps, and authentication is available in [the main API documentation](https://www.bitmex.com/app/restAPI). *All* table data is available via the [Websocket](/app/wsAPI). We highly recommend using the socket if you want to have the quickest possible data without being subject to ratelimits. ##### Return Types By default, all data is returned as JSON. Send `?_format=csv` to get CSV data or `?_format=xml` to get XML data. ##### Trade Data Queries *This is only a small subset of what is available, to get you started.* Fill in the parameters and click the `Try it out!` button to try any of these queries. * [Pricing Data](#!/Quote/Quote_get) * [Trade Data](#!/Trade/Trade_get) * [OrderBook Data](#!/OrderBook/OrderBook_getL2) * [Settlement Data](#!/Settlement/Settlement_get) * [Exchange Statistics](#!/Stats/Stats_history) Every function of the BitMEX.com platform is exposed here and documented. Many more functions are available. ##### Swagger Specification [⇩ Download Swagger JSON](swagger.json) ## All API Endpoints Click to expand a section.
*
* OpenAPI spec version: 1.2.0
* Contact: [email protected]
Expand All @@ -25,10 +25,11 @@ type BasicAuth struct {
}

type APIKey struct {
Key string
Prefix string
Secret string
Host string
Key string
Prefix string
Secret string
Host string
Timeout int64
}

type Configuration struct {
Expand Down

0 comments on commit ba7c43f

Please sign in to comment.