btcmarkets

package
Version: v0.0.0-...-a2c5123 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 14 Imported by: 0

README

GoCryptoTrader package Btcmarkets

Build Status Software License GoDoc Coverage Status Go Report Card

This btcmarkets 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.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

BTCMarkets Exchange

Current Features
  • REST Support
How to enable
  // 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

var b exchange.IBotExchange

for i := range bot.exchanges {
  if bot.exchanges[i].GetName() == "BTCMarkets" {
    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:
// 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 guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

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

1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalance

type AccountBalance struct {
	Balance      float64 `json:"balance"`
	PendingFunds float64 `json:"pendingFunds"`
	Currency     string  `json:"currency"`
}

AccountBalance holds account balance details

type BTCMarkets

type BTCMarkets struct {
	exchange.Base
	Ticker map[string]Ticker
}

BTCMarkets is the overarching type across the BTCMarkets package

func (*BTCMarkets) CancelAllExchangeOrders

func (b *BTCMarkets) CancelAllExchangeOrders() error

CancelAllExchangeOrders cancels all orders associated with a currency pair

func (*BTCMarkets) CancelExchangeOrder

func (b *BTCMarkets) CancelExchangeOrder(orderID int64) error

CancelExchangeOrder cancels an order by its corresponding ID number

func (*BTCMarkets) CancelOrder

func (b *BTCMarkets) CancelOrder(orderID []int64) (bool, error)

CancelOrder cancels an order by its ID orderID - id for order example "1337"

func (*BTCMarkets) GetAccountBalance

func (b *BTCMarkets) GetAccountBalance() ([]AccountBalance, error)

GetAccountBalance returns the full account balance

func (*BTCMarkets) GetExchangeAccountInfo

func (b *BTCMarkets) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo retrieves balances for all enabled currencies for the BTCMarkets exchange

func (*BTCMarkets) GetExchangeDepositAddress

func (b *BTCMarkets) GetExchangeDepositAddress(cryptocurrency pair.CurrencyItem) (string, error)

GetExchangeDepositAddress returns a deposit address for a specified currency

func (*BTCMarkets) GetExchangeFundTransferHistory

func (b *BTCMarkets) GetExchangeFundTransferHistory() ([]exchange.FundHistory, error)

GetExchangeFundTransferHistory returns funding history, deposits and withdrawals

func (*BTCMarkets) GetExchangeHistory

func (b *BTCMarkets) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data since exchange opening.

func (*BTCMarkets) GetExchangeOrderInfo

func (b *BTCMarkets) GetExchangeOrderInfo(orderID int64) (exchange.OrderDetail, error)

GetExchangeOrderInfo returns information on a current open order

func (*BTCMarkets) GetFee

func (b *BTCMarkets) GetFee() float64

GetFee returns the BTCMarkets fee on transactions

func (*BTCMarkets) GetOrderDetail

func (b *BTCMarkets) GetOrderDetail(orderID []int64) ([]Order, error)

GetOrderDetail returns order information an a specific order orderID - example "1337"

func (*BTCMarkets) GetOrderbook

func (b *BTCMarkets) GetOrderbook(firstPair, secondPair string) (Orderbook, error)

GetOrderbook returns current orderbook symbol - example "btc" or "ltc"

func (*BTCMarkets) GetOrderbookEx

func (b *BTCMarkets) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*BTCMarkets) GetOrders

func (b *BTCMarkets) GetOrders(currency, instrument string, limit, since int64, historic bool) ([]Order, error)

GetOrders returns current order information on the exchange currency - example "AUD" instrument - example "BTC" limit - example "10" since - since a time example "33434568724" historic - if false just normal Orders open

func (*BTCMarkets) GetTicker

func (b *BTCMarkets) GetTicker(firstPair, secondPair string) (Ticker, error)

GetTicker returns a ticker symbol - example "btc" or "ltc"

func (*BTCMarkets) GetTickerPrice

func (b *BTCMarkets) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*BTCMarkets) GetTrades

func (b *BTCMarkets) GetTrades(firstPair, secondPair string, values url.Values) ([]Trade, error)

GetTrades returns executed trades on the exchange symbol - example "btc" or "ltc" values - optional paramater "since" example values.Set(since, "59868345231")

func (*BTCMarkets) ModifyExchangeOrder

func (b *BTCMarkets) ModifyExchangeOrder(orderID int64, action exchange.ModifyOrder) (int64, error)

ModifyExchangeOrder will allow of changing orderbook placement and limit to market conversion

func (*BTCMarkets) NewOrder

func (b *BTCMarkets) NewOrder(currency, instrument string, price, amount float64, orderSide, orderType, clientReq string) (int64, error)

NewOrder requests a new order and returns an ID currency - example "AUD" instrument - example "BTC" price - example 13000000000 (i.e x 100000000) amount - example 100000000 (i.e x 100000000) orderside - example "Bid" or "Ask" orderType - example "limit" clientReq - example "abc-cdf-1000"

func (*BTCMarkets) Run

func (b *BTCMarkets) Run()

Run implements the BTC Markets wrapper

func (*BTCMarkets) SendAuthenticatedRequest

func (b *BTCMarkets) SendAuthenticatedRequest(reqType, path string, data interface{}, result interface{}) (err error)

SendAuthenticatedRequest sends an authenticated HTTP request

func (*BTCMarkets) SendHTTPRequest

func (b *BTCMarkets) SendHTTPRequest(path string, result interface{}) error

SendHTTPRequest sends an unauthenticated HTTP request

func (*BTCMarkets) SetDefaults

