btse

package
v0.0.0-...-069e140 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 28 Imported by: 0

README

GoCryptoTrader package Btse

Build Status Software License GoDoc Coverage Status Go Report Card

This btse package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress 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
  • Websocket 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() == "BTSE" {
    b = bot.Exchanges[i]
  }
}

// Public calls - wrapper functions

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

// Fetches current orderbook information
ob, err := b.FetchOrderbook()
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.GetAccountInfo()
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:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BTSE

type BTSE struct {
	exchange.Base
}

BTSE is the overarching type across this package

func (*BTSE) CancelAllOrders

func (b *BTSE) CancelAllOrders(orderCancellation *order.Cancel) (order.CancelAllResponse, error)

CancelAllOrders cancels all orders associated with a currency pair If product ID is sent, all orders of that specified market will be cancelled If not specified, all orders of all markets will be cancelled

func (*BTSE) CancelExistingOrder

func (b *BTSE) CancelExistingOrder(orderID, symbol string) (*CancelOrder, error)

CancelExistingOrder cancels an order

func (*BTSE) CancelOrder

func (b *BTSE) CancelOrder(order *order.Cancel) error

CancelOrder cancels an order by its corresponding ID number

func (*BTSE) CreateOrder

func (b *BTSE) CreateOrder(amount, price float64, side, orderType, symbol, timeInForce, tag string) (*string, error)

CreateOrder creates an order

func (*BTSE) FetchAccountInfo

func (b *BTSE) FetchAccountInfo() (account.Holdings, error)

FetchAccountInfo retrieves balances for all enabled currencies

func (*BTSE) FetchOrderBook

func (b *BTSE) FetchOrderBook(symbol string) (*Orderbook, error)

FetchOrderBook gets orderbook data for a given pair

func (*BTSE) FetchOrderbook

func (b *BTSE) FetchOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

FetchOrderbook returns orderbook base on the currency pair

func (*BTSE) FetchTicker

func (b *BTSE) FetchTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

FetchTicker returns the ticker for a currency pair

func (*BTSE) FetchTradablePairs

func (b *BTSE) FetchTradablePairs(a asset.Item) ([]string, error)

FetchTradablePairs returns a list of the exchanges tradable pairs

func (*BTSE) GenerateDefaultSubscriptions

func (b *BTSE) GenerateDefaultSubscriptions() ([]stream.ChannelSubscription, error)

GenerateDefaultSubscriptions Adds default subscriptions to websocket to be handled by ManageSubscriptions()

func (*BTSE) GetAccountBalance

func (b *BTSE) GetAccountBalance() ([]CurrencyBalance, error)

GetAccountBalance returns the users account balance

func (*BTSE) GetActiveOrders

func (b *BTSE) GetActiveOrders(req *order.GetOrdersRequest) ([]order.Detail, error)

GetActiveOrders retrieves any orders that are active/open

func (*BTSE) GetDefaultConfig

func (b *BTSE) GetDefaultConfig() (*config.ExchangeConfig, error)

GetDefaultConfig returns a default exchange config

func (*BTSE) GetDepositAddress

func (b *BTSE) GetDepositAddress(cryptocurrency currency.Code, accountID string) (string, error)

GetDepositAddress returns a deposit address for a specified currency

func (*BTSE) GetExchangeHistory

func (b *BTSE) GetExchangeHistory(p currency.Pair, assetType asset.Item, timestampStart, timestampEnd time.Time) ([]exchange.TradeHistory, error)

GetExchangeHistory returns historic trade data within the timeframe provided.

func (*BTSE) GetFee

func (b *BTSE) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFee returns an estimate of fee based on type of transaction

func (*BTSE) GetFeeByType

func (b *BTSE) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error)

GetFeeByType returns an estimate of fee based on type of transaction

func (*BTSE) GetFills

func (b *BTSE) GetFills(orderID, symbol, before, after, limit, username string) ([]FilledOrder, error)

GetFills gets all filled orders

func (*BTSE) GetFundingHistory

func (b *BTSE) GetFundingHistory() ([]exchange.FundHistory, error)

GetFundingHistory returns funding history, deposits and withdrawals

func (*BTSE) GetFuturesMarkets

func (b *BTSE) GetFuturesMarkets() ([]FuturesMarket, error)

GetFuturesMarkets returns a list of futures markets available on BTSE

func (*BTSE) GetHistoricCandles

func (b *BTSE) GetHistoricCandles(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandles returns candles between a time period for a set time interval

func (*BTSE) GetHistoricCandlesExtended

func (b *BTSE) GetHistoricCandlesExtended(pair currency.Pair, a asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)

GetHistoricCandlesExtended returns candles between a time period for a set time interval

func (*BTSE) GetMarketStatistics

func (b *BTSE) GetMarketStatistics(symbol string) (*MarketStatistics, error)

GetMarketStatistics gets market statistics for a specificed market

func (*BTSE) GetMarketsSummary

func (b *BTSE) GetMarketsSummary() (*HighLevelMarketData, error)

GetMarketsSummary stores market summary data

func (*BTSE) GetOrderHistory

func (b *BTSE) GetOrderHistory(getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)

GetOrderHistory retrieves account order information Can Limit response to specific order status

func (*BTSE) GetOrderInfo

func (b *BTSE) GetOrderInfo(orderID string) (order.Detail, error)

GetOrderInfo returns information on a current open order

func (*BTSE) GetOrders

func (b *BTSE) GetOrders(symbol string) ([]OpenOrder, error)

GetOrders returns all pending orders

func (*BTSE) GetServerTime

func (b *BTSE) GetServerTime() (*ServerTime, error)

GetServerTime returns the exchanges server time

func (*BTSE) GetSpotMarkets

func (b *BTSE) GetSpotMarkets() ([]SpotMarket, error)

GetSpotMarkets returns a list of spot markets available on BTSE

func (*BTSE) GetTicker

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

GetTicker returns the ticker for a specified symbol

func (*BTSE) GetTrades

func (b *BTSE) GetTrades(symbol string) ([]Trade, error)

GetTrades returns a list of trades for the specified symbol

func (*BTSE) ModifyOrder

func (b *BTSE) ModifyOrder(action *order.Modify) (string, error)

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

func (*BTSE) Run

func (b *BTSE) Run()

Run implements the BTSE wrapper

func (*BTSE) SendAuthenticatedHTTPRequest

func (b *BTSE) SendAuthenticatedHTTPRequest(method, endpoint string, req map[string]interface{}, result interface{}, spotEndpoint bool) error

SendAuthenticatedHTTPRequest sends an authenticated HTTP request to the desired endpoint

func (*BTSE) SendHTTPRequest

func (b *BTSE) SendHTTPRequest(method, endpoint string, result interface{}, spotEndpoint bool) error

SendHTTPRequest sends an HTTP request to the desired endpoint

func (*BTSE) SetDefaults

func (b *BTSE) SetDefaults()

SetDefaults sets the basic defaults for BTSE

func (*BTSE) Setup

func (b *BTSE) Setup(exch *config.ExchangeConfig) error

Setup takes in the supplied exchange configuration details and sets params

func (*BTSE) Start

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

Start starts the BTSE go routine

func (*BTSE) SubmitOrder

func (b *BTSE) SubmitOrder(s *order.Submit) (order.SubmitResponse, error)

SubmitOrder submits a new order

func (*BTSE) Subscribe

func (b *BTSE) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error

Subscribe sends a websocket message to receive data from the channel

func (*BTSE) Unsubscribe

func (b *BTSE) Unsubscribe(channelsToUnsubscribe []stream.ChannelSubscription) error

Unsubscribe sends a websocket message to stop receiving data from the channel

func (*BTSE) UpdateAccountInfo

func (b *BTSE) UpdateAccountInfo() (account.Holdings, error)

UpdateAccountInfo retrieves balances for all enabled currencies for the BTSE exchange

func (*BTSE) UpdateOrderbook

func (b *BTSE) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*BTSE) UpdateTicker

func (b *BTSE) UpdateTicker(p currency.Pair, assetType asset.Item) (*ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*BTSE) UpdateTradablePairs

func (b *BTSE) UpdateTradablePairs(forceUpdate bool) error

UpdateTradablePairs updates the exchanges available pairs and stores them in the exchanges config

func (*BTSE) ValidateCredentials

func (b *BTSE) ValidateCredentials() error

ValidateCredentials validates current credentials used for wrapper functionality

func (*BTSE) WithdrawCryptocurrencyFunds

func (b *BTSE) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted

func (*BTSE) WithdrawFiatFunds

func (b *BTSE) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted

func (*BTSE) WithdrawFiatFundsToInternationalBank

func (b *BTSE) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)

WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted

func (*BTSE) WsAuthenticate

func (b *BTSE) WsAuthenticate() error

WsAuthenticate Send an authentication message to receive auth data

func (*BTSE) WsConnect

func (b *BTSE) WsConnect() error

WsConnect connects the websocket client

type CancelOrder

type CancelOrder struct {
	Code int   `json:"code"`
	Time int64 `json:"time"`
}

CancelOrder stores the cancel order response data

type CurrencyBalance

type CurrencyBalance struct {
	Currency  string  `json:"currency"`
	Total     float64 `json:"total,string"`
	Available float64 `json:"available,string"`
}

CurrencyBalance stores the account info data

type FilledOrder

type FilledOrder struct {
	Price     float64 `json:"price"`
	Amount    float64 `json:"amount"`
	Fee       float64 `json:"fee"`
	Side      string  `json:"side"`
	Tag       string  `json:"tag"`
	ID        int64   `json:"id"`
	TradeID   string  `json:"trade_id"`
	Symbol    string  `json:"symbol"`
	OrderID   string  `json:"order_id"`
	CreatedAt string  `json:"created_at"`
}

FilledOrder stores filled order data

type FuturesMarket

