coinut

package
v0.0.0-...-b8e8dbd Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: MIT Imports: 15 Imported by: 0

README

GoCryptoTrader package Coinut

Build Status Software License GoDoc Coverage Status Go Report Card

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

Constants

This section is empty.

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
}

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

func (c *COINUT) CancelExchangeOrder(p pair.CurrencyPair, orderID int64) (int64, error)

CancelExchangeOrder cancels an order by its corresponding ID number

func (*COINUT) CancelOrder

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

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

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

GetDerivativeInstruments returns a list of derivative instruments

func (*COINUT) GetExchangeAccountInfo

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

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

func (c *COINUT) GetExchangeOrderInfo(orderID int64) (float64, error)

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

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

GetInstrumentOrderbook returns the orderbooks for a specific instrument

func (*COINUT) GetInstrumentTicker

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

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

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) (PositionHistory, error)

GetPositionHistory returns position history

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) (TradeHistory, error)

GetTradeHistory returns trade history for a specific instrument.

func (*COINUT) GetTrades

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

GetTrades returns trade information

func (*COINUT) GetUserBalance

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

GetUserBalance returns the full user balance

func (*COINUT) ModifyExchangeOrder

func (c *COINUT) ModifyExchangeOrder(p pair.CurrencyPair, orderID, action int64) (int64, error)

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) Run

func (c *COINUT) Run()

Run implements the COINUT wrapper

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) SetDefaults

func (c *COINUT) SetDefaults()

SetDefaults sets current default values

func (*COINUT) Setup

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

Setup sets the current exchange configuration

func (*COINUT) Start

func (c *COINUT) Start(wg *sync.WaitGroup)

Start starts the COINUT go routine

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

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()

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

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

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

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

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

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

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

Jump to

Keyboard shortcuts

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