Documentation ¶
Index ¶
Constants ¶
View Source
const ( TopicOrder = "g_order" TopicAccount = "g_account" TopicFill = "g_fill" TopicBill = "g_bill" )
View Source
const ( OrderTypeLimit = OrderType("limit") OrderTypeMarket = OrderType("market") SideBuy = Side("buy") SideSell = Side("sell") // 初始状态 OrderStatusNew = OrderStatus("new") // 已经加入orderBook OrderStatusOpen = OrderStatus("open") // 中间状态,请求取消订单 OrderStatusCancelling = OrderStatus("cancelling") // 订单已经被取消,部分成交的订单也是cancelled OrderStatusCancelled = OrderStatus("cancelled") // 订单完全成交 OrderStatusFilled = OrderStatus("filled") BillTypeTrade = BillType("trade") DoneReasonFilled = DoneReason("filled") DoneReasonCancelled = DoneReason("cancelled") TransactionStatusPending = TransactionStatus("pending") TransactionStatusCompleted = TransactionStatus("completed") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 }
BinLogStream export
type Fill ¶
type Fill struct { Id int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"` CreatedAt time.Time UpdatedAt time.Time TradeId 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 string 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) AddTicks(ticks []*Tick) 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 Trade ¶
type Trade struct { Id int64 `gorm:"column:id;primary_key;AUTO_INCREMENT"` CreatedAt time.Time UpdatedAt time.Time ProductId string TakerOrderId int64 MakerOrderId 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.