bithumb

package
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: 15 Imported by: 0

README

GoCryptoTrader package Bithumb

Build Status Software License GoDoc Coverage Status Go Report Card

This bithumb 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

Bithumb 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() == "Bithumb" {
    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 Account

type Account struct {
	Status string `json:"status"`
	Data   struct {
		Created   int64   `json:"created,string"`
		AccountID string  `json:"account_id"`
		TradeFee  float64 `json:"trade_fee,string"`
		Balance   float64 `json:"balance,string"`
	} `json:"data"`
	Message string `json:"message"`
}

Account holds account details

type ActionStatus

type ActionStatus struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

ActionStatus holds the return status

type Balance

type Balance struct {
	Status string `json:"status"`
	Data   struct {
		TotalBTC     float64 `json:"total_btc,string"`
		TotalKRW     float64 `json:"total_krw"`
		InUseBTC     float64 `json:"in_use_btc,string"`
		InUseKRW     float64 `json:"in_use_krw"`
		AvailableBTC float64 `json:"available_btc,string"`
		AvailableKRW float64 `json:"available_krw"`
		MisuKRW      float64 `json:"misu_krw"`
		MisuBTC      float64 `json:"misu_btc,string"`
		XcoinLast    float64 `json:"xcoin_last,string"`
	} `json:"data"`
	Message string `json:"message"`
}

Balance holds balance details

type Bithumb

type Bithumb struct {
	exchange.Base
}

Bithumb is the overarching type across the Bithumb package

func (*Bithumb) CancelAllExchangeOrders

func (b *Bithumb) CancelAllExchangeOrders() error

CancelAllExchangeOrders cancels all orders associated with a currency pair

func (*Bithumb) CancelExchangeOrder

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

CancelExchangeOrder cancels an order by its corresponding ID number

func (*Bithumb) CancelTrade

func (b *Bithumb) CancelTrade(transactionType, orderID, currency string) (ActionStatus, error)

CancelTrade cancels a customer purchase/sales transaction transactionType: Transaction type(bid : purchase, ask : sales) orderID: Order number registered for purchase/sales currency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS (default value: BTC)

func (*Bithumb) GetAccountBalance

func (b *Bithumb) GetAccountBalance() (Balance, error)

GetAccountBalance returns customer wallet information

func (*Bithumb) GetAccountInfo

func (b *Bithumb) GetAccountInfo() (Account, error)

GetAccountInfo returns account information

func (*Bithumb) GetAllTickers

func (b *Bithumb) GetAllTickers() (map[string]Ticker, error)

GetAllTickers returns all ticker information

func (*Bithumb) GetExchangeAccountInfo

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

GetExchangeAccountInfo retrieves balances for all enabled currencies for the Bithumb exchange

func (*Bithumb) GetExchangeDepositAddress

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

GetExchangeDepositAddress returns a deposit address for a specified currency

func (*Bithumb) GetExchangeFundTransferHistory

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

GetExchangeFundTransferHistory returns funding history, deposits and withdrawals

func (*Bithumb) GetExchangeHistory

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

GetExchangeHistory returns historic trade data since exchange opening.

func (*Bithumb) GetExchangeOrderInfo

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

GetExchangeOrderInfo returns information on a current open order

func (*Bithumb) GetLastTransaction

func (b *Bithumb) GetLastTransaction() (LastTransactionTicker, error)

GetLastTransaction returns customer last transaction

func (*Bithumb) GetOrderBook

func (b *Bithumb) GetOrderBook(symbol string) (Orderbook, error)

GetOrderBook returns current orderbook

symbol e.g. "btc"

func (*Bithumb) GetOrderDetails

func (b *Bithumb) GetOrderDetails(orderID, transactionType, currency string) (OrderDetails, error)

GetOrderDetails returns specific order details

orderID: Order number registered for purchase/sales transactionType: Transaction type(bid : purchase, ask : sales) currency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS (default value: BTC)

func (*Bithumb) GetOrderbookEx

func (b *Bithumb) GetOrderbookEx(currency pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*Bithumb) GetOrders

func (b *Bithumb) GetOrders(orderID, transactionType, count, after, currency string) (Orders, error)

GetOrders returns order list

orderID: order number registered for purchase/sales transactionType: transaction type(bid : purchase, ask : sell) count: Value : 1 ~1000 (default : 100) after: YYYY-MM-DD hh:mm:ss's UNIX Timestamp (2014-11-28 16:40:01 = 1417160401000)

func (*Bithumb) GetTicker

func (b *Bithumb) GetTicker(symbol string) (Ticker, error)

GetTicker returns ticker information

symbol e.g. "btc"

func (*Bithumb) GetTickerPrice

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

GetTickerPrice returns the ticker for a currency pair

func (*Bithumb) GetTradablePairs

func (b *Bithumb) GetTradablePairs() ([]string, error)

GetTradablePairs returns a list of tradable currencies

func (*Bithumb) GetTradingPairs

func (b *Bithumb) GetTradingPairs() ([]string, error)

GetTradingPairs gets the available trading currencies

func (*Bithumb) GetTransactionHistory

func (b *Bithumb) GetTransactionHistory(symbol string) (TransactionHistory, error)

GetTransactionHistory returns recent transactions

symbol e.g. "btc"

func (*Bithumb) GetUserTransactions

func (b *Bithumb) GetUserTransactions() (UserTransactions, error)

GetUserTransactions returns customer transactions

func (*Bithumb) GetWalletAddress

func (b *Bithumb) GetWalletAddress(currency string) (WalletAddressRes, error)

GetWalletAddress returns customer wallet address

currency e.g. btc, ltc or "", will default to btc without currency specified

func (*Bithumb) MarketBuyOrder

func (b *Bithumb) MarketBuyOrder(currency string, units float64) (MarketBuy, error)

MarketBuyOrder initiates a buy order through available order books

currency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS (default value: BTC) units: Order quantity

func (*Bithumb) MarketSellOrder

func (b *Bithumb) MarketSellOrder(currency string, units float64) (MarketSell, error)

MarketSellOrder initiates a sell order through available order books

currency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS (default value: BTC) units: Order quantity

func (*Bithumb) ModifyExchangeOrder

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

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

func (*Bithumb) PlaceTrade

func (b *Bithumb) PlaceTrade(orderCurrency, transactionType string, units float64, price int64) (OrderPlace, error)

PlaceTrade executes a trade order

orderCurrency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM, BTG, EOS (default value: BTC) transactionType: Transaction type(bid : purchase, ask : sales) units: Order quantity price: Transaction amount per currency

func (*Bithumb) RequestKRWDepositDetails

func (b *Bithumb) RequestKRWDepositDetails() (KRWDeposit, error)

RequestKRWDepositDetails returns Bithumb banking details for deposit information

func (*Bithumb) RequestKRWWithdraw

func (b *Bithumb) RequestKRWWithdraw(bank, account string, price int64) (ActionStatus, error)

RequestKRWWithdraw allows a customer KRW withdrawal request

bank: Bankcode with bank name e.g. (bankcode)_(bankname) account: Withdrawing bank account number price: Withdrawing amount

func (*Bithumb) Run

func (b *Bithumb) Run()

Run implements the OKEX wrapper

func (*Bithumb) SendAuthenticatedHTTPRequest

func (b *Bithumb) SendAuthenticatedHTTPRequest(path string, params url.Values, result interface{}) error

SendAuthenticatedHTTPRequest sends an authenticated HTTP request to bithumb

func (*Bithumb) SendHTTPRequest

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

SendHTTPRequest sends an unauthenticated HTTP request

func (*Bithumb) SetDefaults

func (b *Bithumb) SetDefaults()

SetDefaults sets the basic defaults for Bithumb

func (*Bithumb) Setup

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

Setup takes in the supplied exchange configuration details and sets params

func (*Bithumb) Start

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

Start starts the OKEX go routine

func (*Bithumb) SubmitExchangeOrder

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

SubmitExchangeOrder submits a new order

func (*Bithumb) UpdateOrderbook

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

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*Bithumb) UpdateTicker

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

