Documentation
¶
Index ¶
- Constants
- func IntegerInterfaceToInt64(i interface{}) int64
- func IntegerInterfaceToUint64(i interface{}) uint64
- type Account
- type Bill
- type BillType
- type BinLogStream
- type Config
- type DoneReason
- type FeeRate
- type Fill
- type Order
- type OrderStatus
- type OrderType
- type Product
- type Side
- type Store
- type Tick
- type TimeInForceType
- type Trade
- type Transaction
- type TransactionStatus
- type User
Constants ¶
View Source
const ( TopicOrder = "g_order" TopicAccount = "g_account" TopicTrade = "g_trade" TopicFill = "g_fill" TopicBill = "g_bill" )
View Source
const ( OrderTypeLimit = OrderType("limit") OrderTypeMarket = OrderType("market") GoodTillCanceled = TimeInForceType("GTC") ImmediateOrCancel = TimeInForceType("IOC") GoodTillCrossing = TimeInForceType("GTX") FillOrKill = TimeInForceType("FOK") SideBuy = Side("buy") SideSell = Side("sell") // 初始状态 OrderStatusNew = OrderStatus("new") // 已经加入orderBook OrderStatusOpen = OrderStatus("open") // 中间状态,请求取消订单 OrderStatusCancelling = OrderStatus("cancelling") // 完整订单被取消 OrderStatusCancelled = OrderStatus("cancelled") // 部分成交的订单被取消 OrderStatusPartial = OrderStatus("partial") // 订单完全成交 OrderStatusFilled = OrderStatus("filled") BillTypeTrade = BillType("trade") DoneReasonFilled = DoneReason("filled") DoneReasonCancelled = DoneReason("cancelled") TransactionStatusPending = TransactionStatus("pending") TransactionStatusCompleted = TransactionStatus("completed") )
Variables ¶
This section is empty.
Functions ¶
func IntegerInterfaceToInt64 ¶
func IntegerInterfaceToInt64(i interface{}) int64
func IntegerInterfaceToUint64 ¶
func IntegerInterfaceToUint64(i interface{}) uint64
Types ¶
type Account ¶
type Account struct { Id int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"` CreatedAt time.Time UpdatedAt time.Time UserId int64 `gorm:"column:user_id;unique_index:idx_uid_currency"` Currency string `gorm:"column:currency;unique_index:idx_uid_currency"` Hold decimal.Decimal `gorm:"column:hold" sql:"type:decimal(32,16);"` Available decimal.Decimal `gorm:"column:available" sql:"type:decimal(32,16);"` }
type BinLogStream ¶
type BinLogStream struct { canal.DummyEventHandler // contains filtered or unexported fields }
func NewBinLogStream ¶
func NewBinLogStream() *BinLogStream
func (*BinLogStream) Start ¶
func (s *BinLogStream) Start()
type Fill ¶
type Fill struct { Id int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"` CreatedAt time.Time UpdatedAt time.Time TradeSeq int64 OrderId int64 `gorm:"unique_index:o_m"` MessageSeq int64 `gorm:"unique_index:o_m"` ProductId string Size decimal.Decimal `sql:"type:decimal(32,16);"` Price decimal.Decimal `sql:"type:decimal(32,16);"` Funds decimal.Decimal `sql:"type:decimal(32,16);"` Fee decimal.Decimal `sql:"type:decimal(32,16);"` Liquidity string Settled bool Side Side Done bool DoneReason DoneReason LogOffset int64 LogSeq int64 }
type Order ¶
type Order struct { Id int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"` CreatedAt time.Time UpdatedAt time.Time ProductId string UserId int64 ClientOid string Size decimal.Decimal `sql:"type:decimal(32,16);"` Funds decimal.Decimal `sql:"type:decimal(32,16);"` FilledSize decimal.Decimal `sql:"type:decimal(32,16);"` ExecutedValue decimal.Decimal `sql:"type:decimal(32,16);"` Price decimal.Decimal `sql:"type:decimal(32,16);"` FillFees decimal.Decimal `sql:"type:decimal(32,16);"` Type OrderType Side Side TimeInForce TimeInForceType TakerFeeRatio decimal.Decimal `sql:"type:decimal(32,16);"` MakerFeeRatio decimal.Decimal `sql:"type:decimal(32,16);"` Status OrderStatus Settled bool }
type OrderStatus ¶
type OrderStatus string
用于表示订单状态
func NewOrderStatusFromString ¶
func NewOrderStatusFromString(s string) (*OrderStatus, error)
func (OrderStatus) String ¶
func (t OrderStatus) String() string
type Product ¶
type Product struct { Id string `gorm:"column:id;primary_key"` CreatedAt time.Time UpdatedAt time.Time BaseCurrency string QuoteCurrency string BaseMinSize decimal.Decimal `sql:"type:decimal(32,16);"` BaseMaxSize decimal.Decimal `sql:"type:decimal(32,16);"` QuoteMinSize decimal.Decimal `sql:"type:decimal(32,16);"` QuoteMaxSize decimal.Decimal `sql:"type:decimal(32,16);"` BaseScale int32 QuoteScale int32 QuoteIncrement float64 }
type Store ¶
type Store interface { BeginTx() (Store, error) Rollback() error CommitTx() error GetConfigs() ([]*Config, error) GetUserByEmail(email string) (*User, error) AddUser(user *User) error UpdateUser(user *User) error GetAccount(userId int64, currency string) (*Account, error) GetAccountsByUserId(userId int64) ([]*Account, error) GetAccountForUpdate(userId int64, currency string) (*Account, error) AddAccount(account *Account) error UpdateAccount(account *Account) error GetUnsettledBillsByUserId(userId int64, currency string) ([]*Bill, error) GetUnsettledBills() ([]*Bill, error) AddBills(bills []*Bill) error UpdateBill(bill *Bill) error GetProductById(id string) (*Product, error) GetProducts() ([]*Product, error) GetOrderById(orderId int64) (*Order, error) GetOrderByClientOid(userId int64, clientOid string) (*Order, error) GetOrderByIdForUpdate(orderId int64) (*Order, error) GetOrdersByUserId(userId int64, statuses []OrderStatus, side *Side, productId string, beforeId, afterId int64, limit int) ([]*Order, error) AddOrder(order *Order) error UpdateOrder(order *Order) error UpdateOrderStatus(orderId int64, oldStatus, newStatus OrderStatus) (bool, error) GetLastFillByProductId(productId string) (*Fill, error) GetUnsettledFillsByOrderId(orderId int64) ([]*Fill, error) GetUnsettledFills(count int32) ([]*Fill, error) UpdateFill(fill *Fill) error AddFills(fills []*Fill) error GetLastTradeByProductId(productId string) (*Trade, error) GetTradesByProductId(productId string, count int) ([]*Trade, error) AddTrades(trades []*Trade) error GetTicksByProductId(productId string, granularity int64, limit int) ([]*Tick, error) GetLastTickByProductId(productId string, granularity int64) (*Tick, error) GetLastTicksAllByProductId(productId string) ([]*Tick, error) AddTicks(ticks []*Tick) error GetFeeRateByUserLevel(userLevel string) (*FeeRate, error) }
type Tick ¶
type Tick struct { Id int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"` CreatedAt time.Time UpdatedAt time.Time ProductId string `gorm:"unique_index:p_g_t"` Granularity int64 `gorm:"unique_index:p_g_t"` Time int64 `gorm:"unique_index:p_g_t"` Open decimal.Decimal `sql:"type:decimal(32,16);"` High decimal.Decimal `sql:"type:decimal(32,16);"` Low decimal.Decimal `sql:"type:decimal(32,16);"` Close decimal.Decimal `sql:"type:decimal(32,16);"` Volume decimal.Decimal `sql:"type:decimal(32,16);"` LogOffset int64 LogSeq int64 }
type TimeInForceType ¶
type TimeInForceType string
Time In Force状态
func NewTimeInForceTypeFromString ¶
func NewTimeInForceTypeFromString(s string) (*TimeInForceType, error)
func (TimeInForceType) String ¶
func (t TimeInForceType) String() string
type Trade ¶
type Trade struct { Id int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"` CreatedAt time.Time UpdatedAt time.Time ProductId string TradeSeq int64 TakerOrderId int64 TakerUserId int64 MakerOrderId int64 MakerUserId int64 Price decimal.Decimal `sql:"type:decimal(32,16);"` Size decimal.Decimal `sql:"type:decimal(32,16);"` Side Side Time time.Time LogOffset int64 LogSeq int64 }
type Transaction ¶
type TransactionStatus ¶
type TransactionStatus string
Click to show internal directories.
Click to hide internal directories.