p2p

package
v2.0.0-...-a6bed7a Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UseTestnet = false

UseTestnet switch all the API endpoints from production to the testnet

Functions

func FormatTimestamp

func FormatTimestamp(t time.Time) int64

FormatTimestamp formats a time into Unix timestamp in milliseconds, as requested by Binance.

func NewDeliveryClient

func NewDeliveryClient(apiKey, secretKey string) *delivery.Client

NewDeliveryClient initialize client for coin-M futures API

func NewFuturesClient

func NewFuturesClient(apiKey, secretKey string) *futures.Client

NewFuturesClient initialize client for futures API

Types

type AllAsset

type AllAsset struct {
	Code          string     `json:"code"`
	Message       any        `json:"message"`
	MessageDetail any        `json:"messageDetail"`
	Data          []AssetAll `json:"data"`
	Success       bool       `json:"success"`
}

type AllAssetService

type AllAssetService struct {
	// contains filtered or unexported fields
}

AllAssetService all asset servcie

func (*AllAssetService) Do

func (s *AllAssetService) Do(ctx context.Context, opts ...RequestOption) (res *AllAsset, err error)

Do send request

type AssetAll

type AssetAll struct {
	ID                   string   `json:"id"`
	AssetCode            string   `json:"assetCode"`
	AssetName            string   `json:"assetName"`
	Unit                 string   `json:"unit"`
	CommissionRate       float64  `json:"commissionRate"`
	FreeAuditWithdrawAmt float64  `json:"freeAuditWithdrawAmt"`
	FreeUserChargeAmount float64  `json:"freeUserChargeAmount"`
	CreateTime           int64    `json:"createTime"`
	Test                 int      `json:"test"`
	Gas                  any      `json:"gas"`
	IsLegalMoney         bool     `json:"isLegalMoney"`
	ReconciliationAmount float64  `json:"reconciliationAmount"`
	SeqNum               string   `json:"seqNum"`
	ChineseName          string   `json:"chineseName"`
	CnLink               string   `json:"cnLink"`
	EnLink               string   `json:"enLink"`
	LogoURL              string   `json:"logoUrl"`
	FullLogoURL          string   `json:"fullLogoUrl"`
	SupportMarket        any      `json:"supportMarket"`
	FeeReferenceAsset    any      `json:"feeReferenceAsset"`
	FeeRate              any      `json:"feeRate"`
	FeeDigit             int      `json:"feeDigit"`
	AssetDigit           int      `json:"assetDigit"`
	Trading              bool     `json:"trading"`
	Tags                 []string `json:"tags"`
	PlateType            string   `json:"plateType"`
	Etf                  bool     `json:"etf"`
	IsLedgerOnly         bool     `json:"isLedgerOnly"`
	Delisted             bool     `json:"delisted"`
	PreDelist            bool     `json:"preDelist"`
	PdTradeDeadline      any      `json:"pdTradeDeadline"`
	PdDepositDeadline    any      `json:"pdDepositDeadline"`
	PdAnnounceURL        any      `json:"pdAnnounceUrl"`
	TagBits              string   `json:"tagBits"`
}

func (*AssetAll) GetAssetCode

func (a *AssetAll) GetAssetCode() string

type AssetConfig

type AssetConfig struct {
	Asset       string `json:"asset"`
	Description string `json:"description"`
	IconURL     string `json:"iconUrl"`
	NewToken    any    `json:"newToken"`
	Pop         any    `json:"pop"`
}

type Client

type Client struct {
	BaseURL    string
	UserAgent  string
	HTTPClient *http.Client
	Debug      bool
	Logger     *log.Logger
	TimeOffset int64
	// contains filtered or unexported fields
}

Client define API client

func NewClient

func NewClient() *Client

NewClient initialize an API client instance with API key and secret key. You should always call this function before using this SDK. Services will be created by the form client.NewXXXService().

func NewProxiedClient

func NewProxiedClient(apiKey, secretKey, proxyUrl string) *Client

NewProxiedClient passing a proxy url

func (*Client) NewAllAssetService

func (c *Client) NewAllAssetService() *AllAssetService

NewAllAssetService get all asset

func (*Client) NewConfigService

func (c *Client) NewConfigService() *ConfigService

NewConfigService get all asset

func (*Client) NewCountriesService

func (c *Client) NewCountriesService() *CountriesService

NewCountriesService get all asset

func (*Client) NewCurrencyPairService

func (c *Client) NewCurrencyPairService() *CurrencyPairService

NewCurrencyPairService get all asset

func (*Client) NewFiatListService

func (c *Client) NewFiatListService() *FiatListService

NewFiatListService get all asset

func (*Client) NewFilterConditionsService

func (c *Client) NewFilterConditionsService() *FilterConditionsService

NewFilterConditionsService get all asset

func (*Client) NewSearchService

func (c *Client) NewSearchService() *SearchService

SearchService get all asset

func (*Client) SetApiEndpoint

func (c *Client) SetApiEndpoint(url string) *Client

SetApiEndpoint set api Endpoint

type Config

type Config struct {
	Code          string     `json:"code"`
	Message       any        `json:"message"`
	MessageDetail any        `json:"messageDetail"`
	Data          ConfigData `json:"data"`
	Success       bool       `json:"success"`
}

type ConfigArea

type ConfigArea struct {
	Area                       string      `json:"area"`
	ProMerchantFilterAvailable bool        `json:"proMerchantFilterAvailable"`
	TradeSides                 []TradeSide `json:"tradeSides"`
	Filters                    Filter      `json:"filters"`
}

type ConfigData

type ConfigData struct {
	Fiat                string             `json:"fiat"`
	Areas               []ConfigArea       `json:"areas"`
	FilterDefaultValues FilterDefaultValue `json:"filterDefaultValues"`
}

type ConfigService

type ConfigService struct {
	// contains filtered or unexported fields
}

ConfigService all asset servcie

func (*ConfigService) Do

func (s *ConfigService) Do(ctx context.Context, opts ...RequestOption) (res *Config, err error)

Do send request

func (*ConfigService) SetFiat

func (s *ConfigService) SetFiat(fiat string) *ConfigService

Fiat sets the fiat parameter.

type ConvertAsset

type ConvertAsset struct {
	Asset       string `json:"asset"`
	Description any    `json:"description"`
	IconURL     any    `json:"iconUrl"`
	NewToken    int    `json:"newToken"`
	Pop         int    `json:"pop"`
}

type Countries

type Countries struct {
	Code          string    `json:"code"`
	Message       any       `json:"message"`
	MessageDetail any       `json:"messageDetail"`
	Data          []Country `json:"data"`
	Success       bool      `json:"success"`
}

type CountriesService

type CountriesService struct {
	// contains filtered or unexported fields
}

CountriesService all asset servcie

func (*CountriesService) Do

func (s *CountriesService) Do(ctx context.Context, opts ...RequestOption) (res *Countries, err error)

Do send request

type Country

type Country struct {
	Code            string `json:"code"`
	Code2           string `json:"code2"`
	En              string `json:"en"`
	Cn              string `json:"cn"`
	MobileCode      string `json:"mobileCode"`
	CountryImageURL any    `json:"countryImageUrl"`
	BizType         any    `json:"bizType"`
}

func (*Country) GetCountryCode

func (c *Country) GetCountryCode() string

type CurrencyPair

type CurrencyPair struct {
	Code          string `json:"code"`
	Message       any    `json:"message"`
	MessageDetail any    `json:"messageDetail"`
	Data          []Pair `json:"data"`
	Success       bool   `json:"success"`
}

type CurrencyPairService

type CurrencyPairService struct {
	// contains filtered or unexported fields
}

CurrencyPairService all asset servcie

func (*CurrencyPairService) Do

func (s *CurrencyPairService) Do(ctx context.Context, opts ...RequestOption) (res *CurrencyPair, err error)

Do send request

type Fiat

type Fiat struct {
	CurrencyCode   string `json:"currencyCode"`
	CurrencySymbol string `json:"currencySymbol"`
	CurrencyScale  int    `json:"currencyScale"`
	CountryCode    string `json:"countryCode"`
	IconURL        string `json:"iconUrl"`
}

func (*Fiat) FiatName

func (f *Fiat) FiatName() string

type FiatList

type FiatList struct {
	Code          string `json:"code"`
	Message       any    `json:"message"`
	MessageDetail any    `json:"messageDetail"`
	Data          []Fiat `json:"data"`
	Success       bool   `json:"success"`
}

type FiatListService

type FiatListService struct {
	// contains filtered or unexported fields
}

FiatListService all asset servcie

func (*FiatListService) Do

func (s *FiatListService) Do(ctx context.Context, opts ...RequestOption) (res *FiatList, err error)

Do send request

type Filter

type Filter struct {
	ProMerchant   bool `json:"proMerchant"`
	AdvancedSort  bool `json:"advancedSort"`
	MakerCategory any  `json:"makerCategory"`
}

type FilterConditions

type FilterConditions struct {
	Code          string     `json:"code"`
	Message       any        `json:"message"`
	MessageDetail any        `json:"messageDetail"`
	Data          FilterData `json:"data"`
	Success       bool       `json:"success"`
}

type FilterConditionsService

type FilterConditionsService struct {
	// contains filtered or unexported fields
}

FilterConditionsService all asset servcie

func (*FilterConditionsService) Do

Do send request

func (*FilterConditionsService) Fiat

Fiat sets the fiat parameter.

type FilterCountry

type FilterCountry struct {
	Scode string `json:"scode"`
	Name  string `json:"name"`
}

type FilterData

type FilterData struct {
	Countries        []FilterCountry     `json:"countries"`
	TradeMethods     []FilterTradeMethod `json:"tradeMethods"`
	PreferredCountry string              `json:"preferredCountry"`
}

type FilterDefaultValue

type FilterDefaultValue struct {
	PublisherType string `json:"publisherType"`
}

type FilterTradeMethod

type FilterTradeMethod struct {
	ID                   any    `json:"id"`
	PayMethodID          string `json:"payMethodId"`
	PayAccount           any    `json:"payAccount"`
	PayBank              any    `json:"payBank"`
	PaySubBank           any    `json:"paySubBank"`
	PayType              any    `json:"payType"`
	Identifier           string `json:"identifier"`
	IconURLColor         string `json:"iconUrlColor"`
	TradeMethodName      string `json:"tradeMethodName"`
	TradeMethodShortName string `json:"tradeMethodShortName"`
	TradeMethodBgColor   string `json:"tradeMethodBgColor"`
}

type Pair

type Pair struct {
	Pair     string  `json:"pair"`
	Rate     float64 `json:"rate"`
	Symbol   string  `json:"symbol"`
	FullName string  `json:"fullName"`
	ImageURL string  `json:"imageUrl"`
}

type RequestOption

type RequestOption func(*request)

RequestOption define option type for request

func WithHeader

func WithHeader(key, value string, replace bool) RequestOption

WithHeader set or add a header value to the request

func WithHeaders

func WithHeaders(header http.Header) RequestOption

WithHeaders set or replace the headers of the request

func WithRecvWindow

func WithRecvWindow(recvWindow int64) RequestOption

WithRecvWindow set recvWindow param for the request

type Search struct {
	Code          string       `json:"code"`
	Message       any          `json:"message"`
	MessageDetail any          `json:"messageDetail"`
	Data          []SearchData `json:"data"`
	Total         int          `json:"total"`
	Success       bool         `json:"success"`
}

type SearchAdv

type SearchAdv struct {
	AdvNo                           string              `json:"advNo"`
	Classify                        string              `json:"classify"`
	TradeType                       string              `json:"tradeType"`
	Asset                           string              `json:"asset"`
	FiatUnit                        string              `json:"fiatUnit"`
	AdvStatus                       any                 `json:"advStatus"`
	PriceType                       any                 `json:"priceType"`
	PriceFloatingRatio              any                 `json:"priceFloatingRatio"`
	RateFloatingRatio               any                 `json:"rateFloatingRatio"`
	CurrencyRate                    any                 `json:"currencyRate"`
	Price                           string              `json:"price"`
	InitAmount                      any                 `json:"initAmount"`
	SurplusAmount                   string              `json:"surplusAmount"`
	AmountAfterEditing              any                 `json:"amountAfterEditing"`
	MaxSingleTransAmount            string              `json:"maxSingleTransAmount"`
	MinSingleTransAmount            string              `json:"minSingleTransAmount"`
	BuyerKycLimit                   any                 `json:"buyerKycLimit"`
	BuyerRegDaysLimit               any                 `json:"buyerRegDaysLimit"`
	BuyerBtcPositionLimit           any                 `json:"buyerBtcPositionLimit"`
	Remarks                         any                 `json:"remarks"`
	AutoReplyMsg                    string              `json:"autoReplyMsg"`
	PayTimeLimit                    int                 `json:"payTimeLimit"`
	TradeMethods                    []SearchTradeMethod `json:"tradeMethods"`
	UserTradeCountFilterTime        any                 `json:"userTradeCountFilterTime"`
	UserBuyTradeCountMin            any                 `json:"userBuyTradeCountMin"`
	UserBuyTradeCountMax            any                 `json:"userBuyTradeCountMax"`
	UserSellTradeCountMin           any                 `json:"userSellTradeCountMin"`
	UserSellTradeCountMax           any                 `json:"userSellTradeCountMax"`
	UserAllTradeCountMin            any                 `json:"userAllTradeCountMin"`
	UserAllTradeCountMax            any                 `json:"userAllTradeCountMax"`
	UserTradeCompleteRateFilterTime any                 `json:"userTradeCompleteRateFilterTime"`
	UserTradeCompleteCountMin       any                 `json:"userTradeCompleteCountMin"`
	UserTradeCompleteRateMin        any                 `json:"userTradeCompleteRateMin"`
	UserTradeVolumeFilterTime       any                 `json:"userTradeVolumeFilterTime"`
	UserTradeType                   any                 `json:"userTradeType"`
	UserTradeVolumeMin              any                 `json:"userTradeVolumeMin"`
	UserTradeVolumeMax              any                 `json:"userTradeVolumeMax"`
	UserTradeVolumeAsset            any                 `json:"userTradeVolumeAsset"`
	CreateTime                      any                 `json:"createTime"`
	AdvUpdateTime                   any                 `json:"advUpdateTime"`
	FiatVo                          any                 `json:"fiatVo"`
	AssetVo                         any                 `json:"assetVo"`
	AdvVisibleRet                   any                 `json:"advVisibleRet"`
	AssetScale                      int                 `json:"assetScale"`
	FiatScale                       int                 `json:"fiatScale"`
	PriceScale                      int                 `json:"priceScale"`
	FiatSymbol                      string              `json:"fiatSymbol"`
	IsTradable                      bool                `json:"isTradable"`
	DynamicMaxSingleTransAmount     string              `json:"dynamicMaxSingleTransAmount"`
	MinSingleTransQuantity          string              `json:"minSingleTransQuantity"`
	MaxSingleTransQuantity          string              `json:"maxSingleTransQuantity"`
	DynamicMaxSingleTransQuantity   string              `json:"dynamicMaxSingleTransQuantity"`
	TradableQuantity                string              `json:"tradableQuantity"`
	CommissionRate                  string              `json:"commissionRate"`
	TradeMethodCommissionRates      []any               `json:"tradeMethodCommissionRates"`
	LaunchCountry                   any                 `json:"launchCountry"`
	AbnormalStatusList              any                 `json:"abnormalStatusList"`
	CloseReason                     any                 `json:"closeReason"`
	StoreInformation                any                 `json:"storeInformation"`
}