UpdateTicker updates and returns the ticker for a currency pair

func (*Bithumb) WithdrawCrypto

func (b *Bithumb) WithdrawCrypto(address, destination, currency string, units float64) (ActionStatus, error)

WithdrawCrypto withdraws a customer currency to an address

address: Currency withdrawing address destination: Currency withdrawal Destination Tag (when withdraw XRP) OR Currency withdrawal Payment Id (when withdraw XMR) currency: BTC, ETH, DASH, LTC, ETC, XRP, BCH, XMR, ZEC, QTUM (default value: BTC) units: Quantity to withdraw currency

func (*Bithumb) WithdrawCryptoExchangeFunds

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

WithdrawCryptoExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bithumb) WithdrawFiatExchangeFunds

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

WithdrawFiatExchangeFunds returns a withdrawal ID when a withdrawal is submitted

func (*Bithumb) WithdrawFiatExchangeFundsToInternationalBank

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

WithdrawFiatExchangeFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

type KRWDeposit

type KRWDeposit struct {
	Status   string `json:"status"`
	Account  string `json:"account"`
	Bank     string `json:"bank"`
	BankUser string `json:"BankUser"`
	Message  string `json:"message"`
}

KRWDeposit resp type for a KRW deposit

type LastTransactionTicker

type LastTransactionTicker struct {
	Status string `json:"status"`
	Data   struct {
		OpeningPrice float64 `json:"opening_price,string"`
		ClosingPrice float64 `json:"closing_price,string"`
		MinPrice     float64 `json:"min_price,string"`
		MaxPrice     float64 `json:"max_price,string"`
		AveragePrice float64 `json:"average_price,string"`
		UnitsTraded  float64 `json:"units_traded,string"`
		Volume1Day   float64 `json:"volume_1day,string"`
		Volume7Day   float64 `json:"volume_7day,string"`
		BuyPrice     int64   `json:"buy_price,string"`
		SellPrice    int64   `json:"sell_price,string"`
		Date         int64   `json:"date,string"`
	} `json:"data"`
	Message string `json:"message"`
}

