decred.org/dcrdex@v1.0.5/client/mm/libxc/bntypes/types.go (about)

     1  package bntypes
     2  
     3  import "encoding/json"
     4  
     5  type Filter struct {
     6  	Type string `json:"filterType"`
     7  
     8  	// Price filter
     9  	MinPrice float64 `json:"minPrice,string"`
    10  	MaxPrice float64 `json:"maxPrice,string"`
    11  	TickSize float64 `json:"tickSize,string"`
    12  
    13  	// Lot size filter
    14  	MinQty   float64 `json:"minQty,string"`
    15  	MaxQty   float64 `json:"maxQty,string"`
    16  	StepSize float64 `json:"stepSize,string"`
    17  }
    18  
    19  type Market struct {
    20  	Symbol              string    `json:"symbol"`
    21  	Status              string    `json:"status"`
    22  	BaseAsset           string    `json:"baseAsset"`
    23  	BaseAssetPrecision  int       `json:"baseAssetPrecision"`
    24  	QuoteAsset          string    `json:"quoteAsset"`
    25  	QuoteAssetPrecision int       `json:"quoteAssetPrecision"`
    26  	OrderTypes          []string  `json:"orderTypes"`
    27  	Filters             []*Filter `json:"filters"`
    28  
    29  	// Below fields are parsed from Filters.
    30  	LotSize  uint64
    31  	MinQty   uint64
    32  	MaxQty   uint64
    33  	RateStep uint64
    34  	MinPrice uint64
    35  	MaxPrice uint64
    36  }
    37  
    38  type Balance struct {
    39  	Asset  string  `json:"asset"`
    40  	Free   float64 `json:"free,string"`
    41  	Locked float64 `json:"locked,string"`
    42  }
    43  
    44  type Account struct {
    45  	Balances []*Balance `json:"balances"`
    46  }
    47  
    48  type NetworkInfo struct {
    49  	// AddressRegex            string  `json:"addressRegex"`
    50  	Coin          string `json:"coin"`
    51  	DepositEnable bool   `json:"depositEnable"`
    52  	// IsDefault               bool    `json:"isDefault"`
    53  	// MemoRegex               string  `json:"memoRegex"`
    54  	// MinConfirm              int     `json:"minConfirm"`
    55  	// Name                    string  `json:"name"`
    56  	Network string `json:"network"`
    57  	// ResetAddressStatus      bool    `json:"resetAddressStatus"`
    58  	// SpecialTips             string  `json:"specialTips"`
    59  	// UnLockConfirm           int     `json:"unLockConfirm"`
    60  	WithdrawEnable          bool    `json:"withdrawEnable"`
    61  	WithdrawFee             float64 `json:"withdrawFee,string"`
    62  	WithdrawIntegerMultiple float64 `json:"withdrawIntegerMultiple,string"`
    63  	// WithdrawMax             float64 `json:"withdrawMax,string"`
    64  	WithdrawMin float64 `json:"withdrawMin,string"`
    65  	// SameAddress             bool    `json:"sameAddress"`
    66  	// EstimatedArrivalTime    int     `json:"estimatedArrivalTime"`
    67  	// Busy                    bool    `json:"busy"`
    68  }
    69  
    70  type CoinInfo struct {
    71  	Coin string `json:"coin"`
    72  	// DepositAllEnable  bool           `json:"depositAllEnable"`
    73  	// Free              float64        `json:"free,string"`
    74  	// Freeze            float64        `json:"freeze,string"`
    75  	// Ipoable           float64        `json:"ipoable,string"`
    76  	// Ipoing            float64        `json:"ipoing,string"`
    77  	// IsLegalMoney      bool           `json:"isLegalMoney"`
    78  	// Locked            float64        `json:"locked,string"`
    79  	// Name              string         `json:"name"`
    80  	// Storage           float64        `json:"storage,string"`
    81  	// Trading           bool           `json:"trading"`
    82  	// WithdrawAllEnable bool           `json:"withdrawAllEnable"`
    83  	// Withdrawing       float64        `json:"withdrawing,string"`
    84  	NetworkList []*NetworkInfo `json:"networkList"`
    85  }
    86  
    87  type OrderbookSnapshot struct {
    88  	LastUpdateID uint64           `json:"lastUpdateId"`
    89  	Bids         [][2]json.Number `json:"bids"`
    90  	Asks         [][2]json.Number `json:"asks"`
    91  }
    92  
    93  type BookUpdate struct {
    94  	FirstUpdateID uint64           `json:"U"`
    95  	LastUpdateID  uint64           `json:"u"`
    96  	Bids          [][2]json.Number `json:"b"`
    97  	Asks          [][2]json.Number `json:"a"`
    98  }
    99  
   100  type BookNote struct {
   101  	StreamName string      `json:"stream"`
   102  	Data       *BookUpdate `json:"data"`
   103  	ID         uint64      `json:"id"`
   104  	Result     []string    `json:"result"`
   105  }
   106  
   107  type WSBalance struct {
   108  	Asset  string  `json:"a"`
   109  	Free   float64 `json:"f,string"`
   110  	Locked float64 `json:"l,string"`
   111  }
   112  
   113  type StreamUpdate struct {
   114  	Asset              string       `json:"a"`
   115  	EventType          string       `json:"e"`
   116  	ClientOrderID      string       `json:"c"`
   117  	CurrentOrderStatus string       `json:"X"`
   118  	Balances           []*WSBalance `json:"B"`
   119  	BalanceDelta       float64      `json:"d,string"`
   120  	Filled             float64      `json:"z,string"`
   121  	QuoteFilled        float64      `json:"Z,string"`
   122  	OrderQty           float64      `json:"q,string"`
   123  	QuoteOrderQty      float64      `json:"Q,string"`
   124  	CancelledOrderID   string       `json:"C"`
   125  	E                  int64        `json:"E"`
   126  	ListenKey          string       `json:"listenKey"`
   127  }
   128  
   129  type RateLimit struct {
   130  	RateLimitType string `json:"rateLimitType"`
   131  	Interval      string `json:"interval"`
   132  	IntervalNum   int64  `json:"intervalNum"`
   133  	Limit         int64  `json:"limit"`
   134  }
   135  
   136  type DataStreamKey struct {
   137  	ListenKey string `json:"listenKey"`
   138  }
   139  
   140  type ExchangeInfo struct {
   141  	Timezone   string       `json:"timezone"`
   142  	ServerTime int64        `json:"serverTime"`
   143  	RateLimits []*RateLimit `json:"rateLimits"`
   144  	Symbols    []*Market    `json:"symbols"`
   145  }
   146  
   147  type StreamSubscription struct {
   148  	Method string   `json:"method"`
   149  	Params []string `json:"params"`
   150  	ID     uint64   `json:"id"`
   151  }
   152  
   153  type PendingDeposit struct {
   154  	Amount  float64 `json:"amount,string"`
   155  	Coin    string  `json:"coin"`
   156  	Network string  `json:"network"`
   157  	Status  int     `json:"status"`
   158  	TxID    string  `json:"txId"`
   159  }
   160  
   161  const (
   162  	DepositStatusPending            = 0
   163  	DepositStatusSuccess            = 1
   164  	DepositStatusCredited           = 6
   165  	DepositStatusWrongDeposit       = 7
   166  	DepositStatusWaitingUserConfirm = 8
   167  )
   168  
   169  type OrderResponse struct {
   170  	Symbol             string  `json:"symbol"`
   171  	Price              float64 `json:"price,string"`
   172  	OrigQty            float64 `json:"origQty,string"`
   173  	OrigQuoteQty       float64 `json:"origQuoteOrderQty,string"`
   174  	ExecutedQty        float64 `json:"executedQty,string"`
   175  	CumulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"`
   176  	Status             string  `json:"status"`
   177  }
   178  
   179  type BookedOrder struct {
   180  	Symbol             string  `json:"symbol"`
   181  	OrderID            int64   `json:"orderId"`
   182  	ClientOrderID      string  `json:"clientOrderId"`
   183  	Price              float64 `json:"price,string"`
   184  	OrigQty            float64 `json:"origQty,string"`
   185  	OrigQuoteQty       float64 `json:"origQuoteOrderQty,string"`
   186  	ExecutedQty        float64 `json:"executedQty,string"`
   187  	CumulativeQuoteQty float64 `json:"cummulativeQuoteQty,string"`
   188  	Status             string  `json:"status"`
   189  	TimeInForce        string  `json:"timeInForce"`
   190  	Side               string  `json:"side"`
   191  }
   192  
   193  type MarketTicker24 struct {
   194  	Symbol             string  `json:"symbol"`
   195  	PriceChange        float64 `json:"priceChange,string"`
   196  	PriceChangePercent float64 `json:"priceChangePercent,string"`
   197  	WeightedAvgPrice   float64 `json:"weightedAvgPrice,string"`
   198  	PrevClosePrice     float64 `json:"prevClosePrice,string"`
   199  	LastPrice          float64 `json:"lastPrice,string"`
   200  	LastQty            float64 `json:"lastQty,string"`
   201  	BidPrice           float64 `json:"bidPrice,string"`
   202  	BidQty             float64 `json:"bidQty,string"`
   203  	AskPrice           float64 `json:"askPrice,string"`
   204  	AskQty             float64 `json:"askQty,string"`
   205  	OpenPrice          float64 `json:"openPrice,string"`
   206  	HighPrice          float64 `json:"highPrice,string"`
   207  	LowPrice           float64 `json:"lowPrice,string"`
   208  	Volume             float64 `json:"volume,string"`
   209  	QuoteVolume        float64 `json:"quoteVolume,string"`
   210  	OpenTime           int64   `json:"openTime"`
   211  	CloseTime          int64   `json:"closeTime"`
   212  	FirstId            int64   `json:"firstId"`
   213  	LastId             int64   `json:"lastId"`
   214  	Count              int64   `json:"count"`
   215  }