api

package
v0.0.0-...-9ec5fe9 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: GPL-3.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const MaxBarsCount = 200

Variables

View Source
var CacheService common.IKVStore
View Source
var QueueService common.IQueue

Functions

func BuildOrder

func BuildOrder(p Param) (interface{}, error)

func CancelOrder

func CancelOrder(p Param) (interface{}, error)

func GetAccountTrades

func GetAccountTrades(p Param) (interface{}, error)

func GetAllTrades

func GetAllTrades(p Param) (interface{}, error)

func GetFees

func GetFees(p Param) (interface{}, error)

func GetLockedBalance

func GetLockedBalance(p Param) (interface{}, error)

func GetMarkets

func GetMarkets(_ Param) (interface{}, error)

func GetOrderBook

func GetOrderBook(p Param) (interface{}, error)

func GetOrders

func GetOrders(p Param) (interface{}, error)

func GetSingleOrder

func GetSingleOrder(p Param) (interface{}, error)

func GetTradingView

func GetTradingView(p Param) (interface{}, error)

func PlaceOrder

func PlaceOrder(p Param) (interface{}, error)

func StartServer

func StartServer(ctx context.Context, startMetric func())

Types

type ApiError

type ApiError struct {
	Code int
	Desc string
}

func BindError

func BindError() *ApiError

func InvalidPriceAmountError

func InvalidPriceAmountError() *ApiError

func MarketNotFoundError

func MarketNotFoundError(marketID string) *ApiError

func NewApiError

func NewApiError(code int, desc string) *ApiError

func ValidationError

func ValidationError(message string) *ApiError

func (*ApiError) Error

func (e *ApiError) Error() string

type Bar

type Bar struct {
	Time   int64           `json:"time"`
	Open   decimal.Decimal `json:"open"`
	Close  decimal.Decimal `json:"close"`
	Low    decimal.Decimal `json:"low"`
	High   decimal.Decimal `json:"high"`
	Volume decimal.Decimal `json:"volume"`
}

func BuildTradingViewByTrades

func BuildTradingViewByTrades(trades []*models.Trade, granularity int64) []*Bar

type BaseReq

type BaseReq struct {
	Address string `json:"address"`
}

func (*BaseReq) GetAddress

func (b *BaseReq) GetAddress() string

func (*BaseReq) SetAddress

func (b *BaseReq) SetAddress(address string)

type BaseResp

type BaseResp struct {
	Status int    `json:"status"`
	Desc   string `json:"desc"`
}

type BuildOrderReq

type BuildOrderReq struct {
	BaseReq
	MarketID  string `json:"marketID"  validate:"required"`
	Side      string `json:"side"      validate:"required,oneof=buy sell"`
	OrderType string `json:"orderType" validate:"required,oneof=limit market"`
	Price     string `json:"price"     validate:"required"`
	Amount    string `json:"amount"    validate:"required"`
	Expires   int64  `json:"expires"`
}

type BuildOrderResp

type BuildOrderResp struct {
	ID              string            `json:"id"`
	MarketID        string            `json:"marketID"`
	Side            string            `json:"side"`
	Type            string            `json:"type"`
	Price           decimal.Decimal   `json:"price"`
	Amount          decimal.Decimal   `json:"amount"`
	Json            *models.OrderJSON `json:"json"`
	AsMakerFeeRate  decimal.Decimal   `json:"asMakerFeeRate"`
	AsTakerFeeRate  decimal.Decimal   `json:"asTakerFeeRate"`
	MakerRebateRate decimal.Decimal   `json:"makerRebateRate"`
	GasFeeAmount    decimal.Decimal   `json:"gasFeeAmount"`
}

func BuildAndCacheOrder

func BuildAndCacheOrder(address string, order *BuildOrderReq) (*BuildOrderResp, error)

type CacheOrder

type CacheOrder struct {
	OrderResponse         BuildOrderResp  `json:"orderResponse"`
	Address               string          `json:"address"`
	BalanceOfTokenToOffer decimal.Decimal `json:"balanceOfTokenToOffer"`
}

type CancelOrderReq

type CancelOrderReq struct {
	BaseReq
	ID string `json:"id" param:"orderID" validate:"required,len=66"`
}

type CandlesReq

type CandlesReq struct {
	BaseReq
	MarketID    string `json:"marketID"    param:"marketID"    validate:"required"`
	From        int64  `json:"from"        query:"from"        validate:"required"`
	To          int64  `json:"to"          query:"to"          validate:"required"`
	Granularity int64  `json:"granularity" query:"granularity" validate:"required"`
}

type CandlesResp

type CandlesResp struct {
	BaseResp
	Data interface{}
}

type FeesReq

type FeesReq struct {
	BaseReq
	MarketID string `json:"marketID" query:"marketID" validate:"required"`
	Price    string `json:"price" query:"price"       validate:"required"`
	Amount   string `json:"amount" query:"amount"     validate:"required"`
}

type FeesResp

