app

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Asset string
	// contains filtered or unexported fields
}

App holds instances of each application dependency and executes program

func NewApp

func NewApp(
	collectors *[]domain.Collector,
	decisionMaker domain.DecisionMaker,
	trader domain.Trader,
	accountService domain.AccountService,
) *App

NewApp returns an instance of App

func (*App) DecideToBuy

func (a *App) DecideToBuy(price float32, currentTime time.Time) error

DecideToBuy do operations to check if an asset should be bought

func (*App) DecideToSell

func (a *App) DecideToSell(price float32, currentTime time.Time) error

DecideToSell do operations to check if an asset should be sold

func (*App) FetchAssets

func (a *App) FetchAssets() (*[]domain.Asset, error)

FetchAssets returns all assets

func (*App) GetAccountAmount

func (a *App) GetAccountAmount() (float32, error)

GetAccountAmount returns the account service amount

func (*App) GetState

func (a *App) GetState() interface{}

GetState returns application state

func (*App) OnNewAssetPrice

func (a *App) OnNewAssetPrice(ohlc *domain.OHLC)

OnNewAssetPrice do operations based on asset new price

func (*App) RegistOnNewAssetPrice

func (a *App) RegistOnNewAssetPrice(observable domain.OnNewAssetPrice)

RegistOnNewAssetPrice executes function when the collector receives a change

func (*App) SetEventsLog

func (a *App) SetEventsLog(eventsLog domain.EventsLog)

SetEventsLog sets events logs repository

func (*App) Start

func (a *App) Start()

Start starts collecting data

func (*App) Stop

func (a *App) Stop()

Stop stops collecting data

type Repository

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

Repository stores and gets applications from database

func NewRepository

func NewRepository(repo domain.Repository) *Repository

NewRepository returns an instance of applications repository

func (*Repository) Create

func (r *Repository) Create(asset string, options domain.ApplicationOptions, accountID primitive.ObjectID) (*domain.Application, error)

Create creates an application object

func (*Repository) DeleteByID

func (r *Repository) DeleteByID(id string) error

DeleteByID deletes an application with the id passed by argument

func (*Repository) FindAll

func (r *Repository) FindAll() (*[]domain.Application, error)

FindAll returns all applications

func (*Repository) FindByID

func (r *Repository) FindByID(id string) (*domain.Application, error)

FindByID returns an application with the id

type Service

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

Service interacts with applications, log events and application state repositories

func NewService

func NewService(
	repo *Repository,
	stateRepo domain.ApplicationExecutionStateRepository,
	eventsLogRepo domain.EventsLog,
	notificationsRepo domain.NotificationsRepository) *Service

NewService returns an instance of applications service

func (*Service) DeleteByID

func (a *Service) DeleteByID(id string) error

DeleteByID deletes the application with the id passed by argument

func (*Service) FindAll

func (a *Service) FindAll() (*[]domain.Application, error)

FindAll returns all applications in the repository

func (*Service) GetLastState

func (a *Service) GetLastState(appID primitive.ObjectID) (*domain.ApplicationExecutionState, error)

GetLastState returns the last application state

func (*Service) GetLogEvents

func (a *Service) GetLogEvents(appID primitive.ObjectID) (*[]domain.EventLog, error)

GetLogEvents returns all log events generated by a application

func (*Service) GetStateAggregated

func (a *Service) GetStateAggregated(appID string, startDate, endDate time.Time) (*[]bson.M, error)

Jump to

Keyboard shortcuts

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