entity

package
v0.0.0-...-d36e230 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: GPL-3.0 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     // Canal entrada ordens
	OrdersChanOut chan *Order     // Canal saida ordens
	Wg            *sync.WaitGroup //recurso Go await
}

EStrutura dados do book

func NewBook

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

Função do book

func (*Book) AddTransaction

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

Método que adiciona a transação na order (controle de pending shares)

func (*Book) Trade

func (b *Book) Trade()

Método trade, correlação de ordens de compra e venda

type Investor

type Investor struct {
	ID            string
	Name          string
	AssetPosition []*InvestorAssetPosition // Slice (go)
}

Estrutura dados do Investidor ID, Nome e Posição de ativos

func NewInvestor

func NewInvestor(id string) *Investor

Criar novo investidor ID e posição em branco

func (*Investor) AddAssetPosition

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

Método adicionar posição

func (*Investor) GetAssetPosition

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

Método que busca a posição atual

func (*Investor) UpdateAssetPosition

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

Método que atualiza as posições

type InvestorAssetPosition

type InvestorAssetPosition struct {
	AssetID string
	Shares  int
}

Estrutura dados para posição de ativos do investidor

func NewInvestorAssetPosition

func NewInvestorAssetPosition(assetID string, shares int) *InvestorAssetPosition

Função que cria nova posição

type Order

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

Estrutura dados dos ativos

func NewOrder

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

Função para nova ordem de negociação (compra/venda)

type OrderQueue

type OrderQueue struct {
	Orders []*Order
}

func NewOrderQueue

func NewOrderQueue() *OrderQueue

func (OrderQueue) Len

func (oq OrderQueue) Len() int

Método Len verfica o tamanho

func (OrderQueue) Less

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

Método Less diz o valor i é menor que j

func (OrderQueue) Pop

func (oq OrderQueue) Pop() interface{}

Método Pop remove de uma posição

func (OrderQueue) Push

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

Método Push adiciona .append

func (OrderQueue) Swap

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

Método Swap inverte i vira j e j vira i

type Transaction

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

Estrutura de dados para as transações

func NewTransaction

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

Função que cria nova transação

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