Documentation ¶
Index ¶
- type Asset
- type AssetsRepositoryInMemory
- func (ar *AssetsRepositoryInMemory) CheckAssetWithCloserPriceExists(accountID string, price, limit float32) (bool, error)
- func (ar *AssetsRepositoryInMemory) Create(asset *domain.Asset) error
- func (ar *AssetsRepositoryInMemory) FindAll(accountID string) (*[]domain.Asset, error)
- func (ar *AssetsRepositoryInMemory) FindCheaperAssetPrice(accountID string) (float32, error)
- func (ar *AssetsRepositoryInMemory) FindPendingAssets(accountID string) (*[]domain.Asset, error)
- func (ar *AssetsRepositoryInMemory) GetBalance(accountID string, startDate, endDate time.Time) (float32, error)
- func (ar *AssetsRepositoryInMemory) Sell(id string, price float32, sellTime time.Time) error
- type BenchmarkAssetsInfo
- type Repository
- func (ar *Repository) CheckAssetWithCloserPriceExists(accountID string, price, limit float32) (bool, error)
- func (or *Repository) Create(asset *Asset) error
- func (or *Repository) FindAll(accountID string) (*[]Asset, error)
- func (or *Repository) FindCheaperAssetPrice(accountID string) (float32, error)
- func (or *Repository) FindOne(filter interface{}) (*Asset, error)
- func (or *Repository) FindPendingAssets(accountID string) (*[]Asset, error)
- func (ar *Repository) GetBalance(accountID string, startDate, endDate time.Time) (float32, error)
- func (or *Repository) Sell(assetID string, price float32, sellTime time.Time) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetsRepositoryInMemory ¶
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
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 ¶
GetBalance returns the assets balance based on buys and sells