entity

package
v0.0.0-...-0d71218 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	ID           string
	Name         string
	MarketVolume int
}

func NewAsset

func NewAsset(id string, name string, marketVolume int) *Asset

type Book

type Book struct {
	Order         []*Order
	Transactions  []*Transaction
	OrdersChan    chan *Order // input
	OrdersChanOut chan *Order
	Wg            *sync.WaitGroup
}

func NewBook

func NewBook(orderChan chan *Order, orderChanOut chan *Order, wg *sync.WaitGroup) *Book

func (*Book) AddTransaction

func (b *Book) AddTransaction(transaction *Transaction, wg *sync.WaitGroup)

func (*Book) Trade

func (b *Book) Trade()

type Investor

type Investor struct {
	ID            string
	Name          string
	AssetPosition []*InvestorAssetPosition
}

func NewInvestor

func NewInvestor(id string) *Investor

func (*Investor) AddAssetPosition

func (i *Investor) AddAssetPosition(assetPosition *InvestorAssetPosition)

func (*Investor) GetAssetPosition

func (i *Investor) GetAssetPosition(assetID string) *InvestorAssetPosition

func (*Investor) UpdateAssetPosition

func (i *Investor) UpdateAssetPosition(assetID string, qtdShares int)

type InvestorAssetPosition

type InvestorAssetPosition struct {
	AssetID string
	Shares  int
}

func NewInvestorAssetPosition

func NewInvestorAssetPosition(assetID string, shares int) *InvestorAssetPosition

type Order

type Order struct {
	ID            string
	Investor      *Investor
	Asset         *Asset
	Shares        int
	PendingShares int
	Price         float64
	OrderType     string
	Status        string
	Transactions  []*Transaction
}

func NewOrder

func NewOrder(orderID string, investor *Investor, asset *Asset, shares int, price float64, orderType string) *Order

type OrderQueue

type OrderQueue struct {
	Orders []*Order
}

func NewOrderQueue

func NewOrderQueue() *OrderQueue

func (*OrderQueue) Len

func (oq *OrderQueue) Len() int

func (*OrderQueue) Less

func (oq *OrderQueue) Less(i, j int) bool

func (*OrderQueue) Pop

func (oq *OrderQueue) Pop() interface{}

func (*OrderQueue) Push

func (oq *OrderQueue) Push(x interface{})

func (*OrderQueue) Swap

func (oq *OrderQueue) Swap(i, j int)

type Transaction

type Transaction struct {
	ID           string
	SellingOrder *Order
	BuyingOrder  *Order
	Shares       int
	Price        float64
	Total        float64
	DateTime     time.Time
}

func NewTransaction

func NewTransaction(sellingOrder *Order, buyingOrder *Order, shares int, price float64) *Transaction

func (*Transaction) AddBuyOrderPendingShares

func (t *Transaction) AddBuyOrderPendingShares(shares int)

func (*Transaction) AddSellOrderPendingShares

func (t *Transaction) AddSellOrderPendingShares(shares int)

func (*Transaction) CalculateTotal

func (t *Transaction) CalculateTotal(shares int, price float64)

func (*Transaction) CloseBuyOrder

func (t *Transaction) CloseBuyOrder()

func (*Transaction) CloseSellOrder

func (t *Transaction) CloseSellOrder()

Jump to

Keyboard shortcuts

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