Documentation ¶
Overview ¶
nolint
nolint
nolint
Index ¶
- Constants
- func GetAllKlineMap() map[int]string
- func GetChannelByKlineType(klineType string) string
- func GetFreqByKlineType(klineType string) int
- func GetKlineTableNameByFreq(freq int) string
- func MustNewKlineFactory(name string, baseK *BaseKline) (r interface{})
- func NewErrorsMerged(args ...error) error
- func NewKlineFactory(name string, baseK *BaseKline) (r interface{}, err error)
- func NewKlinesFactory(name string) (r interface{}, err error)
- func PrintStackIfPanic()
- func TimeString(ts int64) string
- func ToRestfulData(klines *[]IKline, limit int) [][]string
- type BaseKline
- func (b *BaseKline) FormatResult() interface{}
- func (b *BaseKline) GetAnchorTimeTS(ts int64) int64
- func (b *BaseKline) GetBriefInfo() []string
- func (b *BaseKline) GetChannelInfo() (channel, filter string, err error)
- func (b *BaseKline) GetClose() float64
- func (b *BaseKline) GetFreqInSecond() int
- func (b *BaseKline) GetFullChannel() string
- func (b *BaseKline) GetHigh() float64
- func (b *BaseKline) GetLow() float64
- func (b *BaseKline) GetOpen() float64
- func (b *BaseKline) GetProduct() string
- func (b *BaseKline) GetTableName() string
- func (b *BaseKline) GetTimestamp() int64
- func (b *BaseKline) GetVolume() float64
- func (b *BaseKline) PrettyTimeString() string
- type Deal
- type DexFees
- type DexKeeper
- type ErrorsMerged
- type FakeWSEvent
- type IKline
- type IKlines
- type IKlinesDsc
- type IWebsocket
- type InstrumentV2
- type KlineM1
- type KlineM10080
- type KlineM120
- type KlineM1440
- type KlineM15
- type KlineM240
- type KlineM3
- type KlineM30
- type KlineM360
- type KlineM4320
- type KlineM44640
- type KlineM5
- type KlineM525600
- type KlineM60
- type KlineM720
- type MarketKeeper
- type MatchResult
- type MergedTickersEvent
- type Order
- type OrderKeeper
- type OrderV2
- type QueryDealsParams
- type QueryDealsParamsV2
- type QueryDexFeesParams
- type QueryFeeDetailsParams
- type QueryFeeDetailsParamsV2
- type QueryKlinesParams
- type QueryMatchParams
- type QueryMatchParamsV2
- type QueryOrderListParams
- type QueryOrderParamsV2
- type QueryTickerParams
- type QueryTxListParams
- type QueryTxListParamsV2
- type Ticker
- type TickerV2
- type Tickers
- type TokenKeeper
- type Transaction
Constants ¶
const ( // ModuleName is the name of the backend module ModuleName = "backend" // QuerierRoute is the querier route for the backend module QuerierRoute = ModuleName // RouterKey is the msg router key for the backend module RouterKey = "" // query endpoints supported by the backend querier QueryMatchResults = "matches" QueryDealList = "deals" QueryFeeDetails = "fees" QueryOrderList = "orders" QueryTxList = "txs" QueryCandleList = "candles" QueryTickerList = "tickers" QueryDexFeesList = "dexFees" // v2 QueryTickerListV2 = "tickerListV2" QueryTickerV2 = "tickerV2" QueryInstrumentsV2 = "instrumentsV2" QueryOrderListV2 = "orderListV2" QueryOrderV2 = "orderV2" QueryCandleListV2 = "candlesV2" QueryMatchResultsV2 = "matchesV2" QueryFeeDetailsV2 = "feesV2" QueryDealListV2 = "dealsV2" QueryTxListV2 = "txsV2" Kline1GoRoutineWaitInSecond = 5 KlinexGoRoutineWaitInSecond = 10 SecondsInADay = 24 * 60 * 60 )
const ( KlineTypeM1 = "kline_m1" KlineTypeM3 = "kline_m3" KlineTypeM5 = "kline_m5" KlineTypeM15 = "kline_m15" KlineTypeM30 = "kline_m30" KlineTypeM60 = "kline_m60" KlineTypeM120 = "kline_m120" KlineTypeM240 = "kline_m240" KlineTypeM360 = "kline_m360" KlineTypeM720 = "kline_m720" KlineTypeM1440 = "kline_m1440" KlineTypeM4320 = "kline_m4320" KlineTypeM10080 = "kline_m10080" KlineTypeM44640 = "kline_m44640" KlineTypeM525600 = "kline_m525600" )
const ( DefaultPage = 1 DefaultPerPage = 50 )
nolint
const ( TxTypeTransfer = 1 TxTypeOrderNew = 2 TxTypeOrderCancel = 3 TxSideBuy = 1 TxSideSell = 2 TxSideFrom = 3 TxSideTo = 4 BuyOrder = orderTypes.BuyOrder SellOrder = orderTypes.SellOrder TestTokenPair = orderTypes.TestTokenPair FeeTypeOrderNew = orderTypes.FeeTypeOrderNew FeeTypeOrderCancel = orderTypes.FeeTypeOrderCancel FeeTypeOrderExpire = orderTypes.FeeTypeOrderExpire FeeTypeOrderDeal = orderTypes.FeeTypeOrderDeal FeeTypeOrderReceive = orderTypes.FeeTypeOrderReceive )
const WebsocketChanCapacity = 2048
Variables ¶
This section is empty.
Functions ¶
func GetAllKlineMap ¶
GetAllKlineMap return map about kline table names
func GetChannelByKlineType ¶
func GetFreqByKlineType ¶
func GetKlineTableNameByFreq ¶
GetKlineTableNameByFreq return table name
func MustNewKlineFactory ¶
MustNewKlineFactory will panic when err occurred during NewKlineFactory
func NewErrorsMerged ¶
NewErrorsMerged plenty of errors into a single error.
func NewKlineFactory ¶
NewKlineFactory generate kline type by factory pattern
func NewKlinesFactory ¶
NewKlinesFactory generate kline type by type of kline
Types ¶
type BaseKline ¶
type BaseKline struct { Product string `gorm:"PRIMARY_KEY;type:varchar(20)" json:"product"` Timestamp int64 `gorm:"PRIMARY_KEY;type:bigint;" json:"timestamp"` Open float64 `gorm:"type:DOUBLE" json:"open"` Close float64 `gorm:"type:DOUBLE" json:"close"` High float64 `gorm:"type:DOUBLE" json:"high"` Low float64 `gorm:"type:DOUBLE" json:"low"` Volume float64 `gorm:"type:DOUBLE" json:"volume"` // contains filtered or unexported fields }
BaseKline define the basic data of Kine
func (*BaseKline) FormatResult ¶
func (b *BaseKline) FormatResult() interface{}
func (*BaseKline) GetAnchorTimeTS ¶
GetAnchorTimeTS return time interval
func (*BaseKline) GetBriefInfo ¶
GetBriefInfo return array of kline data
func (*BaseKline) GetChannelInfo ¶
func (*BaseKline) GetFreqInSecond ¶
GetFreqInSecond return interval time
func (*BaseKline) GetFullChannel ¶
func (*BaseKline) GetTableName ¶
GetTableName rerurn database table name
func (*BaseKline) GetTimestamp ¶
GetTimestamp return timestamp
func (*BaseKline) PrettyTimeString ¶
PrettyTimeString convert kline data to string
type Deal ¶
type Deal struct { Timestamp int64 `gorm:"index;" json:"timestamp" v2:"timestamp"` BlockHeight int64 `gorm:"PRIMARY_KEY;type:bigint" json:"block_height" v2:"block_height"` OrderID string `gorm:"PRIMARY_KEY;type:varchar(30)" json:"order_id" v2:"order_id"` Sender string `gorm:"index;type:varchar(80)" json:"sender" v2:"sender"` Product string `gorm:"index;type:varchar(20)" json:"product" v2:"product"` Side string `gorm:"type:varchar(10)" json:"side" v2:"side"` Price float64 `gorm:"type:DOUBLE" json:"price" v2:"price"` Quantity float64 `gorm:"type:DOUBLE" json:"volume" v2:"volume"` Fee string `gorm:"type:varchar(20)" json:"fee" v2:"fee"` FeeReceiver string `gorm:"index;type:varchar(80)" json:"fee_receiver" v2:"fee_receiver"` }
type DexKeeper ¶
type DexKeeper interface { GetTokenPairs(ctx sdk.Context) []*dextypes.TokenPair GetTokenPair(ctx sdk.Context, product string) *dextypes.TokenPair SetObserverKeeper(keeper exported.StreamKeeper) }
DexKeeper expected dex keeper
type FakeWSEvent ¶
type FakeWSEvent struct {
// contains filtered or unexported fields
}
FakeWSEvent won't result in sending out tendermint event
func NewFakeWSEvent ¶
func NewFakeWSEvent(channel, filter string, ts int64) *FakeWSEvent
func (*FakeWSEvent) FormatResult ¶
func (f *FakeWSEvent) FormatResult() interface{}
func (*FakeWSEvent) GetChannelInfo ¶
func (f *FakeWSEvent) GetChannelInfo() (channel, filter string, err error)
func (*FakeWSEvent) GetFullChannel ¶
func (f *FakeWSEvent) GetFullChannel() string
func (*FakeWSEvent) GetTimestamp ¶
func (f *FakeWSEvent) GetTimestamp() int64
type IKline ¶
type IKline interface { GetFreqInSecond() int GetAnchorTimeTS(ts int64) int64 GetTableName() string GetProduct() string GetTimestamp() int64 GetOpen() float64 GetClose() float64 GetHigh() float64 GetLow() float64 GetVolume() float64 PrettyTimeString() string GetBriefInfo() []string }
nolint
func ToIKlinesArray ¶
ToIKlinesArray Convert kline data to array for restful interface
type IWebsocket ¶
type InstrumentV2 ¶
type InstrumentV2 struct { InstrumentID string `json:"instrument_id"` // name of token pair BaseCurrency string `json:"base_currency"` QuoteCurrency string `json:"quote_currency"` MinSize string `json:"min_size"` SizeIncrement string `json:"size_increment"` TickSize string `json:"tick_size"` }
func ConvertTokenPairToInstrumentV2 ¶
func ConvertTokenPairToInstrumentV2(tokenPair *dex.TokenPair) *InstrumentV2
ConvertTokenPairToInstrumentV2 convert TokenPair to InstrumentV2
type KlineM10080 ¶
type KlineM10080 struct {
*BaseKline
}
KlineM10080 define kline data in 1 week
func NewKlineM10080 ¶
func NewKlineM10080(b *BaseKline) *KlineM10080
NewKlineM10080 create a instance of NewKlineM10080
func (*KlineM10080) GetFreqInSecond ¶
func (k *KlineM10080) GetFreqInSecond() int
GetFreqInSecond return 604800
func (*KlineM10080) GetTableName ¶
func (k *KlineM10080) GetTableName() string
GetTableName return kline_m10080
type KlineM120 ¶
type KlineM120 struct {
*BaseKline
}
KlineM120 define kline data in 2 hours
func NewKlineM120 ¶
NewKlineM120 create a instance of KlineM120
func (*KlineM120) GetFreqInSecond ¶
GetFreqInSecond return 7200
func (*KlineM120) GetTableName ¶
GetTableName return kline_m120
type KlineM1440 ¶
type KlineM1440 struct {
*BaseKline
}
KlineM1440 define kline data in 1 day
func NewKlineM1440 ¶
func NewKlineM1440(b *BaseKline) *KlineM1440
NewKlineM1440 create a instance of NewKlineM1440
func (*KlineM1440) GetFreqInSecond ¶
func (k *KlineM1440) GetFreqInSecond() int
GetFreqInSecond return 86400
func (*KlineM1440) GetTableName ¶
func (k *KlineM1440) GetTableName() string
GetTableName return kline_m1440
type KlineM15 ¶
type KlineM15 struct {
*BaseKline
}
KlineM15 define kline data in 15 minutes
func NewKlineM15 ¶
NewKlineM15 create a instance of KlineM15
func (*KlineM15) GetFreqInSecond ¶
GetFreqInSecond return 900
func (*KlineM15) GetTableName ¶
GetTableName return kline_m15
type KlineM240 ¶
type KlineM240 struct {
*BaseKline
}
KlineM240 define kline data in 4 hours
func NewKlineM240 ¶
NewKlineM240 create a instance of KlineM240
func (*KlineM240) GetFreqInSecond ¶
GetFreqInSecond return 14400
func (*KlineM240) GetTableName ¶
GetTableName return kline_m240
type KlineM3 ¶
type KlineM3 struct {
*BaseKline
}
KlineM3 define kline data in 3 minutes
func (*KlineM3) GetFreqInSecond ¶
GetFreqInSecond return 180
type KlineM30 ¶
type KlineM30 struct {
*BaseKline
}
KlineM30 define kline data in 30 minutes
func NewKlineM30 ¶
NewKlineM30 create a instance of KlineM30
func (*KlineM30) GetFreqInSecond ¶
GetFreqInSecond return 1800
func (*KlineM30) GetTableName ¶
GetTableName return kline_m30
type KlineM360 ¶
type KlineM360 struct {
*BaseKline
}
KlineM360 define kline data in 6 hours
func NewKlineM360 ¶
NewKlineM360 create a instance of KlineM360
func (*KlineM360) GetFreqInSecond ¶
GetFreqInSecond return 21600
func (*KlineM360) GetTableName ¶
GetTableName return kline_m360
type KlineM4320 ¶
type KlineM4320 struct {
*BaseKline
}
KlineM4320 define kline data in 1 day
func NewKlineM4320 ¶
func NewKlineM4320(b *BaseKline) *KlineM4320
NewKlineM4320 create a instance of KlineM4320
func (*KlineM4320) GetFreqInSecond ¶
func (k *KlineM4320) GetFreqInSecond() int
GetFreqInSecond return 259200
func (*KlineM4320) GetTableName ¶
func (k *KlineM4320) GetTableName() string
GetTableName return kline_m4320
type KlineM44640 ¶
type KlineM44640 struct {
*BaseKline
}
KlineM44640 define kline data in 1 day
func NewKlineM44640 ¶
func NewKlineM44640(b *BaseKline) *KlineM44640
NewKlineM44640 create a instance of KlineM44640
func (*KlineM44640) GetFreqInSecond ¶
func (k *KlineM44640) GetFreqInSecond() int
GetFreqInSecond return 2678400
func (*KlineM44640) GetTableName ¶
func (k *KlineM44640) GetTableName() string
GetTableName return kline_m44640
type KlineM5 ¶
type KlineM5 struct {
*BaseKline
}
KlineM5 define kline data in 5 minutes
func (*KlineM5) GetFreqInSecond ¶
GetFreqInSecond return 300
type KlineM525600 ¶
type KlineM525600 struct {
*BaseKline
}
KlineM525600 define kline data in 1 day
func NewKlineM525600 ¶
func NewKlineM525600(b *BaseKline) *KlineM525600
NewKlineM525600 create a instance of KlineM525600
func (*KlineM525600) GetFreqInSecond ¶
func (k *KlineM525600) GetFreqInSecond() int
GetFreqInSecond return 31536000
func (*KlineM525600) GetTableName ¶
func (k *KlineM525600) GetTableName() string
GetTableName return kline_m525600
type KlineM60 ¶
type KlineM60 struct {
*BaseKline
}
KlineM60 define kline data in 1 hour
func NewKlineM60 ¶
NewKlineM60 create a instance of KlineM60
func (*KlineM60) GetFreqInSecond ¶
GetFreqInSecond return 3600
func (*KlineM60) GetTableName ¶
GetTableName return kline_m60
type KlineM720 ¶
type KlineM720 struct {
*BaseKline
}
KlineM720 define kline data in 12 hours
func NewKlineM720 ¶
NewKlineM720 create a instance of KlineM720
func (*KlineM720) GetFreqInSecond ¶
GetFreqInSecond return 43200
func (*KlineM720) GetTableName ¶
GetTableName return kline_m720
type MarketKeeper ¶
type MarketKeeper interface { GetTickerByProducts(products []string) ([]map[string]string, error) GetKlineByProductID(productID uint64, granularity, size int) ([][]string, error) }
MarketKeeper expected market keeper which would get data from pulsar & redis
type MatchResult ¶
type MatchResult struct { Timestamp int64 `gorm:"index;" json:"timestamp" v2:"timestamp"` BlockHeight int64 `gorm:"PRIMARY_KEY;type:bigint" json:"block_height" v2:"block_height"` Product string `gorm:"PRIMARY_KEY;type:varchar(20)" json:"product" v2:"product"` Price float64 `gorm:"type:DOUBLE" json:"price" v2:"price"` Quantity float64 `gorm:"type:DOUBLE" json:"volume" v2:"volume"` }
type MergedTickersEvent ¶
type MergedTickersEvent struct {
// contains filtered or unexported fields
}
func NewMergedTickersEvent ¶
func NewMergedTickersEvent(ts int64, freq int, tickers []interface{}) *MergedTickersEvent
func (*MergedTickersEvent) FormatResult ¶
func (m *MergedTickersEvent) FormatResult() interface{}
func (*MergedTickersEvent) GetChannelInfo ¶
func (m *MergedTickersEvent) GetChannelInfo() (channel, filter string, err error)
func (*MergedTickersEvent) GetFullChannel ¶
func (m *MergedTickersEvent) GetFullChannel() string
func (*MergedTickersEvent) GetTimestamp ¶
func (m *MergedTickersEvent) GetTimestamp() int64
type Order ¶
type Order struct { TxHash string `gorm:"type:varchar(80)" json:"txhash" v2:"txhash"` OrderID string `gorm:"PRIMARY_KEY;type:varchar(30)" json:"order_id" v2:"order_id"` Sender string `gorm:"index;type:varchar(80)" json:"sender" v2:"sender"` Product string `gorm:"index;type:varchar(20)" json:"product" v2:"product"` Side string `gorm:"type:varchar(10)" json:"side" v2:"side"` Price string `gorm:"type:varchar(40)" json:"price" v2:"price"` Quantity string `gorm:"type:varchar(40)" json:"quantity" v2:"quantity"` Status int64 `gorm:"index;" json:"status" v2:"status"` FilledAvgPrice string `gorm:"type:varchar(40)" json:"filled_avg_price" v2:"filled_avg_price"` RemainQuantity string `gorm:"type:varchar(40)" json:"remain_quantity" v2:"remain_quantity"` Timestamp int64 `gorm:"index;" json:"timestamp" v2:"timestamp"` }
type OrderKeeper ¶
type OrderKeeper interface { GetOrder(ctx sdk.Context, orderID string) *order.Order GetUpdatedOrderIDs() []string GetTxHandlerMsgResult() []bitset.BitSet GetBlockOrderNum(ctx sdk.Context, blockHeight int64) int64 GetBlockMatchResult() *ordertypes.BlockMatchResult GetLastPrice(ctx sdk.Context, product string) sdk.Dec GetBestBidAndAsk(ctx sdk.Context, product string) (sdk.Dec, sdk.Dec) }
OrderKeeper expected order keeper
type OrderV2 ¶
type OrderV2 struct { OrderID string `json:"order_id"` Price string `json:"price"` Size string `json:"size"` OrderType string `json:"order_type"` Notional string `json:"notional"` InstrumentID string `json:"instrument_id"` Side string `json:"side"` Type string `json:"type"` Timestamp string `json:"timestamp"` FilledSize string `json:"filled_size"` FilledNotional string `json:"filled_notional"` State string `json:"state"` }
func ConvertOrderToOrderV2 ¶
type QueryDealsParams ¶
type QueryDealsParams struct { Address string Product string Start int64 End int64 Page int PerPage int Side string }
nolint
func NewQueryDealsParams ¶
func NewQueryDealsParams(addr, product string, start, end int64, page, perPage int, side string) QueryDealsParams
NewQueryDealsParams creates a new instance of QueryDealsParams
type QueryDealsParamsV2 ¶
type QueryDexFeesParams ¶
type QueryDexFeesParams struct { DexHandlingAddr string BaseAsset string QuoteAsset string Page int PerPage int }
nolint
func NewQueryDexFeesParams ¶
func NewQueryDexFeesParams(dexHandlingAddr, baseAsset, quoteAsset string, page, perPage int) QueryDexFeesParams
NewQueryDexFeesParams creates a new instance of QueryDexFeesParams
type QueryFeeDetailsParams ¶
nolint
func NewQueryFeeDetailsParams ¶
func NewQueryFeeDetailsParams(addr string, page, perPage int) QueryFeeDetailsParams
NewQueryFeeDetailsParams creates a new instance of QueryFeeDetailsParams
type QueryFeeDetailsParamsV2 ¶
type QueryKlinesParams ¶
nolint
func NewQueryKlinesParams ¶
func NewQueryKlinesParams(product string, granularity, size int) QueryKlinesParams
NewQueryKlinesParams creates a new instance of QueryKlinesParams
type QueryMatchParams ¶
nolint
func NewQueryMatchParams ¶
func NewQueryMatchParams(product string, start, end int64, page, perPage int) QueryMatchParams
NewQueryMatchParams creates a new instance of QueryMatchParams
type QueryMatchParamsV2 ¶
type QueryOrderListParams ¶
type QueryOrderListParams struct { Address string Product string Page int PerPage int Start int64 End int64 Side string HideNoFill bool }
nolint
func NewQueryOrderListParams ¶
func NewQueryOrderListParams(addr, product, side string, page, perPage int, start, end int64, hideNoFill bool) QueryOrderListParams
NewQueryOrderListParams creates a new instance of QueryOrderListParams
type QueryOrderParamsV2 ¶
type QueryTickerParams ¶
type QueryTickerParams struct { Product string `json:"product"` Count int `json:"count"` Sort bool `json:"sort"` }
nolint
type QueryTxListParams ¶
type QueryTxListParams struct { Address string TxType int64 StartTime int64 EndTime int64 Page int PerPage int }
nolint
func NewQueryTxListParams ¶
func NewQueryTxListParams(addr string, txType, startTime, endTime int64, page, perPage int) QueryTxListParams
NewQueryTxListParams creates a new instance of QueryTxListParams
type QueryTxListParamsV2 ¶
type Ticker ¶
type Ticker struct { Symbol string `json:"symbol"` Product string `json:"product"` Timestamp int64 `json:"timestamp"` Open float64 `json:"open"` // Open In 24h Close float64 `json:"close"` // Close in 24h High float64 `json:"high"` // High in 24h Low float64 `json:"low"` // Low in 24h Price float64 `json:"price"` Volume float64 `json:"volume"` // Volume in 24h Change float64 `json:"change"` // (Close - Open) ChangePercentage string `json:"change_percentage"` // Change / Open * 100% }
func (*Ticker) FormatResult ¶
func (t *Ticker) FormatResult() interface{}
func (*Ticker) GetChannelInfo ¶
func (*Ticker) GetFullChannel ¶
func (*Ticker) GetTimestamp ¶
func (*Ticker) PrettyString ¶
PrettyString return string of ticker data
type TickerV2 ¶
type TickerV2 struct { InstrumentID string `json:"instrument_id"` // name of token pair Last string `json:"last"` BestBid string `json:"best_bid"` BestAsk string `json:"best_ask"` Open24H string `json:"open_24h"` High24H string `json:"high_24h"` Low24H string `json:"low_24h"` BaseVolume24H string `json:"base_volume_24h"` QuoteVolume24H string `json:"quote_volume_24h"` Timestamp string `json:"timestamp"` }
func DefaultTickerV2 ¶
type TokenKeeper ¶
type TokenKeeper interface { GetFeeDetailList() []*token.FeeDetail GetParams(ctx sdk.Context) (params token.Params) }
TokenKeeper expected token keeper
type Transaction ¶
type Transaction struct { TxHash string `gorm:"type:varchar(80)" json:"txhash" v2:"txhash"` Type int64 `gorm:"index;" json:"type" v2:"type"` // 1:Transfer, 2:NewOrder, 3:CancelOrder Address string `gorm:"index;type:varchar(80)" json:"address" v2:"address"` Symbol string `gorm:"type:varchar(20)" json:"symbol" v2:"symbol"` Side int64 `gorm:"" json:"side"` // 1:buy, 2:sell, 3:from, 4:to Quantity string `gorm:"type:varchar(40)" json:"quantity" v2:"quantity"` Fee string `gorm:"type:varchar(40)" json:"fee" v2:"fee"` Timestamp int64 `gorm:"index" json:"timestamp" v2:"timestamp"` }
func GenerateTx ¶
func GenerateTx(tx *auth.StdTx, txHash string, ctx sdk.Context, orderKeeper OrderKeeper, timestamp int64) []*Transaction
GenerateTx return transaction, called at DeliverTx