LastTransactionTicker holds customer last transaction information

type MarketBuy

type MarketBuy struct {
	Status  string `json:"status"`
	OrderID string `json:"order_id"`
	Data    []struct {
		ContID string  `json:"cont_id"`
		Units  float64 `json:"units,string"`
		Price  float64 `json:"price,string"`
		Total  float64 `json:"total,string"`
		Fee    float64 `json:"fee,string"`
	} `json:"data"`
	Message string `json:"message"`
}

MarketBuy holds market buy order information

type MarketSell

type MarketSell struct {
	Status  string `json:"status"`
	OrderID string `json:"order_id"`
	Data    []struct {
		ContID string  `json:"cont_id"`
		Units  float64 `json:"units,string"`
		Price  float64 `json:"price,string"`
		Total  float64 `json:"total,string"`
		Fee    float64 `json:"fee,string"`
	} `json:"data"`
	Message string `json:"message"`
}

MarketSell holds market buy order information

type OrderDetails

type OrderDetails struct {
	Status string `json:"status"`
	Data   []struct {
		TransactionDate int64   `json:"transaction_date,string"`
		Type            string  `json:"type"`
		OrderCurrency   string  `json:"order_currency"`
		PaymentCurrency string  `json:"payment_currency"`
		UnitsTraded     float64 `json:"units_traded,string"`
		Price           float64 `json:"price,string"`
		Total           float64 `json:"total,string"`
	} `json:"data"`
	Message string `json:"message"`
}

OrderDetails contains specific order information

type OrderPlace

type OrderPlace struct {
	Status string `json:"status"`
	Data   []struct {
		ContID string  `json:"cont_id"`
		Units  float64 `json:"units,string"`
		Price  float64 `json:"price,string"`
		Total  float64 `json:"total,string"`
		Fee    float64 `json:"fee,string"`
	} `json:"data"`
	Message string `json:"message"`
}

