Documentation ¶
Index ¶
- Variables
- func AutoMigrations()
- func InitAllCurrencies(db *utils.GormDB)
- func InitAllMarkets(db *utils.GormDB)
- type Account
- func (account *Account) AfterSave(db *gorm.DB)
- func (account *Account) Amount() (amount decimal.Decimal)
- func (account *Account) LockFunds(db *utils.GormDB, amount decimal.Decimal, reason, modifiableId int, ...) (err error)
- func (account *Account) PlusFunds(db *utils.GormDB, amount, fee decimal.Decimal, reason, modifiableId int, ...) (err error)
- func (account *Account) SubFunds(db *utils.GormDB, amount, fee decimal.Decimal, reason, modifiableId int, ...) (err error)
- func (account *Account) UnlockFunds(db *utils.GormDB, amount decimal.Decimal, reason, modifiableId int, ...) (err error)
- func (account *Account) UnlockedAndSubFunds(db *utils.GormDB, amount, locked, fee decimal.Decimal, ...) (err error)
- type AccountVersion
- type AccountVersionCheckPoint
- type ApiToken
- type Attrs
- type CommonModel
- type Currency
- type Device
- type Fee
- type Identity
- type KLine
- type Market
- func (market *Market) AfterCreate(db *gorm.DB)
- func (market *Market) AfterFind(db *gorm.DB)
- func (market *Market) AskRedisKey() string
- func (market *Market) BidRedisKey() string
- func (market *Market) KLineNotify(period int64) string
- func (market *Market) KLineRedisKey(period int64) string
- func (market *Market) LatestTradesRedisKey() string
- func (assignment *Market) MatchingExchange() string
- func (assignment *Market) MatchingQueue() string
- func (assignment *Market) OrderCancelExchange() string
- func (assignment *Market) OrderCancelQueue() string
- func (market *Market) TickerNotify() string
- func (market *Market) TickerRedisKey() string
- func (assignment *Market) TradeTreatExchange() string
- func (assignment *Market) TradeTreatQueue() string
- type MatchingPayload
- type Order
- func (order *Order) AfterFind(db *gorm.DB)
- func (order *Order) CalculationAvgPrice()
- func (order *Order) Fee() (fee decimal.Decimal)
- func (order *Order) InitStateStr()
- func (order *Order) OType() string
- func (order *Order) OrderAttrs() (attrs map[string]string)
- func (order *Order) Strike(db *utils.GormDB, trade Trade) (err error)
- type OrderCurrency
- type OrderJson
- type Ticker
- type TickerAspect
- type Token
- type Trade
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UNKNOWN = 0 FIX = 1 STRIKE_FEE = 100 STRIKE_ADD = 110 STRIKE_SUB = 120 STRIKE_UNLOCK = 130 ORDER_SUBMIT = 600 ORDER_CANCEL = 610 ORDER_FULLFILLED = 620 TRANSFER = 700 TRANSFER_BACK = 710 WALLET_TRANSFER = 720 WALLET_TRANSFER_BACK = 730 WALLET_TRANSFER_LOCK = 735 WALLET_TRANSFER_UNLOCK = 736 WITHDRAW_LOCK = 800 WITHDRAW_UNLOCK = 810 DEPOSIT = 1000 WITHDRAW = 2000 AWARD = 3000 OTC_ORDER_SUBMIT = 900 OTC_ORDER_FINISHED = 910 OTC_ORDER_FINISHED_2 = 911 OTC_ORDER_CANCELLED = 920 OTC_ORDER_CANCELLED_2 = 921 OPTION_DEPOSIT = 1100 OPTION_UNLOCK = 1200 OPTION_CANCEL = 1500 PROFIT_LOCK = 1300 PROFIT_UNLOCK = 1400 RECYCLE_TRANS_FEE = 1600 FUNS = map[string]int{ "UnlockFunds": 1, "LockFunds": 2, "PlusFunds": 3, "SubFunds": 4, "UnlockedAndSubFunds": 5, } )
View Source
var ( CANCEL = 0 WAIT = 100 DONE = 200 )
View Source
var AllCurrencies []Currency
View Source
var AllMarkets []Market
View Source
var (
TickersRedisKey = "goDCE:tickers"
)
Functions ¶
func AutoMigrations ¶
func AutoMigrations()
func InitAllCurrencies ¶
func InitAllMarkets ¶
Types ¶
type Account ¶
type Account struct { CommonModel UserId int `json:"user_id"` CurrencyId int `json:"currency_id"` Balance decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"balance"` Locked decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"locked"` }
func (*Account) UnlockFunds ¶
type AccountVersion ¶
type AccountVersion struct { CommonModel UserId int `json:"user_id"` AccountId int `json:"account_id"` Reason int `json:"reason"` Balance decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"balance"` Locked decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"locked"` Fee decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"fee"` Amount decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"amount"` ModifiableId int `json:"modifiable_id"` ModifiableType string `json:"modifiable_type"` CurrencyId int `json:"currency_id"` Fun int `json:"fun"` }
type AccountVersionCheckPoint ¶
type AccountVersionCheckPoint struct { CommonModel AccountVersionId int `json:"account_version_id"` UserId int `json:"user_id"` AccountId int `json:"account_id"` Fixed string `json:"fixed"` FixedNum decimal.Decimal `json:"fixed_num" gorm:"type:decimal(32,16)"` Balance decimal.Decimal `json:"balance" gorm:"type:decimal(32,16)"` }
type ApiToken ¶
type ApiToken struct { CommonModel UserId int `json:"user_id"` AccessKey string `gorm:"type:varchar(64)" json:"access_key"` SecretKey string `gorm:"type:varchar(64)" json:"secret_key"` Label string `gorm:"type:varchar(32)" json:"label"` Scopes string `gorm:"type:varchar(32)" json:"scopes"` ExpireAt time.Time `json:"expire_at" gorm:"default:null"` DeletedAt time.Time `json:"-" gorm:"default:null"` }
type CommonModel ¶
type Currency ¶
type Currency struct { CommonModel Key string `json:"key"` Code string `json:"code"` Symbol string `json:"-"` Coin bool `json:"coin"` Precision int `json:"precision"` Erc20 bool `json:"erc20"` Erc23 bool `json:"erc23"` Visible bool `json:"visible"` Tradable bool `json:"tradable"` Depositable bool `json:"depositable"` }
func (*Currency) IsEthereum ¶
type Device ¶
type Device struct { CommonModel UserId int `json:"user_id"` IsUsed bool `json:"is_used"` Token string `json:"token" gorm:"type:varchar(64)"` PublicKey string `json:"-"` }
func (*Device) InitializeToken ¶
func (device *Device) InitializeToken()
type Identity ¶
type Identity struct { CommonModel UserId int `json:"user_id"` Source string `json:"source" gorm:"type:varchar(32)"` // Email or Phone, Symbol string `json:"symbol" gorm:"type:varchar(64)"` // Email address or Phone number }
type KLine ¶
type KLine struct { CommonModel MarketId int `json:"market_id"` Period int `json:"period"` Timestamp int64 `json:"timestamp"` // 时间戳 Open decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"open"` // 开盘价 High decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"high"` // 最高价 Low decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"low"` // 最低价 Close decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"close"` // 收盘价 Volume decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"volume"` // 交易量 }
type Market ¶
type Market struct { CommonModel Name string `json:"name"" gorm:"type:varchar(16)"` Code string `json:"code" gorm:"type:varchar(16)"` PriceGroupFixed int `json:"price_group_fixed"` SortOrder int `json:"sort_order"` AskCurrencyId int `json:"ask_currency_id"` BidCurrencyId int `json:"bid_currency_id"` AskFee decimal.Decimal `json:"ask_fee" gorm:"type:decimal(32,16);default:null;"` BidFee decimal.Decimal `json:"bid_fee" gorm:"type:decimal(32,16);default:null;"` AskFixed int `json:"ask_fixed"` BidFixed int `json:"bid_fixed"` Visible bool `json:"visible"` Tradable bool `json:"tradable"` // 暂存数据 Ticker *TickerAspect `sql:"-" json:"ticker"` LatestKLines map[int]KLine `sql:"-" json:"-"` // 撮合相关属性 Ack bool `json:"-"` Durable bool `json:"-"` MatchingAble bool `json:"-"` MatchingNode string `json:"-" gorm:"default:'a'; type:varchar(11)"` TradeTreatNode string `json:"-" gorm:"default:'a'; type:varchar(11)"` OrderCancelNode string `json:"-" gorm:"default:'a'; type:varchar(11)"` Running bool `json:"-" sql:"-"` Matching string `json:"-"` TradeTreat string `json:"-"` OrderCancel string `json:"-"` }
func FindAllMarket ¶
func FindAllMarket() []Market
func FindMarketByCode ¶
func FindMarketById ¶
func (*Market) AfterCreate ¶
func (*Market) AskRedisKey ¶
func (*Market) BidRedisKey ¶
func (*Market) KLineRedisKey ¶
func (*Market) LatestTradesRedisKey ¶
func (*Market) OrderCancelExchange ¶
func (*Market) OrderCancelQueue ¶
func (*Market) TickerNotify ¶
func (*Market) TickerRedisKey ¶
func (*Market) TradeTreatExchange ¶
func (*Market) TradeTreatQueue ¶
type MatchingPayload ¶
func (*MatchingPayload) OrderAttrs ¶
func (mp *MatchingPayload) OrderAttrs() (attrs map[string]string)
type Order ¶
type Order struct { CommonModel UserId int `json:"user_id"` AskAccountId int `json:"ask_account_id" gorm:"default:null"` BidAccountId int `json:"bid_account_id" gorm:"default:null"` MarketId int `json:"market_id"` State int `json:"-"` Type string `gorm:"type:varchar(16)" json:"type"` Sn string `gorm:"type:varchar(16)" json:"sn" gorm:"default:null"` Source string `gorm:"type:varchar(16)" json:"source"` OrderType string `gorm:"type:varchar(16)" json:"order_type"` Price decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"price"` Volume decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"volume"` OriginVolume decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"origin_volume"` Locked decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"locked"` OriginLocked decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"origin_locked"` FundsReceived decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"funds_received"` TradesCount int `json:"trades_count"` Market Market `sql:"-" json:"-"` StateStr string `sql:"-" json:"state"` AvgPrice decimal.Decimal `sql:"-" json:"avg_price"` // contains filtered or unexported fields }
func (*Order) CalculationAvgPrice ¶
func (order *Order) CalculationAvgPrice()
func (*Order) InitStateStr ¶
func (order *Order) InitStateStr()
func (*Order) OrderAttrs ¶
type OrderCurrency ¶
type Ticker ¶
type Ticker struct { MarketId int `json:"market_id"` At int64 `json:"at"` Name string `json:"name"` TickerAspect *TickerAspect `json:"ticker"` }
type TickerAspect ¶
type Token ¶
type Token struct { CommonModel Token string `gorm:"type:varchar(64)" json:"token"` UserId int `json:"user_id"` IsUsed bool `json:"is_used"` ExpireAt time.Time `gorm:"default:null" json:"expire_at"` LastVerifyAt time.Time `gorm:"default:null" json:"last_verify_at"` }
func (*Token) InitializeLoginToken ¶
func (token *Token) InitializeLoginToken()
type Trade ¶
type Trade struct { CommonModel Trend int `json:"trend"` MarketId int `json:"market_id"` AskId int `json:"ask_id"` BidId int `json:"bid_id"` Price decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"price"` Volume decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"volume"` Funds decimal.Decimal `gorm:"type:decimal(32,16);default:null;" json:"funds"` Side string `json:"side" sql:"-" gorm:"type:varchar(4)"` Market Market `json:"market" sql:"-"` AskUserId int `json:"ask_user_id"` BidUserId int `json:"bid_user_id"` AskFee Fee `json:"ask_fee" sql:"-"` BidFee Fee `json:"bid_fee" sql:"-"` }
func (*Trade) SimpleAttrs ¶
type User ¶
type User struct { CommonModel Sn string `gorm:"type:varchar(32);default:null" json:"sn"` PasswordDigest string `gorm:"type:varchar(64);default:null"` Nickname string `gorm:"type:varchar(32);default:null" json:"nickname"` State int `gorm:"default:null" json:"state"` Activated bool `gorm:"default:null" json:"activated"` Disabled bool `json:"disabled"` ApiDisabled bool `json:"api_disabled"` Password string `sql:"-"` Tokens []Token `sql:"-" json:"tokens"` Accounts []Account `sql:"-" json:"accounts"` }
func (*User) CompareHashAndPassword ¶
func (*User) GenerateSn ¶
func (user *User) GenerateSn()
func (*User) SetPasswordDigest ¶
func (user *User) SetPasswordDigest()
Click to show internal directories.
Click to hide internal directories.