type FeesResp struct {
	GasFeeAmount          decimal.Decimal `json:"gasFeeAmount"`
	AsMakerTotalFeeAmount decimal.Decimal `json:"asMakerTotalFeeAmount"`
	AsMakerTradeFeeAmount decimal.Decimal `json:"asMakerTradeFeeAmount"`
	AsMakerFeeRate        decimal.Decimal `json:"asMakerFeeRate"`
	AsTakerTotalFeeAmount decimal.Decimal `json:"asTakerTotalFeeAmount"`
	AsTakerTradeFeeAmount decimal.Decimal `json:"asTakerTradeFeeAmount"`
	AsTakerFeeRate        decimal.Decimal `json:"asTakerFeeRate"`
}

type LockedBalance

type LockedBalance struct {
	Symbol        string          `json:"symbol"`
	LockedBalance decimal.Decimal `json:"lockedBalance"`
}

type LockedBalanceReq

type LockedBalanceReq struct {
	BaseReq
}

type LockedBalanceResp

type LockedBalanceResp struct {
	LockedBalances []LockedBalance `json:"lockedBalances"`
}

type Market

type Market struct {
	ID                     string          `json:"id"`
	BaseToken              string          `json:"baseToken"`
	BaseTokenProjectUrl    string          `json:"baseTokenProjectUrl"`
	BaseTokenName          string          `json:"baseTokenName"`
	BaseTokenDecimals      int             `json:"baseTokenDecimals"`
	BaseTokenAddress       string          `json:"baseTokenAddress"`
	QuoteToken             string          `json:"quoteToken"`
	QuoteTokenDecimals     int             `json:"quoteTokenDecimals"`
	QuoteTokenAddress      string          `json:"quoteTokenAddress"`
	MinOrderSize           decimal.Decimal `json:"minOrderSize"`
	PricePrecision         int             `json:"pricePrecision"`
	PriceDecimals          int             `json:"priceDecimals"`
	AmountDecimals         int             `json:"amountDecimals"`
	AsMakerFeeRate         decimal.Decimal `json:"asMakerFeeRate"`
	AsTakerFeeRate         decimal.Decimal `json:"asTakerFeeRate"`
	GasFeeAmount           decimal.Decimal `json:"gasFeeAmount"`
	SupportedOrderTypes    []string        `json:"supportedOrderTypes"`
	MarketOrderMaxSlippage decimal.Decimal `json:"marketOrderMaxSlippage"`
	MarketStatus
}

type MarketStatus

type MarketStatus struct {
	LastPriceIncrease   decimal.Decimal `json:"lastPriceIncrease"`
	LastPrice           decimal.Decimal `json:"lastPrice"`
	Price24h            decimal.Decimal `json:"price24h"`
	Amount24h           decimal.Decimal `json:"amount24h"`
	QuoteTokenVolume24h decimal.Decimal `json:"quoteTokenVolume24h"`
}

func GetMarketStatus

func GetMarketStatus(marketID string) *MarketStatus

type MarketsReq

type MarketsReq struct {
	BaseReq
}

type MarketsResp

type MarketsResp struct {
	BaseResp
	Markets []Market `json:"markets"`
	Count   int64    `json:"count"`
}

type OrderBook

type OrderBook struct {
	Bids [][2]string `json:"bids"`
	Asks [][2]string `json:"asks"`
}

type OrderBookReq

type OrderBookReq struct {
	BaseReq
	MarketID string `json:"marketID" param:"marketID" validate:"required"`
}

type OrderBookResp

type OrderBookResp struct {
	BaseResp
	Data OrderBook
}

type Param

type Param interface {
	GetAddress() string
	SetAddress(address string)
}

type PlaceOrderReq

type PlaceOrderReq struct {
	BaseReq
	ID        string `json:"orderID"   validate:"required,len=66"`
	Signature string `json:"signature" validate:"required"`
}

type QueryOrderReq

type QueryOrderReq struct {
	BaseReq
	MarketID string `json:"marketID" query:"marketID" validate:"required"`
	Status   string `json:"status"   query:"status"`
	Page     int    `json:"page"     query:"page"`
	PerPage  int    `json:"perPage"  query:"perPage"`
}

type QueryOrderResp

type QueryOrderResp struct {
	Count  int64           `json:"count"`
	Orders []*models.Order `json:"orders"`
}

type QuerySingleOrderReq

type QuerySingleOrderReq struct {
	BaseReq
	OrderID string `json:"orderID" param:"orderID" validate:"required"`
}

type QuerySingleOrderResp

type QuerySingleOrderResp struct {
	Order *models.Order `json:"order"`
}

type QueryTradeReq

type QueryTradeReq struct {
	BaseReq
	MarketID string `json:"marketID" param:"marketID" validate:"required"`
	Status   string `json:"status"   query:"status"`
	Page     int    `json:"page"     query:"page"`
	PerPage  int    `json:"perPage"  query:"perPage"`
}

type QueryTradeResp

type QueryTradeResp struct {
	Count  int64           `json:"count"`
	Trades []*models.Trade `json:"trades"`
}

type Response

type Response struct {
	Status int         `json:"status"`
	Desc   string      `json:"desc"`
	Data   interface{} `json:"data,omitempty"`
}

type SnapshotV2

type SnapshotV2 struct {
	Sequence uint64      `json:"sequence"`
	Bids     [][2]string `json:"bids"`
	Asks     [][2]string `json:"asks"`
}

Jump to

Keyboard shortcuts

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