1
This commit is contained in:
24
models/binancedto/binance.go
Normal file
24
models/binancedto/binance.go
Normal file
@ -0,0 +1,24 @@
|
||||
package binancedto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type UserSubscribeState struct {
|
||||
SpotLastTime *time.Time `json:"spotLastTime" comment:"现货websocket最后通信时间"`
|
||||
FuturesLastTime *time.Time `json:"futuresLastTime" comment:"合约websocket最后通信时间"`
|
||||
}
|
||||
|
||||
type OpenOrder struct {
|
||||
Price decimal.Decimal `json:"price"` //均价
|
||||
Quantity decimal.Decimal `json:"quantity"` //数量
|
||||
Status string `json:"status"` //币安原始状态 "NEW", "PARTIALLY_FILLED", "FILLED", "CANCELED", "PENDING_CANCEL", "REJECTED", "EXPIRED"
|
||||
}
|
||||
|
||||
type StoplossMarket struct {
|
||||
Pid int `json:"pid"`
|
||||
Symbol string `json:"symbol"`
|
||||
Type int `json:"type" comment:"对冲类型 1-现货 2-合约"`
|
||||
}
|
||||
44
models/coin.go
Normal file
44
models/coin.go
Normal file
@ -0,0 +1,44 @@
|
||||
package models
|
||||
|
||||
// Coin vts_coin 币种表信息
|
||||
type Coin struct {
|
||||
ID int `db:"id"`
|
||||
IsOpenTran int `db:"isopentran"` //是否开启提币:1开启,2关闭
|
||||
IsTrade int `db:"istrade"` //是否开启合约交易,1开启,0未开启
|
||||
CoinName string `db:"coinname"` //币种名称
|
||||
CoinCode string `db:"coincode"` //币种代号
|
||||
Url string `db:"url"` //钱包接口url
|
||||
MinChargeNum float64 `db:"minchargenum"` //最小充值数量
|
||||
MinNum float64 `db:"minnum"` //最小提币数量
|
||||
MaxNum float64 `db:"maxnum"` //最大提币转量
|
||||
}
|
||||
|
||||
// TradeSet vts_tradeset 交易配置
|
||||
type TradeSet struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
AmountDigit int `db:"amountdigit"` //基础币种计数精度
|
||||
PriceDigit int `db:"pricecdigit" json:"pricecdigit"` //价格小数点位数
|
||||
Currency string `db:"currency" json:"currency"` //法币
|
||||
Coin string `db:"coin" json:"coin"` //币种
|
||||
PriceChange float64 `db:"pricechange" json:"pricechange"` //价格波动价位
|
||||
MinBuyVal float64 `db:"minbuyval"` //最小下单金额
|
||||
OpenPrice float64 `db:"openprice"` //开盘价格
|
||||
LastPrice string `json:"last"` //最新价格
|
||||
HighPrice string `json:"high"` //24小时最高价
|
||||
LowPrice string `json:"low"` //24小时最低价
|
||||
Volume string `json:"volume"` //24小时成数量
|
||||
QuoteVolume string `json:"quote"` //24小时成交金额
|
||||
MinQty float64 `json:"minQty"` //最小交易数量
|
||||
MaxQty float64 `json:"maxQty"` //最大交易数量
|
||||
MaxNotional string `json:"MaxNotional` //最大名义价值
|
||||
MinNotional string `json:"MinNotional` //最大名义价值
|
||||
E int64 `json:"-"` //推送时间
|
||||
}
|
||||
|
||||
//CommissionType int `db:"commissiontype"` //手续费:1买,2卖,3双向
|
||||
//DepositNum float64 `db:"depositnum" json:"depositnum"` //保证金规模(手)
|
||||
//ForceRate float64 `db:"forcerate" json:"forcerate"` //维持保证金率1%
|
||||
//OverNighRate float64 `db:"overnighrate" json:"overnighrate"` //隔夜费用比率
|
||||
//MinBuyNum int `db:"minbuynum" json:"minbuynum"` //最小购买多少手
|
||||
// MaxBuyNum int `db:"maxbuynum" json:"maxbuynum"` //最大购买多少手
|
||||
//HandNum int `db:"handnum" json:"handnum"` //1手多少数量usdt
|
||||
76
models/coingatedto/coingatedto.go
Normal file
76
models/coingatedto/coingatedto.go
Normal file
@ -0,0 +1,76 @@
|
||||
package coingatedto
|
||||
|
||||
import "github.com/shopspring/decimal"
|
||||
|
||||
type OrderRequest struct {
|
||||
OrderID string `json:"order_id"` // 订单ID
|
||||
PriceAmount decimal.Decimal `json:"price_amount"` // 价格金额
|
||||
PriceCurrency string `json:"price_currency"` // 价格货币
|
||||
ReceiveCurrency string `json:"receive_currency"` // 接收货币
|
||||
Title string `json:"title"` // 标题
|
||||
Description string `json:"description"` // 描述
|
||||
CallbackURL string `json:"callback_url"` // 回调URL
|
||||
CancelUrl string `json:"cancel_url"` //取消跳转url
|
||||
SuccessUrl string `json:"success_url"` //成功跳转地址
|
||||
// OrderID:PriceAmount:PriceCurrency 然后在rsa加密
|
||||
Token string `json:"token"` //回调token
|
||||
PurchaserEmail string `json:"purchaser_email"` //付款方邮箱
|
||||
|
||||
}
|
||||
|
||||
type OrderResponse struct {
|
||||
ID int `json:"id"` // 订单ID
|
||||
Status string `json:"status"` // 订单状态
|
||||
Title string `json:"title"` // 标题
|
||||
DoNotConvert bool `json:"do_not_convert"` // 不转换
|
||||
OrderableType string `json:"orderable_type"` // 可订购类型
|
||||
OrderableID int `json:"orderable_id"` // 可订购ID
|
||||
UUID string `json:"uuid"` // UUID
|
||||
PaymentGateway *string `json:"payment_gateway"` // 支付网关 (可为 nil)
|
||||
PriceCurrency string `json:"price_currency"` // 价格货币
|
||||
PriceAmount string `json:"price_amount"` // 价格金额
|
||||
LightningNetwork bool `json:"lightning_network"` // 闪电网络
|
||||
ReceiveCurrency string `json:"receive_currency"` // 接收货币
|
||||
ReceiveAmount string `json:"receive_amount"` // 接收金额
|
||||
CreatedAt string `json:"created_at"` // 创建时间
|
||||
OrderID string `json:"order_id"` // 订单ID
|
||||
PaymentURL string `json:"payment_url"` // 支付URL
|
||||
UnderpaidAmount string `json:"underpaid_amount"` // 欠款金额
|
||||
OverpaidAmount string `json:"overpaid_amount"` // 超额支付金额
|
||||
IsRefundable bool `json:"is_refundable"` // 是否可退款
|
||||
PaymentRequestURI *string `json:"payment_request_uri"` // 支付请求URI (可为 nil)
|
||||
Refunds []interface{} `json:"refunds"` // 退款信息
|
||||
Voids []interface{} `json:"voids"` // 作废信息
|
||||
Fees []interface{} `json:"fees"` // 费用信息
|
||||
BlockchainTransactions []interface{} `json:"blockchain_transactions"` // 区块链交易信息
|
||||
Token string `json:"token"` // 令牌
|
||||
}
|
||||
|
||||
type OrderCallBackResponse struct {
|
||||
ID int `json:"id" form:"id"` // 订单ID
|
||||
OrderID string `json:"order_id" form:"order_id"` // 订单号
|
||||
Status string `json:"status" form:"status"` // 订单状态
|
||||
PayAmount string `json:"pay_amount" form:"pay_amount"` // 支付金额
|
||||
PayCurrency string `json:"pay_currency" form:"pay_currency"` // 支付货币
|
||||
PriceAmount string `json:"price_amount" form:"price_amount"` // 价格金额
|
||||
PriceCurrency string `json:"price_currency" form:"price_currency"` // 价格货币
|
||||
ReceiveCurrency string `json:"receive_currency" form:"receive_currency"` // 接收货币
|
||||
ReceiveAmount string `json:"receive_amount" form:"receive_amount"` // 接收金额
|
||||
CreatedAt string `json:"created_at" form:"create_at"` // 创建时间
|
||||
Token string `json:"token" form:"token"` // 令牌
|
||||
UnderpaidAmount string `json:"underpaid_amount" form:"underpaid_amount"` // 欠款金额
|
||||
OverpaidAmount string `json:"overpaid_amount" form:"overpaid_amount"` // 超额支付金额
|
||||
IsRefundable bool `json:"is_refundable" form:"is_refundable"` // 是否可退款
|
||||
Fees []OrderCallBackFee `json:"fees" form:"fees"` // 费用信息
|
||||
}
|
||||
|
||||
type OrderCallBackFee struct {
|
||||
Type string `json:"type"` // 费用类型
|
||||
Amount string `json:"amount"` // 费用金额
|
||||
Currency OrderCallCurrency `json:"currency"` // 货币信息 {"id":1,"symbol":"BTC"}
|
||||
}
|
||||
|
||||
type OrderCallCurrency struct {
|
||||
ID int `json:"id"` // 货币ID
|
||||
Symbol string `json:"symbol"` // 货币符号
|
||||
}
|
||||
9
models/commondto/websocket.go
Normal file
9
models/commondto/websocket.go
Normal file
@ -0,0 +1,9 @@
|
||||
package commondto
|
||||
|
||||
import "time"
|
||||
|
||||
type WebSocketErr struct {
|
||||
Count int `json:"count"`
|
||||
ErrorMessage string `json:"message"`
|
||||
Time time.Time `json:"time"`
|
||||
}
|
||||
121
models/deal.go
Normal file
121
models/deal.go
Normal file
@ -0,0 +1,121 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Deal vts_deal 成交记录表
|
||||
type Deal struct {
|
||||
ID int `db:"id"`
|
||||
UserID int `db:"userid"`
|
||||
CurrencyID int `db:"currencyid"` //
|
||||
CoinID int `db:"coinid"` //
|
||||
OrderType int `db:"ordertype"` //订单类型:1限价,2限价止盈止损,3市价
|
||||
BuyType int `db:"buytype"` //买卖类型:1买,2卖
|
||||
IsTrigger int `db:"istrigger"` //是否触发撮合-是:1,否:2
|
||||
MatchID int64 `db:"matchid"` //撮合id
|
||||
OrderNO int64 `db:"orderno"` //订单号
|
||||
CreateDateInt int64 `db:"-"` //成交日期
|
||||
EntrustDateInt int64 `db:"-"` //委托时间
|
||||
DealNO string `db:"dealno"` //成交单号
|
||||
Price float64 `db:"price"` //成交价格
|
||||
Num float64 `db:"num"` //成交数量
|
||||
Poundage float64 `db:"poundage"` //手续费
|
||||
TotalAmt float64 `db:"totalamt"` //总金额
|
||||
SurAmt float64 `db:"suramt"` //剩余金额
|
||||
BuyInPrice float64 `db:"buyinprice"` //买卖方原始价格
|
||||
FreezeAmt float64 `db:"freezeamt"` //
|
||||
CreateDate time.Time `db:"createdate"` //成交日期
|
||||
EntrustDate time.Time `db:"entrustdate"` //委托时间
|
||||
}
|
||||
|
||||
// DealStatistics vts_dealstatistics 成交量和最新最大最小价格统计
|
||||
type DealStatistics struct {
|
||||
ID int `db:"id"`
|
||||
CurrencyID int `db:"currencyid"`
|
||||
CoinID int `db:"coinid"`
|
||||
NewPrice float64 `db:"newprice"` //最新价格
|
||||
HighPrice float64 `db:"highprice"` //24小时最高价
|
||||
LowPrice float64 `db:"lowprice"` //24小时最小价格
|
||||
DealNum float64 `db:"dealnum"` //24小时成交量
|
||||
DealAmt float64 `db:"dealamt"` //24小时成交金额
|
||||
OpenPrice float64 `db:"openprice"` //开盘价
|
||||
Rate float64 `db:"rate"` //涨幅--未乘百分比
|
||||
Change float64 `db:"-"`
|
||||
DealDate int64 `db:"-"`
|
||||
}
|
||||
|
||||
// DealKLine 发送k线消息队列实体
|
||||
type DealKLine struct {
|
||||
CurrencyID int
|
||||
CoinID int
|
||||
IsTrigger int //是否触发撮合-是:1,否:2
|
||||
CreateDateInt int64 //成交日期
|
||||
Price float64
|
||||
Num float64 //成交数量
|
||||
TotalAmt float64 //总金额
|
||||
Poundage float64
|
||||
CreateDate time.Time //成交日期
|
||||
}
|
||||
|
||||
// KLine vts_kline model
|
||||
type KLine struct {
|
||||
CurrencyID int `db:"currencyid"`
|
||||
CoinID int `db:"coinid"`
|
||||
KlineType int `db:"klinetype"` //kline类型:对应 KlineTypeMap的值
|
||||
Opened float64 `db:"opened"` //开盘
|
||||
Highest float64 `db:"highest"` //最高
|
||||
Lowest float64 `db:"lowest"` //最低
|
||||
Closed float64 `db:"closed"` //收盘
|
||||
DNum float64 `db:"dnum"` //成交
|
||||
DAmt float64 `db:"damt"` //金额
|
||||
DealDate time.Time `db:"dealdate"` //时间
|
||||
IsUpdate bool `db:"-"`
|
||||
}
|
||||
|
||||
//KlineType int `db:"klinetype"` //kline类型:1--分时线,2--1分线,3--5分线,4--15分线,5--30分线,6--60分线,7--日线,8--周线,9--月线线,10--交易行情
|
||||
//KlineType string `db:"klinetype"` //kline类型:1--分时线,2--1分线,3--5分线,4--15分线,5--30分线,6--60分线,7--日线,8--周线,9--月线线,10--交易行情
|
||||
|
||||
type DbDealDataSend struct {
|
||||
Deals []Deal
|
||||
}
|
||||
|
||||
type BalanceUpdate struct {
|
||||
Event string `json:"e"` //
|
||||
Data int `json:"data"` //
|
||||
}
|
||||
|
||||
type ErrCode struct {
|
||||
Event string `json:"e"` //错误的订阅
|
||||
Data string `json:"data"` //
|
||||
}
|
||||
|
||||
// BuySellFive set five item
|
||||
type BuySellFive struct {
|
||||
Price float64
|
||||
Num float64
|
||||
}
|
||||
|
||||
// DealDay 行情成交记录表 vts_dealday
|
||||
type DealDay struct {
|
||||
ID int `db:"id"`
|
||||
CurrencyID int `db:"currencyid"` //
|
||||
CoinID int `db:"coinid"` //
|
||||
IsTrigger int `db:"istrigger"` //是否触发撮合-是:1,否:2
|
||||
Price float64 `db:"price"` //成交价格
|
||||
Num float64 `db:"num"` //成交数量
|
||||
CreateDate time.Time `db:"createdate"` //成交日期
|
||||
}
|
||||
|
||||
// PushNewDealNew Push new deal to redis
|
||||
type PushNewDealNew struct {
|
||||
Type int `json:"type"`
|
||||
Symbol string `json:"symbol"` //交易对,比如BTC-USDT
|
||||
Data [][]string `json:"data"`
|
||||
}
|
||||
|
||||
type PushNewDealNewStr struct {
|
||||
Type int `json:"type"`
|
||||
Symbol string `json:"symbol"` //交易对,比如BTC-USDT
|
||||
Data []string `json:"data"`
|
||||
}
|
||||
67
models/enums/klineconst.go
Normal file
67
models/enums/klineconst.go
Normal file
@ -0,0 +1,67 @@
|
||||
package enums
|
||||
|
||||
//k线周期
|
||||
const (
|
||||
KLINE_1MIN = 1 + iota
|
||||
KLINE_3MIN
|
||||
KLINE_5MIN
|
||||
KLINE_15MIN
|
||||
KLINE_30MIN
|
||||
KLINE_1H
|
||||
KLINE_2H
|
||||
KLINE_4H
|
||||
KLINE_6H
|
||||
KLINE_8H
|
||||
KLINE_12H
|
||||
KLINE_1DAY
|
||||
KLINE_3DAY
|
||||
KLINE_1WEEK
|
||||
KLINE_1MONTH
|
||||
KLINE_1YEAR
|
||||
)
|
||||
|
||||
var (
|
||||
ExchangeBinanceId = 2 //币安交易所id
|
||||
ExchangeHuoBiId = 1 //火币交易所id
|
||||
|
||||
//KlineTypeMap k类型对应整型数值
|
||||
KlineTypeMap = map[string]int{
|
||||
"1m": KLINE_1MIN,
|
||||
"3m": KLINE_3MIN,
|
||||
"5m": KLINE_5MIN,
|
||||
"15m": KLINE_15MIN,
|
||||
"30m": KLINE_30MIN,
|
||||
"1h": KLINE_1H,
|
||||
"2h": KLINE_2H,
|
||||
"4h": KLINE_4H,
|
||||
"6h": KLINE_6H,
|
||||
"8h": KLINE_8H,
|
||||
"12h": KLINE_12H,
|
||||
"1d": KLINE_1DAY,
|
||||
"3d": KLINE_3DAY,
|
||||
"1w": KLINE_1WEEK,
|
||||
"1M": KLINE_1MONTH,
|
||||
}
|
||||
|
||||
//KlineTypeStringMap k类型对应字符串数值
|
||||
KlineTypeStringMap = map[int]string{
|
||||
KLINE_1MIN: "1m",
|
||||
KLINE_3MIN: "3m",
|
||||
KLINE_5MIN: "5m",
|
||||
KLINE_15MIN: "15m",
|
||||
KLINE_30MIN: "30m",
|
||||
KLINE_1H: "1h",
|
||||
KLINE_2H: "2h",
|
||||
KLINE_4H: "4h",
|
||||
KLINE_6H: "6h",
|
||||
KLINE_8H: "8h",
|
||||
KLINE_12H: "12h",
|
||||
KLINE_1DAY: "1d",
|
||||
KLINE_3DAY: "3d",
|
||||
KLINE_1WEEK: "1w",
|
||||
KLINE_1MONTH: "1M",
|
||||
}
|
||||
)
|
||||
|
||||
//KLINE_PERIOD_1H
|
||||
//KLINE_PERIOD_3H
|
||||
172
models/futuresdto/futuresdto.go
Normal file
172
models/futuresdto/futuresdto.go
Normal file
@ -0,0 +1,172 @@
|
||||
package futuresdto
|
||||
|
||||
type FutureTicker24h struct {
|
||||
Symbol string `json:"symbol"` // 交易对符号 (e.g., BTCUSDT)
|
||||
PriceChange string `json:"priceChange"` // 24小时价格变动
|
||||
PriceChangePercent string `json:"priceChangePercent"` // 24小时价格变动百分比
|
||||
WeightedAvgPrice string `json:"weightedAvgPrice"` // 加权平均价
|
||||
LastPrice string `json:"lastPrice"` // 最近一次成交价
|
||||
LastQty string `json:"lastQty"` // 最近一次成交额
|
||||
OpenPrice string `json:"openPrice"` // 24小时内第一次成交的价格
|
||||
HighPrice string `json:"highPrice"` // 24小时最高价
|
||||
LowPrice string `json:"lowPrice"` // 24小时最低价
|
||||
Volume string `json:"volume"` // 24小时成交量
|
||||
QuoteVolume string `json:"quoteVolume"` // 24小时成交额
|
||||
OpenTime int64 `json:"openTime"` // 24小时内,第一笔交易的发生时间 (Unix timestamp)
|
||||
CloseTime int64 `json:"closeTime"` // 24小时内,最后一笔交易的发生时间 (Unix timestamp)
|
||||
FirstId int `json:"firstId"` // 首笔成交id
|
||||
LastId int `json:"lastId"` // 末笔成交id
|
||||
Count int `json:"count"` // 成交笔数
|
||||
}
|
||||
|
||||
type FundingInfo struct {
|
||||
Symbol string `json:"symbol"` // 交易对符号 (e.g., ORBSUSDT)
|
||||
MarkPrice string `json:"markPrice"` // 标记价格
|
||||
IndexPrice string `json:"indexPrice"` // 指数价格
|
||||
EstimatedSettlePrice string `json:"estimatedSettlePrice"` // 预计结算价格
|
||||
LastFundingRate string `json:"lastFundingRate"` // 最后一次资金费率
|
||||
InterestRate string `json:"interestRate"` // 利率
|
||||
NextFundingTime int64 `json:"nextFundingTime"` // 下次资金费用时间 (Unix timestamp)
|
||||
// Time int64 `json:"time"` // 当前时间 (Unix timestamp)
|
||||
}
|
||||
|
||||
type RateLimit struct {
|
||||
Interval string `json:"interval"` // 限制时间间隔 (e.g., MINUTE)
|
||||
IntervalNum int `json:"intervalNum"` // 间隔数量 (e.g., 1)
|
||||
Limit int `json:"limit"` // 限制次数
|
||||
RateLimitType string `json:"rateLimitType"` // 限制类型 (e.g., REQUEST_WEIGHT)
|
||||
}
|
||||
|
||||
type Asset struct {
|
||||
Asset string `json:"asset"` // 资产名称 (e.g., BUSD)
|
||||
MarginAvailable bool `json:"marginAvailable"` // 是否可用作保证金
|
||||
AutoAssetExchange *string `json:"autoAssetExchange"` // 自动兑换阈值 (可选)
|
||||
}
|
||||
|
||||
type Filter struct {
|
||||
FilterType string `json:"filterType"` // 过滤器类型 (e.g., PRICE_FILTER)
|
||||
MaxPrice *string `json:"maxPrice,omitempty"` // 最大价格 (可选)
|
||||
MinPrice *string `json:"minPrice,omitempty"` // 最小价格 (可选)
|
||||
TickSize *string `json:"tickSize,omitempty"` // 最小价格间隔 (可选)
|
||||
MaxQty *string `json:"maxQty,omitempty"` // 最大数量 (可选)
|
||||
MinQty *string `json:"minQty,omitempty"` // 最小数量 (可选)
|
||||
StepSize *string `json:"stepSize,omitempty"` // 最小数量间隔 (可选)
|
||||
Limit *int `json:"limit,omitempty"` // 限制 (可选)
|
||||
Notional *string `json:"notional,omitempty"` // 最小名义价值 (可选)
|
||||
MultiplierUp *string `json:"multiplierUp,omitempty"` // 价格上限百分比 (可选)
|
||||
MultiplierDown *string `json:"multiplierDown,omitempty"` // 价格下限百分比 (可选)
|
||||
// MultiplierDecimal *int `json:"multiplierDecimal,omitempty"` // 小数位数 (可选)
|
||||
}
|
||||
|
||||
type FutSymbol struct {
|
||||
Symbol string `json:"symbol"` // 交易对 (e.g., BLZUSDT)
|
||||
Pair string `json:"pair"` // 标的交易对
|
||||
ContractType string `json:"contractType"` // 合约类型
|
||||
DeliveryDate int64 `json:"deliveryDate"` // 交割日期 (Unix timestamp)
|
||||
OnboardDate int64 `json:"onboardDate"` // 上线日期 (Unix timestamp)
|
||||
Status string `json:"status"` // 交易对状态 (e.g., TRADING)
|
||||
BaseAsset string `json:"baseAsset"` // 标的资产
|
||||
QuoteAsset string `json:"quoteAsset"` // 报价资产
|
||||
MarginAsset string `json:"marginAsset"` // 保证金资产
|
||||
PricePrecision int `json:"pricePrecision"` // 价格小数点位数
|
||||
QuantityPrecision int `json:"quantityPrecision"` // 数量小数点位数
|
||||
BaseAssetPrecision int `json:"baseAssetPrecision"` // 标的资产精度
|
||||
QuotePrecision int `json:"quotePrecision"` // 报价资产精度
|
||||
UnderlyingType string `json:"underlyingType"` // 标的类型
|
||||
// UnderlyingSubType []string `json:"underlyingSubType"` // 子类型
|
||||
// SettlePlan int `json:"settlePlan"` // 结算计划
|
||||
TriggerProtect string `json:"triggerProtect"` // 触发保护阈值
|
||||
Filters []Filter `json:"filters"` // 过滤器列表
|
||||
// OrderType []string `json:"OrderType"` // 订单类型
|
||||
// TimeInForce []string `json:"timeInForce"` // 有效方式
|
||||
LiquidationFee string `json:"liquidationFee"` // 强平费率
|
||||
MarketTakeBound string `json:"marketTakeBound"` // 市价吃单最大偏离比例
|
||||
}
|
||||
|
||||
type FutExchangeInfo struct {
|
||||
// ExchangeFilters []interface{} `json:"exchangeFilters"` // 交易所过滤器
|
||||
RateLimits []RateLimit `json:"rateLimits"` // API访问限制
|
||||
ServerTime int64 `json:"serverTime"` // 服务器时间 (Unix timestamp)
|
||||
Assets []Asset `json:"assets"` // 资产信息
|
||||
Symbols []FutSymbol `json:"symbols"` // 交易对信息
|
||||
Timezone string `json:"timezone"` // 服务器时区
|
||||
}
|
||||
|
||||
// AllTickersResp 获取所有合约币--app
|
||||
type AllTickersResp struct {
|
||||
SymbolId int `json:"symbol_id"` // 交易对id
|
||||
CoinId int `json:"coin_id"` // 交易币id
|
||||
Coin string `json:"coin"` // 交易币
|
||||
PriceDigit int `json:"price_digit"` // 价格小数点位数
|
||||
AmountDigit int32 `json:"amount_digit"` // 基础币种计数精度
|
||||
Multiplier int `json:"multiplier"` // 合约乘数
|
||||
NewPrice string `json:"new_price"` // 最新价格
|
||||
DealAmt string `json:"deal_amt"` // 24小时成交总额-usd
|
||||
DealNum string `json:"deal_num"` // 24小时成交总额-张
|
||||
DealCoin string `json:"deal_coin"` // 24小时成交量-币
|
||||
Ratio string `json:"ratio"` // 涨跌幅
|
||||
MaxLever int `json:"max_lever"` //最大杠杆倍数
|
||||
UserLike int `json:"user_like"` // 是否自选
|
||||
FutType int `json:"fut_type"` // 数据类型 1==U本位数据 2==币本位数据
|
||||
}
|
||||
|
||||
// AllTickersRespPc 获取所有合约币--pc
|
||||
type AllTickersRespPc struct {
|
||||
SymbolId int `json:"symbol_id"` // 交易对id
|
||||
CoinId int `json:"coin_id"` // 交易币id
|
||||
Coin string `json:"coin"` // 交易币
|
||||
PriceDigit int `json:"price_digit"` // 价格小数点位数
|
||||
UserLike int `json:"user_like"` // 是否自选
|
||||
AmountDigit int32 `json:"amount_digit"` // 基础币种计数精度
|
||||
NewPrice string `json:"new_price"` // 最新价格
|
||||
DealAmt string `json:"deal_amt"` // 24小时成交总额-usd
|
||||
DealNum string `json:"deal_num"` // 24小时成交总额-张
|
||||
DealCoin string `json:"deal_coin"` // 24小时成交量-币
|
||||
Ratio string `json:"ratio"` // 涨跌幅
|
||||
HighPrice string `json:"high_price"` // 24小时最高价
|
||||
LowPrice string `json:"low_price"` // 24小时最小价格
|
||||
DisplaySort int `json:"display_sort"` // 排序号
|
||||
FutType int `json:"fut_type"` // 数据类型 1==U本位数据 2==币本位数据
|
||||
}
|
||||
|
||||
// MarketResp 获取单个合约币返回
|
||||
type MarketResp struct {
|
||||
SymbolId int `json:"symbol_id"` // 交易对id
|
||||
CoinId int `json:"coin_id"` // 交易币id
|
||||
Coin string `json:"coin"` // 交易币
|
||||
PriceDigit int `json:"price_digit"` // 价格小数点位数
|
||||
AmountDigit int `json:"amount_digit"` // 基础币种计数精度
|
||||
USDTDigit int `json:"usdt_digit"` // 基础币种计数精度
|
||||
Multiplier int `json:"multiplier"` //合约乘数
|
||||
NewPrice string `json:"new_price"` // 最新价格
|
||||
MinBuyVal string `json:"min_buy_val"` // 最小下单金额
|
||||
Ratio string `json:"ratio"` // 涨跌幅
|
||||
ImageStr string `json:"image_str"` // 币种图片
|
||||
DetailCode string `json:"detail_code"` // 币种全称
|
||||
DealNum string `json:"deal_num"` // 24小时成交量-张
|
||||
DealAmt string `json:"deal_amt"` // 24小时成交金额-usd
|
||||
DealCoin string `json:"deal_coin"` // 24小时成交量-币
|
||||
OpenPrice string `json:"open_price"` // 开盘价
|
||||
HighPrice string `json:"high_price"` // 24小时最高价
|
||||
LowPrice string `json:"low_price"` // 24小时最小价格
|
||||
MergeDepth string `json:"merge_depth"` // 合并深度 如:0.1,0.001,0.0001
|
||||
MarkPrice string `json:"mark_price"` // 标记价格
|
||||
IndexPrice string `json:"index_price"` // 指数价格
|
||||
FundRate string `json:"fund_rate"` //资金费率
|
||||
UserLike int `json:"user_like"` // 是否自选
|
||||
NextFundingSec int `json:"next_funding_sec"` // 距离下次收资金费用时间,多少秒
|
||||
}
|
||||
|
||||
type WsKline struct {
|
||||
Line string `json:"i"` // K线间隔,比如1m
|
||||
LineTime string `json:"t"` // k线时间撮
|
||||
Open string `json:"o"` // 这根K线期间第一笔成交价
|
||||
Close string `json:"c"` // 这根K线期间末一笔成交价
|
||||
High string `json:"h"` // 这根K线期间最高成交价
|
||||
Low string `json:"l"` // 这根K线期间最低成交价
|
||||
Volume string `json:"v"` // 这根K线期间成交量
|
||||
VolCoin string `json:"vc"` // 成交量-币
|
||||
QuoteVolume string `json:"q"` // 这根K线期间成交额
|
||||
Chg string `json:"chg"` //涨幅
|
||||
Ampl string `json:"ampl"` //震幅
|
||||
}
|
||||
55
models/futuresdto/futuresreceivedto.go
Normal file
55
models/futuresdto/futuresreceivedto.go
Normal file
@ -0,0 +1,55 @@
|
||||
package futuresdto
|
||||
|
||||
type OrderTriggerReject struct {
|
||||
Symbol string `json:"s"`
|
||||
OrderNo int `json:"i"`
|
||||
Reason string `json:"r"`
|
||||
}
|
||||
|
||||
type ReceiveBase struct {
|
||||
EventType string `json:"e"` // 事件类型
|
||||
EventTime int64 `json:"E"` // 事件时间
|
||||
MatchTime int64 `json:"T"` // 撮合时间
|
||||
}
|
||||
|
||||
type OrderTradeUpdate struct {
|
||||
ReceiveBase
|
||||
OrderDetails map[string]interface{} `json:"o"` // 订单详情
|
||||
}
|
||||
|
||||
type OrderDetails struct {
|
||||
Symbol string `json:"s"` // 交易对
|
||||
ClientOrderId string `json:"c"` // 客户端自定义订单ID
|
||||
Side string `json:"S"` // 订单方向
|
||||
OrderType string `json:"o"` // 订单类型
|
||||
TimeInForce string `json:"f"` // 有效方式
|
||||
OriginalQuantity string `json:"q"` // 订单原始数量
|
||||
OriginalPrice string `json:"p"` // 订单原始价格
|
||||
AveragePrice string `json:"ap"` // 订单平均价格
|
||||
StopPrice string `json:"sp"` // 条件订单触发价格,对追踪止损单无效
|
||||
ExecutionType string `json:"x"` // 本次事件的具体执行类型
|
||||
OrderStatus string `json:"X"` // 订单的当前状态
|
||||
OrderId int64 `json:"i"` // 订单ID
|
||||
LastFilledQuantity string `json:"l"` // 订单末次成交量
|
||||
CumulativeQuantity string `json:"z"` // 订单累计已成交量
|
||||
LastFilledPrice string `json:"L"` // 订单末次成交价格
|
||||
CommissionAsset string `json:"N"` // 手续费资产类型
|
||||
CommissionAmount string `json:"n"` // 手续费数量
|
||||
TransactionTime int64 `json:"T"` // 成交时间
|
||||
TradeId int64 `json:"t"` // 成交ID
|
||||
BidValue string `json:"b"` // 买单净值
|
||||
AskValue string `json:"a"` // 卖单净值
|
||||
IsMaker bool `json:"m"` // 该成交是作为挂单成交吗?
|
||||
ReduceOnly bool `json:"R"` // 是否是只减仓单
|
||||
TriggerPriceType string `json:"wt"` // 触发价类型
|
||||
OriginalOrderType string `json:"ot"` // 原始订单类型
|
||||
PositionSide string `json:"ps"` // 持仓方向
|
||||
ClosePosition bool `json:"cp"` // 是否为触发平仓单
|
||||
ActivationPrice string `json:"AP"` // 追踪止损激活价格
|
||||
CallbackRate string `json:"cr"` // 追踪止损回调比例
|
||||
TriggerProtection bool `json:"pP"` // 是否开启条件单触发保护
|
||||
RealizedProfitLoss string `json:"rp"` // 该交易实现盈亏
|
||||
PreventSelfTrade string `json:"V"` // 自成交防止模式
|
||||
PriceMatchingMode string `json:"pm"` // 价格匹配模式
|
||||
GTDCancelTime int64 `json:"gtd"` // TIF为GTD的订单自动取消时间
|
||||
}
|
||||
60
models/liquidation.go
Normal file
60
models/liquidation.go
Normal file
@ -0,0 +1,60 @@
|
||||
package models
|
||||
|
||||
import "github.com/shopspring/decimal"
|
||||
|
||||
//Liquidation 强平计算公式字段
|
||||
type Liquidation struct {
|
||||
WalletBalance decimal.Decimal //账户余额,钱包余额= 1,535,443.01
|
||||
TMM1 decimal.Decimal //(TMM1)其它合约下的全部保证金(除合约1外)= 71200.81144,维持保证金=名义价值*维持保证金率-维持保证金速算額,名义价值=价格*数量,拿标记价格计算
|
||||
UPNL1 decimal.Decimal //全部其它合约的未实现盈亏(除合约1外)= -56,249.35
|
||||
CumB decimal.Decimal //单向模式下合约1的维持保证金速算額= 135,365.00
|
||||
CumL decimal.Decimal //开多合约1下的维持保证金速算額(双向持仓模式)= 0
|
||||
CumS decimal.Decimal //开空合约1下的维持保证金速算額(双向持仓模式)= 0
|
||||
Side1BOTH int //合约1的方向(单向持仓模式);“1”代表开多持仓;“-1”代表开空持仓= 1
|
||||
Position1BOTH decimal.Decimal //合约1的持仓大小(单向持仓模式);无论开多或开空,取绝对值= 3,683.979
|
||||
EP1BOTH decimal.Decimal //合约1的头寸价格(单向持仓模式)=1,456.84
|
||||
Position1LONG decimal.Decimal //开多仓位大小(双向持仓模式);无论开多或开空,取绝对值= 0
|
||||
EP1LONG decimal.Decimal //开多持仓的头寸(双向持仓模式);无论开多或开空,取绝对值= 0
|
||||
Position1SHORT decimal.Decimal //开空仓位大小(双向持仓模式);无论开多或开空,取绝对值= 0
|
||||
EP1SHORT decimal.Decimal //开空持仓的头寸(双向持仓模式);无论开多或开空,取绝对值= 0
|
||||
MMRB decimal.Decimal //单向持仓模式合约的维持保证金费率= 10%
|
||||
MMRL decimal.Decimal //开多合约的维持保证金费率(双向持仓模式)= 0
|
||||
MMRS decimal.Decimal //开空合约的维持保证金费率(双向持仓模式)= 0
|
||||
}
|
||||
|
||||
//CalculateLiquidationPrice 计算强平公式
|
||||
func (lq Liquidation) CalculateLiquidationPrice() decimal.Decimal {
|
||||
//d1=WB-TMM1+UPNL1+CumB+CumL+CumS-Side1BOTH*Position1BOTH*EP1BOTH-Position1LONG*EP1LONG+Position1SHORT*EP1SHORT
|
||||
t1 := lq.WalletBalance
|
||||
if lq.TMM1.Cmp(decimal.Zero) != 0 {
|
||||
t1 = t1.Sub(lq.TMM1)
|
||||
}
|
||||
if lq.UPNL1.Cmp(decimal.Zero) != 0 {
|
||||
t1 = t1.Add(lq.UPNL1)
|
||||
}
|
||||
if lq.CumB.Cmp(decimal.Zero) != 0 {
|
||||
t1 = t1.Add(lq.CumB)
|
||||
}
|
||||
if lq.CumL.Cmp(decimal.Zero) != 0 {
|
||||
t1 = t1.Add(lq.CumL)
|
||||
}
|
||||
if lq.CumS.Cmp(decimal.Zero) != 0 {
|
||||
t1 = t1.Add(lq.CumS)
|
||||
}
|
||||
|
||||
position1BOTH := lq.Position1BOTH
|
||||
side1BOTH := decimal.NewFromInt32(int32(lq.Side1BOTH))
|
||||
position1LONG := lq.Position1LONG
|
||||
position1SHORT := lq.Position1SHORT
|
||||
|
||||
d1 := t1.Sub(side1BOTH.Mul(position1BOTH).Mul(lq.EP1BOTH)).
|
||||
Sub(position1LONG.Mul(lq.EP1LONG)).Add(position1SHORT.Mul(lq.EP1SHORT))
|
||||
|
||||
//d2=Position1BOTH*MMRB+Position1LONG*MMRL+Position1SHORT*MMRS-Side1BOTH*Position1BOTH-Position1LONG+Position1SHORT
|
||||
t2 := position1BOTH.Mul(lq.MMRB).Add(position1LONG.Mul(lq.MMRL)).Add(position1SHORT.Mul(lq.MMRS))
|
||||
t2 = t2.Sub(side1BOTH.Mul(position1BOTH))
|
||||
d2 := t2.Sub(position1LONG).Add(position1SHORT)
|
||||
//LP1= d1/d2
|
||||
|
||||
return d1.Div(d2)
|
||||
}
|
||||
141
models/market.go
Normal file
141
models/market.go
Normal file
@ -0,0 +1,141 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// Ticker24 24小时统计
|
||||
type Ticker24 struct {
|
||||
ChangePercent string `json:"change"` //24小时价格变动百分比
|
||||
LastPrice string `json:"last"` //最新价格
|
||||
OpenPrice string `json:"open"` //24小时开盘价格
|
||||
HighPrice string `json:"high"` //24小时最高价
|
||||
LowPrice string `json:"low"` //24小时最低价
|
||||
Volume string `json:"volume"` //24小时成数量
|
||||
QuoteVolume string `json:"quote"` //24小时成交金额
|
||||
Symbol string `json:"-"`
|
||||
E int64 `json:"-"` //推送时间
|
||||
}
|
||||
|
||||
type Kline struct {
|
||||
Pair string
|
||||
Timestamp int64
|
||||
Open string
|
||||
Close string
|
||||
High string
|
||||
Low string
|
||||
Vol string
|
||||
QuoteVolume string //成交金额
|
||||
}
|
||||
|
||||
type DepthRecord struct {
|
||||
Price float64
|
||||
Amount float64
|
||||
}
|
||||
|
||||
type DepthRecords []DepthRecord
|
||||
|
||||
func (dr DepthRecords) Len() int {
|
||||
return len(dr)
|
||||
}
|
||||
|
||||
func (dr DepthRecords) Swap(i, j int) {
|
||||
dr[i], dr[j] = dr[j], dr[i]
|
||||
}
|
||||
|
||||
func (dr DepthRecords) Less(i, j int) bool {
|
||||
return dr[i].Price < dr[j].Price
|
||||
}
|
||||
|
||||
type Depth struct {
|
||||
ContractType string //for future
|
||||
Pair string
|
||||
UTime time.Time
|
||||
AskList DepthRecords // Descending order 卖盘,[price(挂单价), vol(此价格挂单张数)], 按price升序
|
||||
BidList DepthRecords // Descending order 买盘,[price(挂单价), vol(此价格挂单张数)], 按price降序
|
||||
}
|
||||
|
||||
// DepthBin 币安深度
|
||||
type DepthBin struct {
|
||||
Symbol string `json:"s"`
|
||||
Bids [][]string `json:"bids"`
|
||||
Asks [][]string `json:"asks"`
|
||||
}
|
||||
|
||||
type UFuturesDepthBin struct {
|
||||
Symbol string `json:"s"`
|
||||
Bids [][]string `json:"b"`
|
||||
Asks [][]string `json:"a"`
|
||||
}
|
||||
|
||||
// NewDealPush 最近成交记录
|
||||
type NewDealPush struct {
|
||||
Price float64 `json:"price"` //成交价格
|
||||
Num float64 `json:"num"` //成交数量
|
||||
Type int `json:"type"` //1买,2卖
|
||||
DealId int64 `json:"dealid"` //交易id
|
||||
CreateTime int64 `json:"createtime"` //交易时间
|
||||
//Symbol string `json:"symbol"`
|
||||
//ExchangeId int `json:"exchangeid"`
|
||||
}
|
||||
|
||||
// ForceOrder 强平订单exc_forceorder
|
||||
type ForceOrder struct {
|
||||
ExchangeID int `db:"exchangeid"`
|
||||
Symbol string `db:"symbol"`
|
||||
Side string `db:"side"` //请买卖方向 SELL, BUY
|
||||
Ordertype string `db:"ordertype"` //订单类型 LIMIT, MARKET, STOP, TAKE_PROFIT, STOP_MARKET, TAKE_PROFIT_MARKET, TRAILING_STOP_MARKET
|
||||
TimeInForce string `db:"timeinforce"` //有效方式,GTC 1,IOC 2,FOK 3,GTX 4
|
||||
Price float64 `db:"price"` //价格
|
||||
Num float64 `db:"num"` //数量
|
||||
AvgPrice float64 `db:"avgprice"` //平均价格
|
||||
State string `db:"state"` //订单状态
|
||||
CreateTime time.Time `db:"createtime"`
|
||||
}
|
||||
|
||||
type FiveItem struct {
|
||||
Buy [][]string `json:"buy"`
|
||||
Sell [][]string `json:"sell"`
|
||||
BuyNum float64 `json:"buynum"`
|
||||
SellNum float64 `json:"sellnum"`
|
||||
}
|
||||
|
||||
// AlertSet vts_alertset
|
||||
type AlertSet struct {
|
||||
Id int `db:"id"`
|
||||
UserId int `db:"userid"`
|
||||
CoinId int `db:"coinid"`
|
||||
CurrencyId int `db:"currencyid"`
|
||||
AlertType int `db:"alerttype"` //预警类型:1价格涨到,2价格跌到,3涨幅达到,4跌幅达到,5-24小时涨幅,6-24小时跌幅
|
||||
Frequency int `db:"frequency"` //提醒频率:1仅提醒一次,2每日提醒一次,3持续提醒(每当价格达到该值,则提醒一次)
|
||||
State int `db:"state"` //设置状态:1正常,2停止(比如频率是只提醒一次,提醒一次完就修改为2)
|
||||
AlwaysState int `db:"alwaysstate"` //持续提醒状态:1已提醒,0可提醒
|
||||
AlertValue float64 `db:"alertvalue"` //提醒值
|
||||
SendTime time.Time `db:"sendtime"` //发送时间,每日提醒+持续提醒需要
|
||||
|
||||
}
|
||||
|
||||
type PriceMarket struct {
|
||||
Price float64 //最新价格
|
||||
Rate24h float64 //24小时涨幅
|
||||
Symbol string //交易对
|
||||
}
|
||||
|
||||
// AlertLog vts_alertlog提醒记录
|
||||
type AlertLog struct {
|
||||
Id int `db:"id"`
|
||||
UserId int `db:"userid"`
|
||||
AlertId int `db:"alertid"`
|
||||
AlertValue float64 `db:"alertvalue"`
|
||||
Coin string `db:"coin"`
|
||||
Currency string `db:"currency"`
|
||||
Msg string `db:"msg"`
|
||||
CreateTime time.Time `db:"createtime"`
|
||||
}
|
||||
|
||||
type AlertMq struct {
|
||||
UserId int
|
||||
AlertId int
|
||||
AlertValue string
|
||||
Symbol string //格式:BTC/USDT
|
||||
Msg string
|
||||
CreateTime int64
|
||||
}
|
||||
12
models/ossdto/oss.go
Normal file
12
models/ossdto/oss.go
Normal file
@ -0,0 +1,12 @@
|
||||
package ossdto
|
||||
|
||||
type OssTokenResponse struct {
|
||||
AccessKeyId string `json:"accessKeyId"`
|
||||
AccessKeySecret string `json:"accessKeySecret"`
|
||||
SecurityToken string `json:"securityToken"`
|
||||
Expiration string `json:"expiration"`
|
||||
Policy string `json:"policy"`
|
||||
Signature string `json:"signature"`
|
||||
Host string `json:"host"`
|
||||
Dir string `json:"dir"`
|
||||
}
|
||||
95
models/pushdata.go
Normal file
95
models/pushdata.go
Normal file
@ -0,0 +1,95 @@
|
||||
package models
|
||||
|
||||
var (
|
||||
Pre24hrTicker = "24hrTicker" //ticker推送前缀,推送格式:<symbol>@24hrTicker
|
||||
PreTrade = "trade" //最新成交推送前缀 <symbol>@trade
|
||||
PreKline = "kline" //k线推送前缀 <symbol>@kline_<interval>
|
||||
PreDepth = "depth" //深度推送前缀 <symbol>@depth<levels>
|
||||
PreDepth35 = "depth35" //35深度推送前缀 <symbol>@depth<levels>
|
||||
PreMarkPrice = "markPrice" //最新标记价 <symbol>@markPrice
|
||||
TickerArr = "ticker@arr" //所有24小时行情
|
||||
PreErr = "err"
|
||||
)
|
||||
|
||||
type PushFive struct {
|
||||
Type int `json:"type"` //类型
|
||||
Num string `json:"num"` //买卖总数量
|
||||
Symbol string `json:"symbol"` //交易对,比如BTC-USDT
|
||||
Data [][]string `json:"data"` //数据
|
||||
}
|
||||
|
||||
type PushAll struct {
|
||||
Event string `json:"e"`
|
||||
Data []WsTicker `json:"data"`
|
||||
}
|
||||
type PushKline struct {
|
||||
Type int `json:"type"`
|
||||
Symbol string `json:"symbol"` //交易对,比如BTC-USDT
|
||||
Data [][]string `json:"data"`
|
||||
}
|
||||
|
||||
type WsWsTickerBase struct {
|
||||
Event string `json:"e"`
|
||||
Symbol string `json:"s"` //交易对,比如BTC-USDT
|
||||
Data WsTicker `json:"data"` //
|
||||
}
|
||||
|
||||
// WsTicker 24小时行情推送
|
||||
type WsTicker struct {
|
||||
E int64 `json:"-"` //时间戳
|
||||
Symbol string `json:"s"` //symbol,BTC-USDT
|
||||
Close string `json:"c"` //收盘价格,也是最新价格
|
||||
Open string `json:"o"` //开盘价格
|
||||
High string `json:"h"` //最高价格
|
||||
Low string `json:"l"` //最低价格
|
||||
Volume string `json:"v"` //成交量
|
||||
QuoteVolume string `json:"q"` //成交额
|
||||
Change string `json:"chg"` //涨幅
|
||||
RatePrice string `json:"rp"` //最新价格等于多少usdt
|
||||
|
||||
}
|
||||
|
||||
type WsBase struct {
|
||||
Event string `json:"e"`
|
||||
Symbol string `json:"s"` //交易对,比如BTC-USDT
|
||||
Data interface{} `json:"data"` //
|
||||
}
|
||||
|
||||
type WsTrade struct {
|
||||
Price string `json:"p"` //成交价格
|
||||
Quantity string `json:"q"` //成交数量
|
||||
DealTime string `json:"t"` //时间撮
|
||||
Market string `json:"m"` //1是买方主动触发交易,2卖方主动触发交易
|
||||
}
|
||||
|
||||
type BaseKline struct {
|
||||
Event string `json:"e"` //事件
|
||||
Symbol string `json:"s"` //交易对,比如BTC-USDT
|
||||
Data WsKline `json:"data"` //k线数据
|
||||
}
|
||||
|
||||
type WsKline struct {
|
||||
Line string `json:"i"` // K线间隔,比如1m
|
||||
LineTime string `json:"t"` // k线时间撮
|
||||
Open string `json:"o"` // 这根K线期间第一笔成交价
|
||||
Close string `json:"c"` // 这根K线期间末一笔成交价
|
||||
High string `json:"h"` // 这根K线期间最高成交价
|
||||
Low string `json:"l"` // 这根K线期间最低成交价
|
||||
Volume string `json:"v"` // 这根K线期间成交量
|
||||
QuoteVolume string `json:"q"` // 这根K线期间成交额
|
||||
Chg string `json:"chg"` // 涨幅
|
||||
Ampl string `json:"ampl"` // 震幅
|
||||
}
|
||||
|
||||
type WsFive struct {
|
||||
Event string `json:"e"` //事件
|
||||
Symbol string `json:"s"` //比如BTC-USDT
|
||||
Bid [][]string `json:"bid"` //买盘口
|
||||
Ask [][]string `json:"ask"` //卖盘口
|
||||
}
|
||||
|
||||
type WsMarkPrice struct {
|
||||
Event string `json:"e"`
|
||||
Symbol string `json:"s"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
}
|
||||
10
models/rabbitmqdto/ApiKeyWebSocket.go
Normal file
10
models/rabbitmqdto/ApiKeyWebSocket.go
Normal file
@ -0,0 +1,10 @@
|
||||
package rabbitmqdto
|
||||
|
||||
//api key 连接
|
||||
type ApiKeyWSConnect struct {
|
||||
ApiKey string `json:"apiKey"`
|
||||
ApiSecret string `json:"apiSecret"`
|
||||
ProxyType string `json:"proxyType"`
|
||||
ProxyAddress string `json:"proxyAddress"`
|
||||
Type int `json:"type" comment:"1-订阅 0-取消订阅"`
|
||||
}
|
||||
72
models/spot/spotdto.go
Normal file
72
models/spot/spotdto.go
Normal file
@ -0,0 +1,72 @@
|
||||
package spot
|
||||
|
||||
type SpotTicker24h struct {
|
||||
Symbol string `json:"symbol"` // 交易对符号 (e.g., BNBBTC)
|
||||
PriceChange string `json:"priceChange"` // 24小时价格变动
|
||||
PriceChangePercent string `json:"priceChangePercent"` // 24小时价格变动百分比
|
||||
WeightedAvgPrice string `json:"weightedAvgPrice"` // 加权平均价
|
||||
PrevClosePrice string `json:"prevClosePrice"` // 前一个收盘价
|
||||
LastPrice string `json:"lastPrice"` // 最近一次成交价
|
||||
LastQty string `json:"lastQty"` // 最近一次成交量
|
||||
BidPrice string `json:"bidPrice"` // 当前买单价
|
||||
BidQty string `json:"bidQty"` // 当前买单量
|
||||
AskPrice string `json:"askPrice"` // 当前卖单价
|
||||
AskQty string `json:"askQty"` // 当前卖单量
|
||||
OpenPrice string `json:"openPrice"` // 24小时内第一次成交的价格
|
||||
HighPrice string `json:"highPrice"` // 24小时最高价
|
||||
LowPrice string `json:"lowPrice"` // 24小时最低价
|
||||
Volume string `json:"volume"` // 24小时成交量
|
||||
QuoteVolume string `json:"quoteVolume"` // 24小时成交额
|
||||
OpenTime int64 `json:"openTime"` // 24小时内,第一笔交易的发生时间 (Unix timestamp)
|
||||
CloseTime int64 `json:"closeTime"` // 24小时内,最后一笔交易的发生时间 (Unix timestamp)
|
||||
FirstId int `json:"firstId"` // 首笔成交id
|
||||
LastId int `json:"lastId"` // 末笔成交id
|
||||
Count int `json:"count"` // 成交笔数
|
||||
}
|
||||
|
||||
type RateLimit struct {
|
||||
// 定义在 "限制种类 (rateLimitType)" 部分的限制
|
||||
}
|
||||
|
||||
type ExchangeFilter struct {
|
||||
// 定义在 "过滤器" 部分的过滤器
|
||||
FilterType string `json:"filterType"` //类别
|
||||
MinPrice string `json:"minPrice"` //最小金额
|
||||
MaxPrice string `json:"maxPrice"` //最大金额
|
||||
TickSize string `json:"tickSize"` //最小精度
|
||||
|
||||
MinQty string `json:"minQty"` //最小购买数量
|
||||
MaxQty string `json:"maxQty"` //最大购买数量
|
||||
StepSize string `json:"stepSize"` //数量最小精度
|
||||
}
|
||||
|
||||
type Symbol struct {
|
||||
Symbol string `json:"symbol"` // 交易对符号 (e.g., ETHBTC)
|
||||
Status string `json:"status"` // 当前状态 (e.g., TRADING)
|
||||
BaseAsset string `json:"baseAsset"` // 基础资产 (e.g., ETH)
|
||||
BaseAssetPrecision int `json:"baseAssetPrecision"` // 基础资产精度
|
||||
QuoteAsset string `json:"quoteAsset"` // 报价资产 (e.g., BTC)
|
||||
QuotePrecision int `json:"quotePrecision"` // 报价资产精度
|
||||
QuoteAssetPrecision int `json:"quoteAssetPrecision"` // 报价资产的精度
|
||||
OrderTypes []string `json:"orderTypes"` // 支持的订单类型
|
||||
IcebergAllowed bool `json:"icebergAllowed"` // 是否允许冰山订单
|
||||
OcoAllowed bool `json:"ocoAllowed"` // 是否允许 OCO (One Cancels the Other) 订单
|
||||
QuoteOrderQtyMarketAllowed bool `json:"quoteOrderQtyMarketAllowed"` // 是否允许市场单的报价订单数量
|
||||
AllowTrailingStop bool `json:"allowTrailingStop"` // 是否允许跟踪止损
|
||||
IsSpotTradingAllowed bool `json:"isSpotTradingAllowed"` // 是否允许现货交易
|
||||
IsMarginTradingAllowed bool `json:"isMarginTradingAllowed"` // 是否允许保证金交易
|
||||
CancelReplaceAllowed bool `json:"cancelReplaceAllowed"` // 是否允许取消替代
|
||||
Filters []ExchangeFilter `json:"filters"` // 过滤器,定义在 "过滤器" 部分
|
||||
Permissions []string `json:"permissions"` // 权限
|
||||
PermissionSets [][]string `json:"permissionSets"` // 权限集
|
||||
DefaultSelfTradePreventionMode string `json:"defaultSelfTradePreventionMode"` // 默认的自我交易防止模式
|
||||
AllowedSelfTradePreventionModes []string `json:"allowedSelfTradePreventionModes"` // 允许的自我交易防止模式
|
||||
}
|
||||
|
||||
type ExchangeInfo struct {
|
||||
Timezone string `json:"timezone"` // 时区 (e.g., UTC)
|
||||
ServerTime int64 `json:"serverTime"` // 服务器时间 (Unix timestamp)
|
||||
RateLimits []RateLimit `json:"rateLimits"` // 速率限制,定义在 "限制种类" 部分
|
||||
ExchangeFilters []ExchangeFilter `json:"exchangeFilters"` // 交易所过滤器,定义在 "过滤器" 部分
|
||||
Symbols []Symbol `json:"symbols"` // 交易对列表
|
||||
}
|
||||
Reference in New Issue
Block a user