common

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EXIT_CODE_POLYGON                  = 64
	EXIT_CODE_ASSET_COUNT_OUT_OF_RANGE = 65
	EXIT_CODE_DATABASE_ERROR           = 66
)

Variables

View Source
var CurrentVersion = Version{
	Major:  1,
	Minor:  0,
	Patch:  0,
	Suffix: "dev",
}

CurrentVersion represents the current build version. This is the only one in the system

Functions

func BuildAssetMap

func BuildAssetMap(assets []*Asset) map[string]*Asset

BuildAssetMap creates a map[string]*Asset hashmap where the ticker is the key

func BuildVersionString

func BuildVersionString() string

BuildVersionString creates a version string. This is what you see when running "import-fred version".

func GetDependencyList

func GetDependencyList() []string

GetDependencyList returns a sorted dependency list on the format package="version".

func LogSummary added in v0.3.0

func LogSummary(assets []*Asset)

LogSummary logs statistics about each signficant asset change

func MergeAssetList added in v0.3.0

func MergeAssetList(first []*Asset, second []*Asset) (combinedAssets []*Asset, firstOnly []*Asset, secondOnly []*Asset)

MergeAssetList combines assets from `first` and `second`. Assets in `first` are given preference to `second`

func SaveIcons

func SaveIcons(assets []*Asset, dirpath string)

SaveIcons writes icon images to disk. Each icon is name <dirpath>/ticker.png|jpeg

func SaveToDatabase

func SaveToDatabase(assets []*Asset) error

func SaveToParquet

func SaveToParquet(records []*Asset, fn string) error

func TrimWhiteSpace

func TrimWhiteSpace(assets []*Asset)

TrimeWhiteSpace removes leading and trailing whitespace in selected fields of the asset

Types

type Asset

type Asset struct {
	Ticker               string    `json:"ticker" parquet:"name=ticker, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	Name                 string    `json:"Name" parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	Description          string    `json:"description" parquet:"name=description, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	PrimaryExchange      string    `` /* 143-byte string literal not displayed */
	AssetType            AssetType `json:"asset_type" toml:"asset_type" parquet:"name=asset_type, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	CompositeFigi        string    `` /* 137-byte string literal not displayed */
	ShareClassFigi       string    `` /* 143-byte string literal not displayed */
	CUSIP                string    `json:"cusip" parquet:"name=cusip, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	ISIN                 string    `json:"isin" parquet:"name=isin, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	CIK                  string    `json:"cik" parquet:"name=cik, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	ListingDate          string    `` /* 131-byte string literal not displayed */
	DelistingDate        string    `` /* 137-byte string literal not displayed */
	Industry             string    `json:"industry" parquet:"name=industry, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	Sector               string    `json:"sector" parquet:"name=sector, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	Icon                 []byte    `json:"icon"`
	IconUrl              string    `json:"icon_url" toml:"icon_url" parquet:"name=icon_url, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
	CorporateUrl         string    `` /* 134-byte string literal not displayed */
	HeadquartersLocation string    `` /* 158-byte string literal not displayed */
	SimilarTickers       []string  `` /* 153-byte string literal not displayed */
	PolygonDetailAge     int64     `json:"polygon_detail_age" parquet:"name=polygon_detail_age, type=INT64"`
	FidelityCusip        bool      `parquet:"name=fidelity_cusip, type=BOOLEAN"`

	Updated      bool
	UpdateReason string

	LastUpdated int64  `json:"last_updated" parquet:"name=last_update, type=INT64"`
	Source      string `json:"source" parquet:"name=source, type=BYTE_ARRAY, convertedtype=UTF8, encoding=PLAIN_DICTIONARY"`
}

func ActiveAssetsFromDatabase added in v0.3.0

func ActiveAssetsFromDatabase() (assets []*Asset)

ActiveAssetsFromDatabase loads all active assets from the database

func CleanAssets

func CleanAssets(assets []*Asset) []*Asset

CleanAssets remove assets that have no composite figi or have an unknown asset type

func DeduplicateCompositeFigi added in v0.4.0

func DeduplicateCompositeFigi(assets []*Asset) []*Asset

DeduplicateCompositeFigi de-dupes assets that belong to the same composite figi. Dedup rules are as follows:

  1. Common stock is preferred to all other types
  2. Closed-end funds are preferred to mutual funds
  3. Most recent listed_utc is preferred

func FilterMixedCase added in v0.3.0

func FilterMixedCase(assets []*Asset) []*Asset

FilterMixedCase removes assets that have mixed-case tickers

func MergeAsset

func MergeAsset(a *Asset, b *Asset) *Asset

Merge fields from b into a

func ReadAssetsFromParquet added in v0.3.0

func ReadAssetsFromParquet(fn string) []*Asset

func ReadAssetsFromToml added in v0.3.0

func ReadAssetsFromToml(fn string) []*Asset

ReadAssetsFromToml reads assets stored as TOML from the file `fn`

func RemoveAssets added in v0.4.0

func RemoveAssets(assets []*Asset, remove []*Asset) []*Asset

RemoveAssets remove assets in `remove` from `assets`

func RemoveDelistedAssets added in v0.3.0

func RemoveDelistedAssets(assets []*Asset) []*Asset

RemoveDelistedAssets removes assets with DelistingDate set

func SubtractAssets added in v0.3.0

func SubtractAssets(a []*Asset, b []*Asset) (sub []*Asset)

SubtractAssets returns the set of assets in a but not b

func (*Asset) MarshalZerologObject

func (asset *Asset) MarshalZerologObject(e *zerolog.Event)

type AssetType

type AssetType string
const (
	CommonStock  AssetType = "Common Stock"
	ETF          AssetType = "Exchange Traded Fund"
	ETN          AssetType = "Exchange Traded Note"
	CEF          AssetType = "Closed-End Fund"
	MutualFund   AssetType = "Mutual Fund"
	ADRC         AssetType = "American Depository Receipt Common"
	FRED         AssetType = "FRED"
	UnknownAsset AssetType = "Unknown"
)

type Version

type Version struct {
	// Increment this for backwards incompatible changes
	Major int

	// Increment this for feature releases
	Minor int

	// Increment this for bug releases
	Patch int

	// VersionSuffix is the suffix used in the PV API version string.
	// It will be blank for release versions.
	Suffix string
}

Version represents a SemVer 2.0.0 compatible build version

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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