README
¶
GoCryptoTrader package Coinut

This coinut 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
Coinut Exchange
Current Features
- Initial generation
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 ¶
- type COINUT
- func (c *COINUT) CancelAllExchangeOrders(p pair.CurrencyPair) error
- func (c *COINUT) CancelExchangeOrder(p pair.CurrencyPair, orderID int64) (int64, error)
- func (c *COINUT) CancelOrder(instrumentID, orderID int) (bool, error)
- func (c *COINUT) CancelOrders(orders []CancelOrders) (CancelOrdersResponse, error)
- func (c *COINUT) GetDerivativeInstruments(secType string) (interface{}, error)
- func (c *COINUT) GetExchangeAccountInfo() (exchange.AccountInfo, error)
- func (c *COINUT) GetExchangeDepositAddress(p pair.CurrencyPair) (string, error)
- func (c *COINUT) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)
- func (c *COINUT) GetExchangeOrderInfo(orderID int64) (float64, error)
- func (c *COINUT) GetIndexTicker(asset string) (IndexTicker, error)
- func (c *COINUT) GetInstrumentOrderbook(instrumentID, limit int) (Orderbook, error)
- func (c *COINUT) GetInstrumentTicker(instrumentID int) (Ticker, error)
- func (c *COINUT) GetInstruments() (Instruments, error)
- func (c *COINUT) GetOpenOrders(instrumentID int) ([]OrdersResponse, error)
- func (c *COINUT) GetOpenPositions(instrumentID int) ([]OpenPosition, error)
- func (c *COINUT) GetOptionChain(asset, secType string, expiry int64) (OptionChainResponse, error)
- func (c *COINUT) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error)
- func (c *COINUT) GetPositionHistory(secType string, start, limit int) (PositionHistory, error)
- func (c *COINUT) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)
- func (c *COINUT) GetTradeHistory(instrumentID, start, limit int) (TradeHistory, error)
- func (c *COINUT) GetTrades(instrumentID int) (Trades, error)
- func (c *COINUT) GetUserBalance() (UserBalance, error)
- func (c *COINUT) ModifyExchangeOrder(p pair.CurrencyPair, orderID, action int64) (int64, error)
- func (c *COINUT) NewOrder(instrumentID int, quantity, price float64, buy bool, orderID uint32) (interface{}, error)
- func (c *COINUT) NewOrders(orders []Order) ([]OrdersBase, error)
- func (c *COINUT) Run()
- func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{}, authenticated bool, ...) (err error)
- func (c *COINUT) SetDefaults()
- func (c *COINUT) Setup(exch config.ExchangeConfig)
- func (c *COINUT) Start(wg *sync.WaitGroup)
- func (c *COINUT) SubmitExchangeOrder(p pair.CurrencyPair, side string, orderType int, amount, price float64) (int64, error)
- func (c *COINUT) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)
- func (c *COINUT) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)
- func (c *COINUT) WebsocketClient()
- func (c *COINUT) WithdrawExchangeFunds(address string, p pair.CurrencyPair, amount float64) (string, error)
- type CancelOrders
- type CancelOrdersResponse
- type Commission
- type GenericResponse
- type IndexTicker
- type InstrumentBase
- type Instruments
- type OpenPosition
- type Option
- type OptionChainResponse
- type OptionChainUpdate
- type Order
- type OrderFilledResponse
- type OrderRejectResponse
- type OrderResponse
- type Orderbook
- type OrderbookBase
- type OrdersBase
- type OrdersResponse
- type PositionHistory
- type Ticker
- type TradeBase
- type TradeHistory
- type Trades
- type UserBalance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type COINUT ¶
COINUT is the overarching type across the coinut package
func (*COINUT) CancelAllExchangeOrders ¶
func (c *COINUT) CancelAllExchangeOrders(p pair.CurrencyPair) error
CancelAllExchangeOrders cancels all orders associated with a currency pair
func (*COINUT) CancelExchangeOrder ¶
CancelExchangeOrder cancels an order by its corresponding ID number
func (*COINUT) CancelOrder ¶
CancelOrder cancels a specific order and returns if it was actioned
func (*COINUT) CancelOrders ¶
func (c *COINUT) CancelOrders(orders []CancelOrders) (CancelOrdersResponse, error)
CancelOrders cancels multiple orders
func (*COINUT) GetDerivativeInstruments ¶
GetDerivativeInstruments returns a list of derivative instruments
func (*COINUT) GetExchangeAccountInfo ¶
GetExchangeAccountInfo retrieves balances for all enabled currencies for the COINUT exchange
func (*COINUT) GetExchangeDepositAddress ¶
func (c *COINUT) GetExchangeDepositAddress(p pair.CurrencyPair) (string, error)
GetExchangeDepositAddress returns a deposit address for a specified currency
func (*COINUT) GetExchangeHistory ¶
func (c *COINUT) GetExchangeHistory(p pair.CurrencyPair, assetType string) ([]exchange.TradeHistory, error)
GetExchangeHistory returns historic trade data since exchange opening.
func (*COINUT) GetExchangeOrderInfo ¶
GetExchangeOrderInfo returns information on a current open order
func (*COINUT) GetIndexTicker ¶
func (c *COINUT) GetIndexTicker(asset string) (IndexTicker, error)
GetIndexTicker returns the index ticker for an asset
func (*COINUT) GetInstrumentOrderbook ¶
GetInstrumentOrderbook returns the orderbooks for a specific instrument
func (*COINUT) GetInstrumentTicker ¶
GetInstrumentTicker returns a ticker for a specific instrument
func (*COINUT) GetInstruments ¶
func (c *COINUT) GetInstruments() (Instruments, error)
GetInstruments returns instruments
func (*COINUT) GetOpenOrders ¶
func (c *COINUT) GetOpenOrders(instrumentID int) ([]OrdersResponse, error)
GetOpenOrders returns a list of open order and relevant information
func (*COINUT) GetOpenPositions ¶
func (c *COINUT) GetOpenPositions(instrumentID int) ([]OpenPosition, error)
GetOpenPositions returns all your current opened positions
func (*COINUT) GetOptionChain ¶
func (c *COINUT) GetOptionChain(asset, secType string, expiry int64) (OptionChainResponse, error)
GetOptionChain returns option chain
func (*COINUT) GetOrderbookEx ¶
GetOrderbookEx returns orderbook base on the currency pair
func (*COINUT) GetPositionHistory ¶
func (c *COINUT) GetPositionHistory(secType string, start, limit int) (PositionHistory, error)
GetPositionHistory returns position history
func (*COINUT) GetTickerPrice ¶
GetTickerPrice returns the ticker for a currency pair
func (*COINUT) GetTradeHistory ¶
func (c *COINUT) GetTradeHistory(instrumentID, start, limit int) (TradeHistory, error)
GetTradeHistory returns trade history for a specific instrument.
func (*COINUT) GetUserBalance ¶
func (c *COINUT) GetUserBalance() (UserBalance, error)
GetUserBalance returns the full user balance
func (*COINUT) ModifyExchangeOrder ¶
ModifyExchangeOrder will allow of changing orderbook placement and limit to market conversion
func (*COINUT) NewOrder ¶
func (c *COINUT) NewOrder(instrumentID int, quantity, price float64, buy bool, orderID uint32) (interface{}, error)
NewOrder places a new order on the exchange
func (*COINUT) NewOrders ¶
func (c *COINUT) NewOrders(orders []Order) ([]OrdersBase, error)
NewOrders places multiple orders on the exchange
func (*COINUT) SendHTTPRequest ¶
func (c *COINUT) SendHTTPRequest(apiRequest string, params map[string]interface{}, authenticated bool, result interface{}) (err error)
SendHTTPRequest sends either an authenticated or unauthenticated HTTP request
func (*COINUT) Setup ¶
func (c *COINUT) Setup(exch config.ExchangeConfig)
Setup sets the current exchange configuration
func (*COINUT) SubmitExchangeOrder ¶
func (c *COINUT) SubmitExchangeOrder(p pair.CurrencyPair, side string, orderType int, amount, price float64) (int64, error)
SubmitExchangeOrder submits a new order
func (*COINUT) UpdateOrderbook ¶
UpdateOrderbook updates and returns the orderbook for a currency pair
func (*COINUT) UpdateTicker ¶
UpdateTicker updates and returns the ticker for a currency pair
func (*COINUT) WebsocketClient ¶
func (c *COINUT) WebsocketClient()
WebsocketClient initiates a websocket client
func (*COINUT) WithdrawExchangeFunds ¶
func (c *COINUT) WithdrawExchangeFunds(address string, p pair.CurrencyPair, amount float64) (string, error)
WithdrawExchangeFunds returns a withdrawal ID when a withdrawal is submitted
type CancelOrders ¶
CancelOrders holds information about a cancelled order
type CancelOrdersResponse ¶
type CancelOrdersResponse struct { GenericResponse Results []struct { OrderID int64 `json:"order_id"` Status string `json:"status"` InstrumentID int `json:"inst_id"` } `json:"results"` }
CancelOrdersResponse is response for a cancelled order
type Commission ¶
Commission holds trade commission structure
type GenericResponse ¶
type GenericResponse struct { Nonce int64 `json:"nonce"` Reply string `json:"reply"` Status []string `json:"status"` TransID int64 `json:"trans_id"` Timestamp int64 `json:"timestamp"` }
GenericResponse is the generic response you will get from coinut
type IndexTicker ¶
IndexTicker holds indexed ticker inforamtion
type InstrumentBase ¶
type InstrumentBase struct { Base string `json:"base"` DecimalPlaces int `json:"decimal_places"` InstID int `json:"inst_id"` Quote string `json:"quote"` }
InstrumentBase holds information on base currency
type Instruments ¶
type Instruments struct {
Instruments map[string][]InstrumentBase `json:"SPOT"`
}
Instruments holds the full information on base currencies
type OpenPosition ¶
type OpenPosition struct { PositionID int `json:"position_id"` Commission Commission `json:"commission"` OpenPrice float64 `json:"open_price,string"` RealizedPL float64 `json:"realized_pl,string"` Quantity float64 `json:"qty,string"` OpenTimestamp int64 `json:"open_timestamp"` InstrumentID int `json:"inst_id"` }
OpenPosition holds information on an open position
type Option ¶
type Option struct { HighestBuy float64 `json:"highest_buy,string"` InstrumentID int `json:"inst_id"` Last float64 `json:"last,string"` LowestSell float64 `json:"lowest_sell,string"` OpenInterest float64 `json:"open_interest,string"` }
Option holds options information
type OptionChainResponse ¶
type OptionChainResponse struct { ExpiryTime int64 `json:"expiry_time"` SecurityType string `json:"sec_type"` Asset string `json:"asset"` Entries []struct { Call Option `json:"call"` Put Option `json:"put"` Strike float64 `json:"strike,string"` } }
OptionChainResponse is the response type for options
type OptionChainUpdate ¶
type OptionChainUpdate struct { Option GenericResponse Asset string `json:"asset"` ExpiryTime int64 `json:"expiry_time"` SecurityType string `json:"sec_type"` Volume float64 `json:"volume,string"` }
OptionChainUpdate contains information on the chain update options
type Order ¶
type Order struct { InstrumentID int64 `json:"inst_id"` Price float64 `json:"price,string"` Quantity float64 `json:"qty,string"` ClientOrderID int `json:"client_ord_id"` Side string `json:"side,string"` }
Order holds order information
type OrderFilledResponse ¶
type OrderFilledResponse struct { GenericResponse Commission Commission `json:"commission"` FillPrice float64 `json:"fill_price,string"` FillQuantity float64 `json:"fill_qty,string"` Order OrderResponse `json:"order"` }
OrderFilledResponse contains order filled response
type OrderRejectResponse ¶
type OrderRejectResponse struct { OrderResponse Reasons []string `json:"reasons"` }
OrderRejectResponse holds information on a rejected order
type OrderResponse ¶
type OrderResponse struct { OrderID int64 `json:"order_id"` OpenQuantity float64 `json:"open_qty,string"` Price float64 `json:"price,string"` Quantity float64 `json:"qty,string"` InstrumentID int64 `json:"inst_id"` ClientOrderID int64 `json:"client_ord_id"` Timestamp int64 `json:"timestamp"` OrderPrice float64 `json:"order_price,string"` Side string `json:"side"` }
OrderResponse is a response for orders
type Orderbook ¶
type Orderbook struct { Buy []OrderbookBase `json:"buy"` Sell []OrderbookBase `json:"sell"` InstrumentID int `json:"inst_id"` TotalBuy float64 `json:"total_buy,string"` TotalSell float64 `json:"total_sell,string"` TransID int64 `json:"trans_id"` }
Orderbook is the full order book
type OrderbookBase ¶
type OrderbookBase struct { Count int `json:"count"` Price float64 `json:"price,string"` Quantity float64 `json:"qty,string"` }
OrderbookBase is a sub-type holding price and quantity
type OrdersBase ¶
type OrdersBase struct { GenericResponse OrderResponse }
OrdersBase contains generic response and order responses
type OrdersResponse ¶
type OrdersResponse struct {
Data []OrdersBase
}
OrdersResponse holds the full data range on orders
type PositionHistory ¶
type PositionHistory struct { Positions []struct { PositionID int `json:"position_id"` Records []struct { Commission Commission `json:"commission"` FillPrice float64 `json:"fill_price,string,omitempty"` TransactionID int `json:"trans_id"` FillQuantity float64 `json:"fill_qty,omitempty"` Position struct { Commission Commission `json:"commission"` Timestamp int64 `json:"timestamp"` OpenPrice float64 `json:"open_price,string"` RealizedPL float64 `json:"realized_pl,string"` Quantity float64 `json:"qty,string"` } `json:"position"` AssetAtExpiry float64 `json:"asset_at_expiry,string,omitempty"` } `json:"records"` Instrument struct { ExpiryTime int64 `json:"expiry_time"` ContractSize float64 `json:"contract_size,string"` ConversionRate float64 `json:"conversion_rate,string"` OptionType string `json:"option_type"` InstrumentID int `json:"inst_id"` SecType string `json:"sec_type"` Asset string `json:"asset"` Strike float64 `json:"strike,string"` } `json:"inst"` OpenTimestamp int64 `json:"open_timestamp"` } `json:"positions"` TotalNumber int `json:"total_number"` }
PositionHistory holds the complete position history
type Ticker ¶
type Ticker struct { HighestBuy float64 `json:"highest_buy,string"` InstrumentID int `json:"inst_id"` Last float64 `json:"last,string"` LowestSell float64 `json:"lowest_sell,string"` OpenInterest float64 `json:"open_interest,string"` Timestamp float64 `json:"timestamp"` TransID int64 `json:"trans_id"` Volume float64 `json:"volume,string"` Volume24 float64 `json:"volume24,string"` }
Ticker holds ticker information
type TradeBase ¶
type TradeBase struct { Price float64 `json:"price,string"` Quantity float64 `json:"quantity,string"` Side string `json:"side"` Timestamp float64 `json:"timestamp"` TransID int64 `json:"trans_id"` }
TradeBase is a sub-type holding information on trades
type TradeHistory ¶
type TradeHistory struct { TotalNumber int64 `json:"total_number"` Trades []OrderFilledResponse `json:"trades"` }
TradeHistory holds trade history information
type Trades ¶
type Trades struct {
Trades []TradeBase `json:"trades"`
}
Trades holds the full amount of trades associated with API keys
type UserBalance ¶
type UserBalance struct { BTC float64 `json:"btc,string"` ETC float64 `json:"etc,string"` ETH float64 `json:"eth,string"` LTC float64 `json:"ltc,string"` Equity float64 `json:"equity,string,string"` InitialMargin float64 `json:"initial_margin,string"` MaintenanceMargin float64 `json:"maintenance_margin,string"` RealizedPL float64 `json:"realized_pl,string"` TransID int64 `json:"trans_id"` UnrealizedPL float64 `json:"unrealized_pl,string"` }
UserBalance holds user balances on the exchange