coinut

package
v0.0.0-...-3240a16 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COINUT_API_URL          = "https://api.coinut.com"
	COINUT_API_VERSION      = "1"
	COINUT_INSTRUMENTS      = "inst_list"
	COINUT_TICKER           = "inst_tick"
	COINUT_ORDERBOOK        = "inst_order_book"
	COINUT_TRADES           = "inst_trade"
	COINUT_BALANCE          = "user_balance"
	COINUT_ORDER            = "new_order"
	COINUT_ORDERS           = "new_orders"
	COINUT_ORDERS_OPEN      = "user_open_orders"
	COINUT_ORDER_CANCEL     = "cancel_order"
	COINUT_ORDERS_CANCEL    = "cancel_orders"
	COINUT_TRADE_HISTORY    = "trade_history"
	COINUT_INDEX_TICKER     = "index_tick"
	COINUT_OPTION_CHAIN     = "option_chain"
	COINUT_POSITION_HISTORY = "position_history"
	COINUT_POSITION_OPEN    = "user_open_positions"
)
View Source
const COINUT_WEBSOCKET_URL = "wss://wsapi.coinut.com"

Variables

This section is empty.

Functions

This section is empty.

Types

type COINUT

type COINUT struct {
	exchange.Base
	WebsocketConn *websocket.Conn
	InstrumentMap map[string]int
}

func (*COINUT) CancelOrder

func (c *COINUT) CancelOrder(instrumentID, orderID int) (bool, error)

func (*COINUT) CancelOrders

func (c *COINUT) CancelOrders(orders []CoinutCancelOrders) (CoinutCancelOrdersResponse, error)

func (*COINUT) GetDerivativeInstruments

func (c *COINUT) GetDerivativeInstruments(secType string) (interface{}, error)

func (*COINUT) GetExchangeAccountInfo

func (c *COINUT) GetExchangeAccountInfo() (exchange.AccountInfo, error)

GetExchangeAccountInfo retrieves balances for all enabled currencies for the COINUT exchange

func (*COINUT) GetIndexTicker

func (c *COINUT) GetIndexTicker(asset string) (CoinutIndexTicker, error)

func (*COINUT) GetInstrumentOrderbook

func (c *COINUT) GetInstrumentOrderbook(instrumentID, limit int) (CoinutOrderbook, error)

func (*COINUT) GetInstrumentTicker

func (c *COINUT) GetInstrumentTicker(instrumentID int) (CoinutTicker, error)

func (*COINUT) GetInstruments

func (c *COINUT) GetInstruments() (CoinutInstruments, error)

func (*COINUT) GetOpenOrders

func (c *COINUT) GetOpenOrders(instrumentID int) ([]CoinutOrdersResponse, error)

func (*COINUT) GetOpenPosition

func (c *COINUT) GetOpenPosition(instrumentID int) ([]CoinutOpenPosition, error)

func (*COINUT) GetOptionChain

func (c *COINUT) GetOptionChain(asset, secType string, expiry int64) (CoinutOptionChainResponse, error)

func (*COINUT) GetOrderbookEx

func (c *COINUT) GetOrderbookEx(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

GetOrderbookEx returns orderbook base on the currency pair

func (*COINUT) GetPositionHistory

func (c *COINUT) GetPositionHistory(secType string, start, limit int) (CoinutPositionHistory, error)

func (*COINUT) GetTickerPrice

func (c *COINUT) GetTickerPrice(p pair.CurrencyPair, assetType string) (ticker.Price, error)

GetTickerPrice returns the ticker for a currency pair

func (*COINUT) GetTradeHistory

func (c *COINUT) GetTradeHistory(instrumentID, start, limit int) (CoinutTradeHistory, error)

func (*COINUT) GetTrades

func (c *COINUT) GetTrades(instrumentID int) (CoinutTrades, error)

func (*COINUT) GetUserBalance

func (c *COINUT) GetUserBalance() (CoinutUserBalance, error)

func (*COINUT) NewOrder

func (c *COINUT) NewOrder(instrumentID int, quantity, price float64, buy bool, orderID uint32) (interface{}, error)

func (*COINUT) NewOrders

func (c *COINUT) NewOrders(orders []CoinutOrder) ([]CoinutOrdersBase, error)

func (*COINUT) Run

func (c *COINUT) Run()

Run implements the COINUT wrapper

func (*COINUT) SendAuthenticatedHTTPRequest

func (c *COINUT) SendAuthenticatedHTTPRequest(apiRequest string, params map[string]interface{}, result interface{}) (err error)

func (*COINUT) SetDefaults

func (c *COINUT) SetDefaults()

func (*COINUT) Setup

func (c *COINUT) Setup(exch config.ExchangeConfig)

func (*COINUT) Start

func (c *COINUT) Start()

Start starts the COINUT go routine

func (*COINUT) UpdateOrderbook

func (c *COINUT) UpdateOrderbook(p pair.CurrencyPair, assetType string) (orderbook.Base, error)

UpdateOrderbook updates and returns the orderbook for a currency pair

func (*COINUT) UpdateTicker

func (c *COINUT) UpdateTicker(p pair.CurrencyPair, assetType string) (ticker.Price, error)

UpdateTicker updates and returns the ticker for a currency pair

func (*COINUT) WebsocketClient

func (c *COINUT) WebsocketClient()

type CoinutCancelOrders

type CoinutCancelOrders struct {
	InstrumentID int   `json:"int"`
	OrderID      int64 `json:"order_id"`
}

type CoinutCancelOrdersResponse

type CoinutCancelOrdersResponse struct {
	CoinutGenericResponse
	Results []struct {
		OrderID      int64  `json:"order_id"`
		Status       string `json:"status"`
		InstrumentID int    `json:"inst_id"`
	} `json:"results"`
}

type CoinutCommission

type CoinutCommission struct {
	Currency string  `json:"currency"`
	Amount   float64 `json:"amount,string"`
}

type CoinutGenericResponse

type CoinutGenericResponse struct {
	Nonce     int64    `json:"nonce"`
	Reply     string   `json:"reply"`
	Status    []string `json:"status"`
	TransID   int64    `json:"trans_id"`
	Timestamp int64    `json:"timestamp"`
}

type CoinutIndexTicker

type CoinutIndexTicker struct {
	Asset string  `json:"asset"`
	Price float64 `json:"price,string"`
}

type CoinutInstrumentBase

type CoinutInstrumentBase struct {
	Base          string `json:"base"`
	DecimalPlaces int    `json:"decimal_places"`
	InstID        int    `json:"inst_id"`
	Quote         string `json:"quote"`
}

type CoinutInstruments

type CoinutInstruments struct {
	Instruments map[string][]CoinutInstrumentBase `json:"SPOT"`
}

type CoinutOpenPosition

type CoinutOpenPosition struct {
	PositionID    int              `json:"position_id"`
	Commission    CoinutCommission `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"`
}

type CoinutOption

type CoinutOption 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"`
}

