Documentation ¶
Index ¶
- func GetDatesPlusOneDay(startDate, endDate time.Time) (time.Time, time.Time)
- func SerializeDate(date time.Time) string
- func TransverseDatesRange(startDate, endDate time.Time, handle func(time.Time, time.Time) error)
- type AssetPrice
- type CoindeskRemoteSource
- type FetchRemotePricesType
- type Repository
- func (r *Repository) Aggregate(pipeline mongo.Pipeline) (*[]bson.M, error)
- func (r *Repository) BulkCreate(documents *[]bson.M) error
- func (r *Repository) Create(ohlc *domain.OHLC, asset string) error
- func (r *Repository) FindAll(filter interface{}) (*[]domain.AssetPrice, error)
- func (r *Repository) FindOne(filter interface{}) (interface{}, error)
- func (r *Repository) GetLastAssetsPrices(asset string, limit int) (*[]domain.AssetPrice, error)
- type RepositoryInMemory
- func (r *RepositoryInMemory) Aggregate(pipeline mongo.Pipeline) (*[]bson.M, error)
- func (r *RepositoryInMemory) BulkCreate(documents *[]bson.M) error
- func (r *RepositoryInMemory) Create(ohlc *domain.OHLC, asset string) error
- func (r *RepositoryInMemory) FindAll(filter interface{}) (*[]domain.AssetPrice, error)
- func (r *RepositoryInMemory) FindOne(date time.Time, value float32, asset string) (*domain.AssetPrice, error)
- func (r *RepositoryInMemory) GetLastAssetsPrices(asset string, limit int) (*[]domain.AssetPrice, error)
- type Service
- type UrlDataFetcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDatesPlusOneDay ¶
GetDatesPlusOneDay returns the two dates passed by parameter with one more day
func SerializeDate ¶
SerializeDate convert time to string formatted to be accepted on coindesk url as parameter
Types ¶
type AssetPrice ¶
type AssetPrice = domain.AssetPrice
type CoindeskRemoteSource ¶
type CoindeskRemoteSource struct {
HTTPFetcher UrlDataFetcher
}
func NewCoindeskRemoteSource ¶
func NewCoindeskRemoteSource(HTTPFetcher UrlDataFetcher) *CoindeskRemoteSource
func (*CoindeskRemoteSource) FetchRemoteAssetsPrices ¶
func (c *CoindeskRemoteSource) FetchRemoteAssetsPrices(startDate, endDate time.Time, asset string) (*[]bson.M, error)
FetchRemoteAssetsPrices uses remote source to get asset prices
type FetchRemotePricesType ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository stores and gets assets prices
func NewRepository ¶
func NewRepository(repo domain.Repository) *Repository
NewRepository returns an instance of AssetsPricesRepository
func (*Repository) BulkCreate ¶
func (r *Repository) BulkCreate(documents *[]bson.M) error
BulkCreate creates multiple assets prices
func (*Repository) Create ¶
func (r *Repository) Create(ohlc *domain.OHLC, asset string) error
Create stores an asset price
func (*Repository) FindAll ¶
func (r *Repository) FindAll(filter interface{}) (*[]domain.AssetPrice, error)
FindAll returns assets prices
func (*Repository) FindOne ¶
func (r *Repository) FindOne(filter interface{}) (interface{}, error)
FindOne returns an asset price
func (*Repository) GetLastAssetsPrices ¶
func (r *Repository) GetLastAssetsPrices(asset string, limit int) (*[]domain.AssetPrice, error)
GetLastAssetsPrices return the last asset price stored in DB
type RepositoryInMemory ¶
type RepositoryInMemory struct {
// contains filtered or unexported fields
}
RepositoryInMemory stores and gets assets prices in memory
func NewRepositoryInMemory ¶
func NewRepositoryInMemory() *RepositoryInMemory
NewRepositoryInMemory returns assets prices repository mock
func (*RepositoryInMemory) BulkCreate ¶
func (r *RepositoryInMemory) BulkCreate(documents *[]bson.M) error
BulkCreate stub
func (*RepositoryInMemory) Create ¶
func (r *RepositoryInMemory) Create(ohlc *domain.OHLC, asset string) error
Create stores an asset price
func (*RepositoryInMemory) FindAll ¶
func (r *RepositoryInMemory) FindAll(filter interface{}) (*[]domain.AssetPrice, error)
FindAll returns assets prices
func (*RepositoryInMemory) FindOne ¶
func (r *RepositoryInMemory) FindOne(date time.Time, value float32, asset string) (*domain.AssetPrice, error)
FindOne returns an asset price
func (*RepositoryInMemory) GetLastAssetsPrices ¶
func (r *RepositoryInMemory) GetLastAssetsPrices(asset string, limit int) (*[]domain.AssetPrice, error)
GetLastAssetsPrices stub
type Service ¶
type Service struct { FetchRemotePrices FetchRemotePricesType // contains filtered or unexported fields }
Service provides assets prices methods
func NewService ¶
func NewService(repo domain.AssetPriceRepository, fetchRemotePrices FetchRemotePricesType) *Service
NewService returns an instance of AssetsPricesService
func (*Service) FetchAndStoreAssetPrices ¶
FetchAndStoreAssetPrices fetches asset prices remotely and save it in repository
func (*Service) GetLastAssetsPrices ¶
GetLastAssetsPrices returns the last price of an asset in the repository