application

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTimeFormat = errors.New("fromTime must be valid RFC3339 format")
)

Functions

This section is empty.

Types

type Balance

type Balance struct {
	BaseBalance  int
	BaseAsset    string
	QuoteBalance int
	QuoteAsset   string
	Time         time.Time
}

type CustomPeriod

type CustomPeriod struct {
	StartDate string
	EndDate   string
}

type Market

type Market struct {
	ID         int
	Url        string
	BaseAsset  string
	QuoteAsset string
}

type MarketBalance

type MarketBalance struct {
	MarketID     string
	BaseBalance  int
	BaseAsset    string
	QuoteBalance int
	QuoteAsset   string
	Time         time.Time
}

type MarketBalanceService

type MarketBalanceService interface {
	// InsertBalance inserts market balance in current moment
	InsertBalance(
		ctx context.Context,
		marketBalance MarketBalance,
	) error
	// GetBalances returns all markets balances from time in past equal to passed arg fromTime
	//if marketID is passed method will return data for all market's, otherwise only for provided one
	GetBalances(
		ctx context.Context,
		timeRange TimeRange,
		page Page,
		marketIDs ...string,
	) (*MarketsBalances, error)
	// StartFetchingBalancesJob starts cron job that will periodically fetch and store balances for all markets
	StartFetchingBalancesJob() error
}

func NewMarketBalanceService

func NewMarketBalanceService(
	marketBalanceRepository domain.MarketBalanceRepository,
	marketRepository domain.MarketRepository,
	tdexMarketLoaderSvc tdexmarketloader.Service,
	jobPeriodInMinutes string,
) MarketBalanceService

type MarketPrice

type MarketPrice struct {
	MarketID   string
	BasePrice  decimal.Decimal
	BaseAsset  string
	QuotePrice decimal.Decimal
	QuoteAsset string
	Time       time.Time
}

type MarketPriceService

type MarketPriceService interface {
	// InsertPrice inserts market price in current moment
	InsertPrice(
		ctx context.Context,
		marketPrice MarketPrice,
	) error
	// GetPrices returns all markets prices from time in past equal to passed arg fromTime
	//if marketID is passed method will return data for all market's, otherwise only for provided one
	GetPrices(
		ctx context.Context,
		timeRange TimeRange,
		page Page,
		referenceCurrency string,
		marketIDs ...string,
	) (*MarketsPrices, error)
	// StartFetchingPricesJob starts cron job that will periodically fetch and store prices for all markets
	StartFetchingPricesJob() error
}

func NewMarketPriceService

func NewMarketPriceService(
	marketPriceRepository domain.MarketPriceRepository,
	marketRepository domain.MarketRepository,
	tdexMarketLoaderSvc tdexmarketloader.Service,
	jobPeriodInMinutes string,
	raterSvc port.RateService,
) MarketPriceService

type MarketProvider

type MarketProvider struct {
	Url        string
	BaseAsset  string
	QuoteAsset string
}

type MarketService

type MarketService interface {
	ListMarkets(
		ctx context.Context,
		req []MarketProvider,
		page Page,
	) ([]Market, error)
}

func NewMarketService

func NewMarketService(
	marketRepository domain.MarketRepository,
) MarketService

type MarketsBalances

type MarketsBalances struct {
	//market_id and its Balances
	MarketsBalances map[string][]Balance
}

type MarketsLoaderService

type MarketsLoaderService interface {
	StartFetchingMarketsJob() error
}

func NewMarketsLoaderService

func NewMarketsLoaderService(
	marketRepository domain.MarketRepository,
	tdexMarketLoaderSvc tdexmarketloader.Service,
) MarketsLoaderService

type MarketsPrices

type MarketsPrices struct {
	//market_id and its Prices
	MarketsPrices map[string][]Price
}

type Page

type Page domain.Page

func (*Page) ToDomain

func (p *Page) ToDomain() domain.Page

type PredefinedPeriod

type PredefinedPeriod int
const (
	// NIL is added in proto file to recognised when predefined period is passed
	NIL PredefinedPeriod = iota
	LastHour
	LastDay
	LastMonth
	LastThreeMonths
	YearToDate
	All

	StartYear = 2022
)

type Price

type Price struct {
	BasePrice          decimal.Decimal
	BaseAsset          string
	BaseReferentPrice  decimal.Decimal
	QuotePrice         decimal.Decimal
	QuoteAsset         string
	QuoteReferentPrice decimal.Decimal
	Time               time.Time
}

type TimeRange

type TimeRange struct {
	PredefinedPeriod *PredefinedPeriod
	CustomPeriod     *CustomPeriod
}

Jump to

Keyboard shortcuts

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