Versions in this module Expand all Collapse all v0 v0.1.0 Jul 22, 2026 Changes in this version + const DefaultTpnlCapacity + func TpnlCacheKey(accountID int, windowNs uint64) string + type Cache struct + func NewCache() *Cache + func (c *Cache) ApplyBookUpdate(symbolID int, bids, asks []common.PriceLevel) + func (c *Cache) DeleteOrder(clientOrderID int) + func (c *Cache) GetAccountBalances(acctID int) map[int]*common.Balance + func (c *Cache) GetAvailable(acctID int, tokenID int) float64 + func (c *Cache) GetBalance(acctID int, tokenID int) *common.Balance + func (c *Cache) GetBestAsk(symbolID int) (price, qty float64, ok bool) + func (c *Cache) GetBestBid(symbolID int) (price, qty float64, ok bool) + func (c *Cache) GetBookState(symbolID int) (common.BookState, bool) + func (c *Cache) GetDepth(symbolID int, levels int) (bids, asks []common.PriceLevel) + func (c *Cache) GetLocked(acctID int, tokenID int) float64 + func (c *Cache) GetMidPrice(symbolID int) (price float64, ok bool) + func (c *Cache) GetOpenOrder(acctID int, clientOrderID int) (common.Order, bool) + func (c *Cache) GetOpenOrdersByAccount(acctID int) []*common.Order + func (c *Cache) GetOpenOrdersBySymbol(acctID int, symbolID int) []*common.Order + func (c *Cache) GetOrCreateTpnlState(key string, windowNs, capacity uint64) *TpnlState + func (c *Cache) GetOrder(clientOrderID int) (common.Order, bool) + func (c *Cache) GetRiskMeta(accountID int) (*RiskMeta, bool) + func (c *Cache) GetRiskNextAcceptedTime(accountID int) uint64 + func (c *Cache) GetSpread(symbolID int) (spread float64, ok bool) + func (c *Cache) GetTotal(acctID int, tokenID int) float64 + func (c *Cache) GetTpnlState(key string) *TpnlState + func (c *Cache) HasSufficientBalance(acctID int, tokenID int, amount float64) bool + func (c *Cache) InsertOrder(order *common.Order) + func (c *Cache) IsSymbolReady(symbolID int) bool + func (c *Cache) OpenOrderCount(acctID int) int + func (c *Cache) SetAccountBalances(acctID int, balances []common.Balance) + func (c *Cache) SetBalance(acctID int, tokenID int, available, locked, total float64) + func (c *Cache) SetBookState(symbolID int, state common.BookState) + func (c *Cache) SetRiskNextAcceptedTime(accountID int, t uint64) + func (c *Cache) UpdateBook(symbolID int, bids, asks []common.PriceLevel) + func (c *Cache) UpdateOrder(order *common.Order) + type OrderBook struct + type OrderCache struct + func NewOrderCache() *OrderCache + func (oc *OrderCache) DeleteOrder(clientOrderID int) + func (oc *OrderCache) GetOpenOrders(accountID int) []*common.Order + func (oc *OrderCache) GetOrder(clientOrderID int) (common.Order, bool) + func (oc *OrderCache) InsertOrder(order *common.Order) + func (oc *OrderCache) UpdateOrder(order *common.Order) + type RiskMeta struct + NextAcceptedTime atomic.Uint64 + type TpnlState struct + func NewTpnlState(windowNs, capacity uint64) *TpnlState + func (s *TpnlState) AddTrade(rec TpnlTradeRecord) bool + func (s *TpnlState) AdvanceClock(ts uint64) + func (s *TpnlState) Capacity() uint64 + func (s *TpnlState) Exposures() []TpnlSymbolExposure + func (s *TpnlState) GetExposure(symbolID int) (baseQty, quoteChange float64) + func (s *TpnlState) NowNs() uint64 + func (s *TpnlState) Purge() int + func (s *TpnlState) SetTokens(symbolID, baseTokenID, quoteTokenID int) + func (s *TpnlState) TradeCount() uint64 + type TpnlSymbolExposure struct + BaseQty float64 + QuoteChange float64 + SymbolID int + type TpnlTokenPair struct + BaseTokenID int + QuoteTokenID int + type TpnlTradeRecord struct + FeeCcyID int + FeeQty float64 + FilledAt uint64 + Price float64 + Qty float64 + Side common.Side + SymbolID int