entities

package
v0.0.0-...-bf1eb11 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicOrder   = "order"
	TopicAccount = "account"
	TopicFill    = "fill"
	TopicBill    = "bill"
)
View Source
const (
	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 {
	gorm.Model
	UserId    int64
	Currency  string
	Available decimal.Decimal
	Hold      decimal.Decimal
}

type Bill

type Bill struct {
	gorm.Model
	UserId   int64
	User     User `gorm:"foreignKey:UserId"`
	Currency string
	Avaiable decimal.Decimal
	Hold     decimal.Decimal
	Type     BillType
	Settled  bool
	Notes    string
}

type BillType

type BillType string

type Config

type Config struct {
	gorm.Model
	Key   string `json:"key"`
	Value string `json:"value"`
}

type DoneReason

type DoneReason string

type Fill

type Fill struct {
	gorm.Model
	TradeId int64 `json:"trade_id"`
	Trade   Trade `gorm:"foreignKey:TradeId"`

	OrderId int64 `json:"order_id"`
	Order   Order `gorm:"foreignKey:OrderId"`

	ProductId int64   `json:"product_id"`
	Product   Product `gorm:"foreignKey:ProductId"`

	Size      decimal.Decimal `json:"fill_size"`
	Price     decimal.Decimal `json:"price"`
	Funds     decimal.Decimal `json:"funds"`
	Fee       decimal.Decimal `json:"fees"`
	Liquidity string          `json:"liquidity"`
	Settled   bool            `json:"settled"`
	Side      Side            `json:"side"`
	Done      bool            `json:"done"`

	DoneReason DoneReason `json:"done_reason"`
	LogOffset  int64
	LogSeq     int64

	MessageSeq int64 `gorm:"index:o_m unique"`
}

type Order

type Order struct {
	gorm.Model
	ProductId int     `json:"product_id"`
	Product   Product `gorm:"foreignKey:ProductId"`

	UserId int  `json:"user_id"`
	User   User `gorm:"foreignKey:UserId"`

	ClientUuid    string
	Size          decimal.Decimal `json:"order_size"`
	Funds         decimal.Decimal `json:"funds"`
	FilledSize    decimal.Decimal `json:"filled_size"`
	ExecutedValue decimal.Decimal `json:"executed_value"`
	Price         decimal.Decimal `json:"price"`
	FillFees      decimal.Decimal `json:"fill_fees"`
	Type          OrderType       `json:"order_type"`
	Side          Side            `json:"side"`
	TimeInForce   string          `json:"time_in_force"`
	Status        OrderStatus     `json:"status"`
	Settled       bool            `json:"settled"`
}

type OrderStatus

type OrderStatus string
const (
	OrderStatusNew        OrderStatus = "NEW"
	OrderStatusCancelled  OrderStatus = "CANCELLED"
	OrderStatusOpen       OrderStatus = "OPEN"
	OrderStatusCancelling OrderStatus = "CANCELLING"
	OrderStatusFilled     OrderStatus = "FILLED"
)

func NewOrderStatusFromString

func NewOrderStatusFromString(s string) (*OrderStatus, error)

type OrderType

type OrderType string
const (
	MARKET_ORDER OrderType = "MARKET"
	LIMIT_ORDER  OrderType = "LIMIT"
)

func (OrderType) String

func (t OrderType) String() string

type Product

type Product struct {
	gorm.Model
	BaseCurrency   string
	QuoteCurrency  string
	BaseMinSize    decimal.Decimal
	QuoteMaxSize   decimal.Decimal
	BaseMaxSize    decimal.Decimal
	QuoteMinSize   decimal.Decimal
	BaseScale      int32
	QuoteScale     int32
	QuoteIncrement float64
}

type Side

type Side string
const (
	SideBuy  Side = "BUY"
	SideSell Side = "SELL"
)

func NewSideFromString

func NewSideFromString(s string) (*Side, error)

func (Side) Opposite

func (s Side) Opposite() Side

func (Side) String

func (s Side) String() string

type Tick

type Tick struct {
	gorm.Model

	ProductId int64   `json:"product_id"`
	Product   Product `gorm:"foreignKey:ProductId"`

	Granularity int64 `json:"granularity"`
	Time        int64 `json:"time"`

	Open      decimal.Decimal `json:"open_price"`
	High      decimal.Decimal `json:"high_price"`
	Low       decimal.Decimal `json:"low_price"`
	Close     decimal.Decimal `json:"close_price"`
	Volume    decimal.Decimal `json:"volume"`
	LogOffset int64
	LogSeq    int64
}

type Trade

type Trade struct {
	gorm.Model
	TradeId int64 `json:"trade_id"`
	OrderId int64 `json:"order_id"`
	Order   Order `gorm:"foreignKey:OrderId"`

	MessageSeq int64

	ProductId int64   `json:"product_id"`
	Product   Product `gorm:"foreignKey:ProductId"`

	TakerOrderId int64 `json:"taker_order_id"`
	TakerOrderFk Order `gorm:"foreignKey:TakerOrderId"`

	MakerOrderId int64 `json:"maker_order_id"`
	MakerOrderFk Order `gorm:"foreignKey:MakerOrderId"`

	Price decimal.Decimal `json:"price"`
	Size  decimal.Decimal `json:"size"`

	Side Side `json:"side"`
	Time time.Time

	LogOffset int64
	LogSeq    int64
}

type Transaction

type Transaction struct {
	gorm.Model

	UserId int64
	User   User `gorm:"foreignKey:UserId"`

	Currency   string            `json:"currency"`
	BlockNum   int               `json:"block_num"`
	ConfirmNum int               `json:"confirm_num"`
	Status     TransactionStatus `json:"transaction_status"`
}

type TransactionStatus

type TransactionStatus string

type User

type User struct {
	gorm.Model
	UserId       string
	Email        string
	PasswordHash string
}

func (*User) BeforeCreate

func (u *User) BeforeCreate()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