Documentation
¶
Overview ¶
Package parser can parse CSV records into Protobuf quotes. It provides tools to parse dates, cents, or entire record.
Index ¶
Constants ¶
const MinYear = 1870
MinYear is the minimal supported year. Any date before the first day of this year is considered invalid.
Variables ¶
var ( // ErrNoDate means date value is missing in the record. ErrNoDate = errors.New("missing date") // ErrDate means the date value has invalid format (####.##) or incorrect, // e.g. not a number or the year is below [MinYear]. October is an exception // to the date format, it is represented by ####.1. ErrDate = errors.New("invalid date") // ErrYear means the date has invalid year ErrYear = errors.New("invalid year") // ErrMonth means the date has invalid month. ErrMonth = errors.New("invalid month") )
var ( // ErrNoSPX means SPX value is missing in the record. ErrNoSPX = errors.New("missing SPX") // ErrSPX means SPX value has invalid format. It should be ####.## with // dollar and cents. ErrSPX = errors.New("invalid SPX") )
var ( // ErrNoDividend means Dividend value is missing in the record. ErrNoDividend = errors.New("missing dividend") // ErrDividend means Dividend value has invalid format. See [ErrSPX] for // format description. ErrDividend = errors.New("invalid dividend") )
var ( // ErrNoEarnings means Earnings are missing in the record. ErrNoEarnings = errors.New("missing CPI") // ErrEarnings means Earnings has invalid format. See [ErrSPX] for // format description. ErrEarnings = errors.New("invalid CPI") )
var ( // ErrNoCPI means Consumer Price Index is missing in the record. ErrNoCPI = errors.New("missing CPI") // ErrCPI means Consumer Price Index has invalid format. See [ErrSPX] for // format description. ErrCPI = errors.New("invalid CPI") )
var ( // ErrFormat means the field has invalid format. ErrFormat = errors.New("invalid format") // ErrDollar means dollar part of the value in ####.## fails to parse. ErrDollar = errors.New("invalid dollar") // ErrCent means cent part of the value in ####.## fails to parse. ErrCent = errors.New("invalid cent") )
Functions ¶
func ParseCent ¶
ParseCent parses string ####.## as cents. It returns an error if the value has invalid format such as cents or dollars are missing, the cents must have two digits, or the value is not a number.
func ParseDate ¶
ParseDate parses date string ####.## into year, month, and the last day of the month. The year has minimum threshold of MinYear. The month is in the range (1, 12) inclusive, represented by two digits except October, which is given by .1, e.g. 1990.1 is Oct 1990. It returns an error if parsing fails.
Types ¶
This section is empty.