func (b *BTCMarkets) SetDefaults()

SetDefaults sets basic defaults

func (*BTCMarkets) Setup

func (b *BTCMarkets) Setup(exch config.ExchangeConfig)

Setup takes in an exchange configuration and sets all parameters

func (*BTCMarkets) Start

func (b *BTCMarkets) Start(wg *sync.WaitGroup)

Start starts the BTC Markets go routine

func (*BTCMarkets) SubmitExchangeOrder

func (b *BTCMarkets) SubmitExchangeOrder(p pair.CurrencyPair, side exchange.OrderSide, orderType exchange.OrderType, amount, price float64, clientID string) (int64, error)

SubmitExchangeOrder submits a new order

func (*BTCMarkets) UpdateOrderbook

func (b *BTCMarkets) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*BTCMarkets) UpdateTicker

func (b *BTCMarkets) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*BTCMarkets) WithdrawAUD

func (b *BTCMarkets) WithdrawAUD(accountName, accountNumber, bankName, bsbNumber string, amount float64) (string, error)

WithdrawAUD withdraws AUD into a designated bank address Does not return a TxID!

func (*BTCMarkets) WithdrawCrypto

func (b *BTCMarkets) WithdrawCrypto(amount float64, currency, address string) (string, error)

WithdrawCrypto withdraws cryptocurrency into a designated address

func (*BTCMarkets) WithdrawCryptoExchangeFunds

func (b *BTCMarkets) WithdrawCryptoExchangeFunds(address string, cryptocurrency pair.CurrencyItem, amount float64) (string, error)

WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*BTCMarkets) WithdrawFiatExchangeFunds

func (b *BTCMarkets) WithdrawFiatExchangeFunds(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*BTCMarkets) WithdrawFiatExchangeFundsToInternationalBank

func (b *BTCMarkets) WithdrawFiatExchangeFundsToInternationalBank(currency pair.CurrencyItem, amount float64) (string, error)

WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

type Order

type Order struct {
	ID              int64           `json:"id"`
	Currency        string          `json:"currency"`
	Instrument      string          `json:"instrument"`
	OrderSide       string          `json:"orderSide"`
	OrderType       string          `json:"ordertype"`
	CreationTime    float64         `json:"creationTime"`
	Status          string          `json:"status"`
	ErrorMessage    string          `json:"errorMessage"`
	Price           float64         `json:"price"`
	Volume          float64         `json:"volume"`
	OpenVolume      float64         `json:"openVolume"`
	ClientRequestID string          `json:"clientRequestId"`
	Trades          []TradeResponse `json:"trades"`
}

Order holds order information

type OrderToGo

type OrderToGo struct {
	Currency        string `json:"currency"`
	Instrument      string `json:"instrument"`
	Price           int64  `json:"price"`
	Volume          int64  `json:"volume"`
	OrderSide       string `json:"orderSide"`
	OrderType       string `json:"ordertype"`
	ClientRequestID string `json:"clientRequestId"`
}

OrderToGo holds order information to be sent to the exchange

type Orderbook

type Orderbook struct {
	Currency   string      `json:"currency"`
	Instrument string      `json:"instrument"`
	Timestamp  int64       `json:"timestamp"`
	Asks       [][]float64 `json:"asks"`
	Bids       [][]float64 `json:"bids"`
}

Orderbook holds current orderbook information returned from the exchange

type Response

type Response struct {
	Success      bool   `json:"success"`
	ErrorCode    int    `json:"errorCode"`
	ErrorMessage string `json:"errorMessage"`
	ID           int    `json:"id"`
	Responses    []struct {
		Success      bool   `json:"success"`
		ErrorCode    int    `json:"errorCode"`
		ErrorMessage string `json:"errorMessage"`
		ID           int64  `json:"id"`
	}
	ClientRequestID string  `json:"clientRequestId"`
	Orders          []Order `json:"orders"`
	Status          string  `json:"status"`
}

Response is the genralized response type

type Ticker

type Ticker struct {
	BestBID    float64 `json:"bestBid"`
	BestAsk    float64 `json:"bestAsk"`
	LastPrice  float64 `json:"lastPrice"`
	Currency   string  `json:"currency"`
	Instrument string  `json:"instrument"`
	Timestamp  int64   `json:"timestamp"`
	Volume     float64 `json:"volume24h"`
}

Ticker holds ticker information

type Trade

type Trade struct {
	TradeID int64   `json:"tid"`
	Amount  float64 `json:"amount"`
	Price   float64 `json:"price"`
	Date    int64   `json:"date"`
}

Trade holds trade information

type TradeResponse

type TradeResponse struct {
	ID           int64   `json:"id"`
	CreationTime float64 `json:"creationTime"`
	Description  string  `json:"description"`
	Price        float64 `json:"price"`
	Volume       float64 `json:"volume"`
	Fee          float64 `json:"fee"`
}

TradeResponse holds trade information

type WithdrawRequestAUD

type WithdrawRequestAUD struct {
	Amount        int64  `json:"amount"`
	Currency      string `json:"currency"`
	AccountName   string `json:"accountName"`
	AccountNumber string `json:"accountNumber"`
	BankName      string `json:"bankName"`
	BSBNumber     string `json:"bsbNumber"`
}

WithdrawRequestAUD is a generalized withdraw request type

type WithdrawRequestCrypto

type WithdrawRequestCrypto struct {
	Amount   int64  `json:"amount"`
	Currency string `json:"currency"`
	Address  string `json:"address"`
}

WithdrawRequestCrypto is a generalized withdraw request type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL