Documentation ¶
Overview ¶
Package yuebao grabs the latest or history yuebao data from tianhong fund's web site and save them into a leveldb database. It also provides query methods to get yuebao data by date or date range.
Index ¶
- Variables
- func CloseDB()
- func GetData(date string) string
- func GetDataByRange(dateBegin, dateEnd string) (jsonStr string)
- func GrabHistoryData() (err error)
- func GrabLatestData() (err error)
- func IsDateValid(date string) bool
- func LoadConfig()
- func LoadDefConfig()
- func Lock(ch chan int)
- func OpenDB() (err error)
- func SaveFromRegexpMatches(matches []string) (err error)
- func UnLock(ch chan int)
Constants ¶
This section is empty.
Variables ¶
var DEBUG = false
DEBUG is debug mode to output debug messages.
Functions ¶
func GetData ¶
GetData gets yuebao data by date. param: date in "yyyy-mm-dd" format. return: json string if data exist or "" if no data found. Ex: {"d":"2013-07-22","y":1.1547,"r":4.447} d -> date, y -> yield(每万份收益), r -> yield rate(7天年化收益率)
func GetDataByRange ¶
GetDataByRange gets data from day start to day end.
param: dateBegin, dayEnd in "yyyy-mm-dd" format. return: json array if data exist or "" if no data found. Ex: [ {"d":"2013-07-22","y":1.1547,"r":4.447}, {"d":"2013-07-21","y":1.1962,"r":4.471} ] d: -> date, y -> yield(每万份收益), r -> yield rate(7天年化收益率)
func GrabHistoryData ¶
func GrabHistoryData() (err error)
GrabHistoryData grabs all history yuebao data from tianhong fund website and save into leveldb database. It reads the "historyURL" and "historyPattern" settings from config file(./config.json).
func GrabLatestData ¶
func GrabLatestData() (err error)
GrabLatestData grabs latest yuebao data from tianhong fund website and save into leveldb database. It reads the "latestURL" and "latestPattern" settings from config file(./config.json).
func IsDateValid ¶
IsDateValid validates input date string. Date string must: 1. in yyyy-mm-dd format 2. > defMinDate(2013-05-30) 3. <= today
func OpenDB ¶
func OpenDB() (err error)
OpenDB opens leveldb database. It reads "dbPath" in config file(./config.json). The default value is "./my.db".
func SaveFromRegexpMatches ¶
SaveFromRegexpMatches saves into leveldb database from matched string slice by grabbing data from website.
Types ¶
This section is empty.