type SearchAdvertiser

type SearchAdvertiser struct {
	UserNo             string  `json:"userNo"`
	RealName           any     `json:"realName"`
	NickName           string  `json:"nickName"`
	Margin             any     `json:"margin"`
	MarginUnit         any     `json:"marginUnit"`
	OrderCount         any     `json:"orderCount"`
	MonthOrderCount    int     `json:"monthOrderCount"`
	MonthFinishRate    float64 `json:"monthFinishRate"`
	PositiveRate       float64 `json:"positiveRate"`
	AdvConfirmTime     any     `json:"advConfirmTime"`
	Email              any     `json:"email"`
	RegistrationTime   any     `json:"registrationTime"`
	Mobile             any     `json:"mobile"`
	UserType           string  `json:"userType"`
	TagIconUrls        []any   `json:"tagIconUrls"`
	UserGrade          int     `json:"userGrade"`
	UserIdentity       string  `json:"userIdentity"`
	ProMerchant        any     `json:"proMerchant"`
	IsBlocked          any     `json:"isBlocked"`
	ActiveTimeInSecond int     `json:"activeTimeInSecond"`
}

type SearchData

type SearchData struct {
	Adv        SearchAdv        `json:"adv"`
	Advertiser SearchAdvertiser `json:"advertiser"`
}

type SearchService

type SearchService struct {
	// contains filtered or unexported fields
}

SearchService all asset servcie

func (*SearchService) Do

func (s *SearchService) Do(ctx context.Context, opts ...RequestOption) (res *Search, err error)

Do send request

func (*SearchService) SetAmount

func (s *SearchService) SetAmount(amount int) *SearchService

func (*SearchService) SetCountry

func (s *SearchService) SetCountry(contry []string) *SearchService

func (*SearchService) SetPageSize

func (s *SearchService) SetPageSize(page int, row int) *SearchService

func (*SearchService) SetSearch

func (s *SearchService) SetSearch(fiat string, asset string, tradeType TradeType, payTypes []string) *SearchService

type SearchTradeMethod

type SearchTradeMethod struct {
	PayID                any    `json:"payId"`
	PayMethodID          string `json:"payMethodId"`
	PayType              any    `json:"payType"`
	PayAccount           any    `json:"payAccount"`
	PayBank              any    `json:"payBank"`
	PaySubBank           any    `json:"paySubBank"`
	Identifier           string `json:"identifier"`
	IconURLColor         any    `json:"iconUrlColor"`
	TradeMethodName      string `json:"tradeMethodName"`
	TradeMethodShortName string `json:"tradeMethodShortName"`
	TradeMethodBgColor   string `json:"tradeMethodBgColor"`
}

type TradeMethod

type TradeMethod struct {
	Identifier string `json:"identifier"`
}

type TradeSide

type TradeSide struct {
	Side          string         `json:"side"`
	Assets        []AssetConfig  `json:"assets"`
	ConvertAssets []ConvertAsset `json:"convertAssets"`
	TradeMethods  []TradeMethod  `json:"tradeMethods"`
}

type TradeType

type TradeType string

SideType define side type of order

const (
	SideTypeBuy  TradeType = "BUY"
	SideTypeSell TradeType = "SELL"
)

Global enums

Jump to

Keyboard shortcuts

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