OrderPlace contains order information

type Orderbook

type Orderbook struct {
	Status string `json:"status"`
	Data   struct {
		Timestamp       int64  `json:"timestamp,string"`
		OrderCurrency   string `json:"order_currency"`
		PaymentCurrency string `json:"payment_currency"`
		Bids            []struct {
			Quantity float64 `json:"quantity,string"`
			Price    float64 `json:"price,string"`
		} `json:"bids"`
		Asks []struct {
			Quantity float64 `json:"quantity,string"`
			Price    float64 `json:"price,string"`
		} `json:"asks"`
	} `json:"data"`
	Message string `json:"message"`
}

Orderbook holds full range of order book information

type Orders

type Orders struct {
	Status string `json:"status"`
	Data   []struct {
		OrderID         string  `json:"order_id"`
		OrderCurrency   string  `json:"order_currency"`
		OrderDate       int64   `json:"order_date"`
		PaymentCurrency string  `json:"payment_currency"`
		Type            string  `json:"type"`
		Status          string  `json:"status"`
		Units           float64 `json:"units,string"`
		UnitsRemaining  float64 `json:"units_remaining,string"`
		Price           float64 `json:"price,string"`
		Fee             float64 `json:"fee,string"`
		Total           float64 `json:"total,string"`
		DateCompleted   int64   `json:"date_completed"`
	} `json:"data"`
	Message string `json:"message"`
}

Orders contains information about your current orders

type Ticker

type Ticker struct {
	OpeningPrice float64 `json:"opening_price,string"`
	ClosingPrice float64 `json:"closing_price,string"`
	MinPrice     float64 `json:"min_price,string"`
	MaxPrice     float64 `json:"max_price,string"`
	AveragePrice float64 `json:"average_price,string"`
	UnitsTraded  float64 `json:"units_traded,string"`
	Volume1Day   float64 `json:"volume_1day,string"`
	Volume7Day   float64 `json:"volume_7day,string"`
	BuyPrice     float64 `json:"buy_price,string"`
	SellPrice    float64 `json:"sell_price,string"`
	ActionStatus
}

Ticker holds ticker data

type TickerResponse

type TickerResponse struct {
	Status  string `json:"status"`
	Data    Ticker `json:"data"`
	Message string `json:"message"`
}

TickerResponse holds the standard ticker response

type TickersResponse

type TickersResponse struct {
	Status  string            `json:"status"`
	Data    map[string]Ticker `json:"data"`
	Message string            `json:"message"`
}

TickersResponse holds the standard ticker response

type TransactionHistory

type TransactionHistory struct {
	Status string `json:"status"`
	Data   []struct {
		ContNumber      int64   `json:"cont_no,string"`
		TransactionDate string  `json:"transaction_date"`
		Type            string  `json:"type"`
		UnitsTraded     float64 `json:"units_traded,string"`
		Price           float64 `json:"price,string"`
		Total           float64 `json:"total,string"`
	} `json:"data"`
	Message string `json:"message"`
}

TransactionHistory holds history of completed transaction data

type UserTransactions

type UserTransactions struct {
	Status string `json:"status"`
	Data   []struct {
		Search       string  `json:"search"`
		TransferDate int64   `json:"transfer_date"`
		Units        string  `json:"units"`
		Price        float64 `json:"price,string"`
		BTC1KRW      float64 `json:"btc1krw,string"`
		Fee          string  `json:"fee"`
		BTCRemain    float64 `json:"btc_remain,string"`
		KRWRemain    float64 `json:"krw_remain,string"`
	} `json:"data"`
	Message string `json:"message"`
}

UserTransactions holds users full transaction list

type WalletAddressRes

type WalletAddressRes struct {
	Status string `json:"status"`
	Data   struct {
		WalletAddress string `json:"wallet_address"`
		Currency      string `json:"currency"`
	} `json:"data"`
	Message string `json:"message"`
}

WalletAddressRes contains wallet address information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL