storage

package
v0.0.0-...-abc9c84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	CurrencyCode string
	CurrencyName string
	Available    *big.Float
	Reserved     *big.Float
	Total        *big.Float
	Account      int
}

type Book

type Book struct {
	LastPrice string
	Spread    *big.Float

	SpreadSessions map[string]*spread.Session `json:"spread_sessions"`
	BuySessions    map[string]*buy.Session    `json:"buy_sessions"`

	SpreadActiveSessionID goAtomic.String
	BuyActiveSessionID    goAtomic.String

	Profit       *big.Float `json:"profit"`
	BoughtVolume *big.Float `json:"bought_volume"`
	BoughtCost   *big.Float `json:"bought_cost"`

	OrderBookEventBroker *broker.Broker
	// contains filtered or unexported fields
}

func NewBook

func NewBook(storage *Storage, pair *Pair, orderBookEventBroker *broker.Broker) *Book

func ResetDumpedBook

func ResetDumpedBook(book *Book, pair *Pair, eventBroker *broker.Broker) *Book

func (*Book) AddAsk

func (b *Book) AddAsk(price string, ask *BookOrder)

func (*Book) AddBid

func (b *Book) AddBid(price string, bid *BookOrder)

func (*Book) AddBoughtCost

func (b *Book) AddBoughtCost(v *big.Float)

func (*Book) AddBoughtVolume

func (b *Book) AddBoughtVolume(v *big.Float)

func (*Book) AddProfit

func (b *Book) AddProfit(v *big.Float)

func (*Book) DeleteAsk

func (b *Book) DeleteAsk(price string)

func (*Book) DeleteBid

func (b *Book) DeleteBid(price string)

func (*Book) GetAsk

func (b *Book) GetAsk(price string) *BookOrder

func (*Book) GetBid

func (b *Book) GetBid(price string) *BookOrder

func (*Book) GetBoughtCost

func (b *Book) GetBoughtCost() *big.Float

func (*Book) GetBoughtVolume

func (b *Book) GetBoughtVolume() *big.Float

func (*Book) GetMaxBid

func (b *Book) GetMaxBid() *BookOrder

func (*Book) GetMaxBidPrice

func (b *Book) GetMaxBidPrice() *big.Float

func (*Book) GetMinAsk

func (b *Book) GetMinAsk() *BookOrder

func (*Book) GetMinAskPrice

func (b *Book) GetMinAskPrice() *big.Float

func (*Book) GetProfit

func (b *Book) GetProfit() *big.Float

func (*Book) GetSpread

func (b *Book) GetSpread() *big.Float

func (*Book) NewBuySession

func (b *Book) NewBuySession(buyVolume *big.Float) *buy.Session

func (*Book) NewSpreadSession

func (b *Book) NewSpreadSession(buyVolume *big.Float) *spread.Session

func (*Book) SetSpread

func (b *Book) SetSpread(spread *big.Float)

func (*Book) SubProfit

func (b *Book) SubProfit(v *big.Float)

func (*Book) UpdateMaxBidPrice

func (b *Book) UpdateMaxBidPrice() bool

func (*Book) UpdateMinAskPrice

func (b *Book) UpdateMinAskPrice() bool

type BookOrder

type BookOrder struct {
	Price  *big.Float
	Amount *big.Float
	Total  *big.Float
}

type DumpStorage

type DumpStorage struct {
	UserOrders map[int64]*Order            `json:"user_orders"`
	Deals      []*response.Deal            `json:"deals"`
	OrderBooks map[string]map[string]*Book `json:"order_books"`
	// contains filtered or unexported fields
}

func NewDumpStorage

func NewDumpStorage(st *Storage) *DumpStorage

func (*DumpStorage) DumpStorage

func (d *DumpStorage) DumpStorage(path string) error

func (DumpStorage) MarshalEasyJSON

func (v DumpStorage) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (DumpStorage) MarshalJSON

func (v DumpStorage) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*DumpStorage) Recover

func (d *DumpStorage) Recover(path string) error

func (*DumpStorage) UnmarshalEasyJSON

func (v *DumpStorage) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*DumpStorage) UnmarshalJSON

func (v *DumpStorage) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Order

type Order struct {
	ID               int64
	TradeTimestamp   string
	CreatedTimestamp time.Time
	State            int
	Modifier         int
	Pair             string
	TradeIntent      int
	OrderedVolume    *big.Float
	LimitPrice       *big.Float
	TotalSellVolume  *big.Float
	TotalBuyVolume   *big.Float
	TotalFeeQuoted   *big.Float
	TotalFeeExt      string
	Activated        string
	TpActivateLevel  string
	TrailDistance    string
	TpSubmitLevel    string
	TpLimitPrice     string
	SlSubmitLevel    string
	SlLimitPrice     string
	StopTimestamp    string
	TriggeredSide    string
}

func NewOrderByResponse

func NewOrderByResponse(r *response.AccountingOrder) (*Order, error)

type Pair

type Pair struct {
	BaseCurrency    string
	QuoteCurrency   string
	Price           string
	Price24hChange  string
	Volume24hChange string
	Amount24hChange string
	LowPrice24h     string
	HighPrice24h    string
	PriceScale      int
	QuantityScale   int
	VolumeScale     int
	MinQuantity     string
	MinVolume       *big.Float
	State           int
}

func (*Pair) GetPairName

func (p *Pair) GetPairName() string

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage() *Storage

func (*Storage) AppendDeals

func (s *Storage) AppendDeals(deals ...*response.Deal)

func (*Storage) CleanUpOldOrders

func (s *Storage) CleanUpOldOrders() int

func (*Storage) GetBalance

func (s *Storage) GetBalance(currency string) *Balance

func (*Storage) GetOrderBook

func (s *Storage) GetOrderBook(base, quoted string) *Book

func (*Storage) GetPair

func (s *Storage) GetPair(pairName string) *Pair

func (*Storage) GetUserOrder

func (s *Storage) GetUserOrder(id int64) *Order

func (*Storage) GetUserOrders

func (s *Storage) GetUserOrders() map[int64]*Order

func (*Storage) RegisterOrderBook

func (s *Storage) RegisterOrderBook(pair *Pair, orderBookEventBroker *broker.Broker) *Book

func (*Storage) UpdatePairs

func (s *Storage) UpdatePairs(pairs []*Pair)

func (*Storage) UpsertBalance

func (s *Storage) UpsertBalance(currency string, balance *Balance)

func (*Storage) UpsertUserOrder

func (s *Storage) UpsertUserOrder(order *Order)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL