Documentation
¶
Overview ¶
Package db handles all data exchange to the db.
Index ¶
- Variables
- func NewApp(ctx context.Context, c Config) (*app, func(), error)
- type AlphaVantage
- type Asset
- type AssetExtractor
- func (a *AssetExtractor) Assets(ctx context.Context, MinAge time.Time, Active bool) ([]PricedAsset, error)
- func (a *AssetExtractor) AssetsByID(ctx context.Context, ids ...AssetID) ([]PricedAsset, error)
- func (a *AssetExtractor) AssetsBySearch(ctx context.Context, search string, MinAge time.Time, Active bool) ([]PricedAsset, error)
- func (a *AssetExtractor) HealthCheck(ctx context.Context) <-chan error
- func (a *AssetExtractor) TimeSeriesAssetsByID(ctx context.Context, from time.Time, ids ...AssetID) ([]TimeSeriesAsset, error)
- type AssetID
- type Config
- type PgxIface
- type PricedAsset
- type TemporaryError
- type TimeSeries
- type TimeSeriesAsset
Constants ¶
This section is empty.
Variables ¶
var ( ErrLimit = errors.New("daily limit reached") ErrCode = errors.New("invalid code requested") )
var ErrNoRecord = errors.New("models: no matching record found")
ErrNoRecord is returned if the query is empty.
Functions ¶
Types ¶
type AlphaVantage ¶
type AlphaVantage struct {
// contains filtered or unexported fields
}
func NewAlphaVantage ¶
func NewAlphaVantage(alphaFunction, alphaKey string) AlphaVantage
type Asset ¶
type Asset struct {
ID AssetID `json:"shareid"`
Name string `json:"description"`
Symbol string `json:"symbol"`
}
Asset is the base struct for assets.
type AssetExtractor ¶
type AssetExtractor struct {
// contains filtered or unexported fields
}
AssetExtractor describes financial data relation
func NewAssetExtractor ¶
func NewAssetExtractor(db PgxIface) *AssetExtractor
func (*AssetExtractor) Assets ¶
func (a *AssetExtractor) Assets(ctx context.Context, MinAge time.Time, Active bool) ([]PricedAsset, error)
Assets provides basic info for searched assets. It sorts (highest first) by traded volume of the last days past.
func (*AssetExtractor) AssetsByID ¶
func (a *AssetExtractor) AssetsByID(ctx context.Context, ids ...AssetID) ([]PricedAsset, error)
func (*AssetExtractor) AssetsBySearch ¶
func (a *AssetExtractor) AssetsBySearch(ctx context.Context, search string, MinAge time.Time, Active bool) ([]PricedAsset, error)
AssetsBySearch provides basic info for searched assets. It sorts (highest first) by traded volume of the last daysPast. func (a *AssetExtractor) GetShareInfo(ctx context.Context, shareIDs []int, daysPast int, queryString string) ([]PricedAsset, error) {
func (*AssetExtractor) HealthCheck ¶
func (a *AssetExtractor) HealthCheck(ctx context.Context) <-chan error
HealthCheck currently only pings the db to see if it is available
func (*AssetExtractor) TimeSeriesAssetsByID ¶
func (a *AssetExtractor) TimeSeriesAssetsByID(ctx context.Context, from time.Time, ids ...AssetID) ([]TimeSeriesAsset, error)
TimeSeriesAssetsByID any return asset comes with a timeSeries starting at `from`
type PricedAsset ¶
PricedAsset extends Asset by the latest price for value orientation.
type TemporaryError ¶
TemporaryError says that a instant rerun is sensible.
func (*TemporaryError) Error ¶
func (e *TemporaryError) Error() string
type TimeSeries ¶
TimeSeries maps SharePrice per day (=unique key)
type TimeSeriesAsset ¶
type TimeSeriesAsset struct {
Asset
TimeSeries TimeSeries `json:"time_series"`
}
TimeSeriesAsset extends Asset by a TimeSeries to do computation.