type CoinutOptionChainResponse

type CoinutOptionChainResponse struct {
	ExpiryTime   int64  `json:"expiry_time"`
	SecurityType string `json:"sec_type"`
	Asset        string `json:"asset"`
	Entries      []struct {
		Call   CoinutOption `json:"call"`
		Put    CoinutOption `json:"put"`
		Strike float64      `json:"strike,string"`
	}
}

type CoinutOptionChainUpdate

type CoinutOptionChainUpdate struct {
	CoinutOption
	CoinutGenericResponse
	Asset        string  `json:"asset"`
	ExpiryTime   int64   `json:"expiry_time"`
	SecurityType string  `json:"sec_type"`
	Volume       float64 `json:"volume,string"`
}

type CoinutOrder

type CoinutOrder 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"`
}

type CoinutOrderFilledResponse

type CoinutOrderFilledResponse struct {
	CoinutGenericResponse
	Commission   CoinutCommission    `json:"commission"`
	FillPrice    float64             `json:"fill_price,string"`
	FillQuantity float64             `json:"fill_qty,string"`
	Order        CoinutOrderResponse `json:"order"`
}

type CoinutOrderRejectResponse

type CoinutOrderRejectResponse struct {
	CoinutOrderResponse
	Reasons []string `json:"reasons"`
}

type CoinutOrderResponse

type CoinutOrderResponse 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"`
}

type CoinutOrderbook

type CoinutOrderbook struct {
	Buy          []CoinutOrderbookBase `json:"buy"`
	Sell         []CoinutOrderbookBase `json:"sell"`
	InstrumentID int                   `json:"inst_id"`
	TotalBuy     float64               `json:"total_buy,string"`
	TotalSell    float64               `json:"total_sell,string"`
	TransID      int64                 `json:"trans_id"`
}

type CoinutOrderbookBase

type CoinutOrderbookBase struct {
	Count    int     `json:"count"`
	Price    float64 `json:"price,string"`
	Quantity float64 `json:"qty,string"`
}

type CoinutOrdersBase

type CoinutOrdersBase struct {
	CoinutGenericResponse
	CoinutOrderResponse
}

type CoinutOrdersResponse

type CoinutOrdersResponse struct {
	Data []CoinutOrdersBase
}

type CoinutPositionHistory

type CoinutPositionHistory struct {
	Positions []struct {
		PositionID int `json:"position_id"`
		Records    []struct {
			Commission    CoinutCommission `json:"commission"`
			FillPrice     float64          `json:"fill_price,string,omitempty"`
			TransactionID int              `json:"trans_id"`
			FillQuantity  float64          `json:"fill_qty,omitempty"`
			Position      struct {
				Commission CoinutCommission `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"`
}

type CoinutTicker

type CoinutTicker 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"`
}

type CoinutTradeBase

type CoinutTradeBase struct {
	Price     float64 `json:"price,string"`
	Quantity  float64 `json:"quantity,string"`
	Side      string  `json:"side"`
	Timestamp float64 `json:"timestamp"`
	TransID   int64   `json:"trans_id"`
}

type CoinutTradeHistory

type CoinutTradeHistory struct {
	TotalNumber int64                       `json:"total_number"`
	Trades      []CoinutOrderFilledResponse `json:"trades"`
}

type CoinutTrades

type CoinutTrades struct {
	Trades []CoinutTradeBase `json:"trades"`
}

type CoinutUserBalance

type CoinutUserBalance 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"`
}

Jump to

Keyboard shortcuts

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