type FuturesMarket struct {
	Symbol              string   `json:"symbol"`
	Last                float64  `json:"last"`
	LowestAsk           float64  `json:"lowestAsk"`
	HighestBid          float64  `json:"highestBid"`
	OpenInterest        float64  `json:"openInterest"`
	OpenInterestUSD     float64  `json:"openInterestUSD"`
	PercentageChange    float64  `json:"percentageChange"`
	Volume              float64  `json:"volume"`
	High24Hr            float64  `json:"high24Hr"`
	Low24Hr             float64  `json:"low24Hr"`
	Base                string   `json:"base"`
	Quote               string   `json:"quote"`
	ContractStart       int64    `json:"contractStart"`
	ContractEnd         int64    `json:"contractEnd"`
	Active              bool     `json:"active"`
	TimeBasedContract   bool     `json:"timeBasedContract"`
	OpenTime            int64    `json:"openTime"`
	CloseTime           int64    `json:"closeTime"`
	StartMatching       int64    `json:"startMatching"`
	InactiveTime        int64    `json:"inactiveTime"`
	FundingRate         float64  `json:"fundingRate"`
	ContractSize        float64  `json:"contractSize"`
	MaxPosition         int64    `json:"maxPosition"`
	MinValidPrice       float64  `json:"minValidPrice"`
	MinPriceIncrement   float64  `json:"minPriceIncrement"`
	MinOrderSize        int32    `json:"minOrderSize"`
	MaxOrderSize        int32    `json:"maxOrderSize"`
	MinRiskLimit        int32    `json:"minRiskLimit"`
	MaxRiskLimit        int32    `json:"maxRiskLimit"`
	MinSizeIncrement    float64  `json:"minSizeIncrement"`
	AvailableSettlement []string `json:"availableSettlement"`
}

FuturesMarket stores market data

type HighLevelMarketData

type HighLevelMarketData map[string]OverviewData

HighLevelMarketData stores market overview data

type MarketStatistics

type MarketStatistics struct {
	Open   float64   `json:"open,string"`
	Low    float64   `json:"low,string"`
	High   float64   `json:"high,string"`
	Close  float64   `json:"close,string"`
	Volume float64   `json:"volume,string"`
	Time   time.Time `json:"time"`
}

MarketStatistics stores market statistics for a particular product

type OpenOrder

type OpenOrder struct {
	Order
	Status string `json:"status"`
}

OpenOrder stores an open order info

type Order

type Order struct {
	ID        string  `json:"id"`
	Type      string  `json:"type"`
	Side      string  `json:"side"`
	Price     float64 `json:"price"`
	Amount    float64 `json:"amount"`
	Tag       string  `json:"tag"`
	Symbol    string  `json:"symbol"`
	CreatedAt string  `json:"created_at"`
}

Order stores the order info

type Orderbook

type Orderbook struct {
	BuyQuote  []QuoteData `json:"buyQuote"`
	SellQuote []QuoteData `json:"sellQuote"`
	Symbol    string      `json:"symbol"`
	Timestamp int64       `json:"timestamp"`
}

Orderbook stores orderbook info

type OverviewData

type OverviewData struct {
	High24Hr         float64 `json:"high24hr,string"`
	HighestBid       float64 `json:"highestbid,string"`
	Last             float64 `json:"last,string"`
	Low24Hr          float64 `json:"low24hr,string"`
	LowestAsk        float64 `json:"lowest_ask,string"`
	PercentageChange float64 `json:"percent_change,string"`
	Volume           float64 `json:"volume,string"`
}

OverviewData stores market overview data

type QuoteData

type QuoteData struct {
	Price float64 `json:"price,string"`
	Size  float64 `json:"size,string"`
}

QuoteData stores quote data

type ServerTime

type ServerTime struct {
	ISO   time.Time `json:"iso"`
	Epoch string    `json:"epoch"`
}

ServerTime stores the server time data

type SpotMarket

type SpotMarket struct {
	Symbol            string  `json:"symbol"`
	ID                string  `json:"id"`
	BaseCurrency      string  `json:"base_currency"`
	QuoteCurrency     string  `json:"quote_currency"`
	BaseMinSize       float64 `json:"base_min_size"`
	BaseMaxSize       float64 `json:"base_max_size"`
	BaseIncrementSize float64 `json:"base_increment_size"`
	QuoteMinPrice     float64 `json:"quote_min_price"`
	QuoteIncrement    float64 `json:"quote_increment"`
	Status            string  `json:"status"`
}

SpotMarket stores market data

type Ticker

type Ticker struct {
	Price  float64 `json:"price,string"`
	Size   float64 `json:"size,string"`
	Bid    float64 `json:"bid,string"`
	Ask    float64 `json:"ask,string"`
	Volume float64 `json:"volume,string"`
	Time   string  `json:"time"`
}

Ticker stores the ticker data

type Trade

type Trade struct {
	SerialID string  `json:"serial_id"`
	Symbol   string  `json:"symbol"`
	Price    float64 `json:"price"`
	Amount   float64 `json:"amount"`
	Time     string  `json:"time"`
	Type     string  `json:"type"`
}

Trade stores trade data

Jump to

Keyboard shortcuts

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