assets

package
v0.0.0-...-bc78c8b Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: GPL-3.0 Imports: 6 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 = domain.Asset

Asset is an alias of domain.Asset

type AssetsRepositoryInMemory

type AssetsRepositoryInMemory struct {
	Assets []domain.Asset
}

AssetsRepositoryInMemory stores assets in memory

func NewAssetsRepositoryInMemory

func NewAssetsRepositoryInMemory() *AssetsRepositoryInMemory

NewAssetsRepositoryInMemory returns an instance of NewAssetsRepositoryInMemory

func (*AssetsRepositoryInMemory) CheckAssetWithCloserPriceExists

func (ar *AssetsRepositoryInMemory) CheckAssetWithCloserPriceExists(accountID string, price, limit float32) (bool, error)

CheckAssetWithCloserPriceExists checks whether exist an asset that has the same price within limits defined

func (*AssetsRepositoryInMemory) Create

func (ar *AssetsRepositoryInMemory) Create(asset *domain.Asset) error

Create creates an asset and stores it in a data structure

func (*AssetsRepositoryInMemory) FindAll

func (ar *AssetsRepositoryInMemory) FindAll(accountID string) (*[]domain.Asset, error)

FindAll returns all assets stored

func (*AssetsRepositoryInMemory) FindCheaperAssetPrice

func (ar *AssetsRepositoryInMemory) FindCheaperAssetPrice(accountID string) (float32, error)

FindCheaperAssetPrice returns the lowest price of non sold assets

func (*AssetsRepositoryInMemory) FindPendingAssets

func (ar *AssetsRepositoryInMemory) FindPendingAssets(accountID string) (*[]domain.Asset, error)

FindPendingAssets returns all assets sold stored

func (*AssetsRepositoryInMemory) GetBalance

func (ar *AssetsRepositoryInMemory) GetBalance(accountID string, startDate, endDate time.Time) (float32, error)

GetBalance mocks the returning of balance between two dates

func (*AssetsRepositoryInMemory) Sell

func (ar *AssetsRepositoryInMemory) Sell(id string, price float32, sellTime time.Time) error

Sell updates asset state to sold and other related attributes

type BenchmarkAssetsInfo

type BenchmarkAssetsInfo struct {
	Buys                [][]float32 `json:"buys"`
	Sells               [][]float32 `json:"sells"`
	SellsPending        int         `json:"sellsPending"`
	AssetsAmountPending float32     `json:"assetsAmountPending"`
}

func GroupAssetsByState

func GroupAssetsByState(assets *[]domain.Asset) BenchmarkAssetsInfo

GroupAssetsByState returns assets bought and sold

type Repository

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

Repository is the DAO of orders

func NewRepository

func NewRepository(repo domain.Repository) *Repository

NewRepository returns an instance of OrdersRepository

func (*Repository) CheckAssetWithCloserPriceExists

func (ar *Repository) CheckAssetWithCloserPriceExists(accountID string, price, limit float32) (bool, error)

CheckAssetWithCloserPriceExists checks whether an asset that has the same price within limits defined exists

func (*Repository) Create

func (or *Repository) Create(asset *Asset) error

Create inserts a new asset in collection

func (*Repository) FindAll

func (or *Repository) FindAll(accountID string) (*[]Asset, error)

FindAll returns every order

func (*Repository) FindCheaperAssetPrice

func (or *Repository) FindCheaperAssetPrice(accountID string) (float32, error)

FindCheaperAssetPrice returns the asset with the lower buy price

func (*Repository) FindOne

func (or *Repository) FindOne(filter interface{}) (*Asset, error)

FindOne returns one asset

func (*Repository) FindPendingAssets

func (or *Repository) FindPendingAssets(accountID string) (*[]Asset, error)

FindPendingAssets returns all assets that weren't sold

func (*Repository) GetBalance

func (ar *Repository) GetBalance(accountID string, startDate, endDate time.Time) (float32, error)

GetBalance returns the assets balance based on buys and sells

func (*Repository) Sell

func (or *Repository) Sell(assetID string, price float32, sellTime time.Time) error

Sell updates asset sell fields

Jump to

Keyboard shortcuts

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