Documentation ¶
Index ¶
- Constants
- func CrawlNow(stockID string, page int) structs.StockPrice
- func CrawlPast(stockID string, page int) []structs.StockPrice
- func GetCollectionStartingDate(year int) time.Time
- type DateChecker
- type Stock
- type StockAccess
- type StockItemChecker
- func (checker *StockItemChecker) AllStockID() []string
- func (checker *StockItemChecker) IsValid(stockid string) bool
- func (checker *StockItemChecker) StockFromID(stockid string) (structs.Stock, bool)
- func (checker *StockItemChecker) StockFromName(stockname string) (structs.Stock, bool)
- func (checker *StockItemChecker) UpdateStocks()
- type StockPrice
- type Watcher
- func (w *Watcher) Collect()
- func (w *Watcher) Description() string
- func (w *Watcher) Register(stock Stock) bool
- func (w *Watcher) StartWatchingStock(stockID string) <-chan StockPrice
- func (w *Watcher) StopWatching()
- func (w *Watcher) StopWatchingStock(stockID string)
- func (w *Watcher) Withdraw(stock Stock) bool
- type WatcherAccess
- type WatchingStock
Constants ¶
const CandleTimeUnitMinute = int64(15) // 15분
CandleTimeUnitMinute 하나의 캔들은 15분
const CandleTimeUnitNanoseconds = time.Minute * 15 // 15분
CandleTimeUnitNanoseconds 하나의 캔들은 15분, 이를 time.Time 구조체로 표현
const CandleTimeUnitSeconds = CandleTimeUnitMinute * 60
CandleTimeUnitSeconds 하나의 캔들은 15분, 이를 초 단위로 표현
Variables ¶
This section is empty.
Functions ¶
func CrawlNow ¶
func CrawlNow(stockID string, page int) structs.StockPrice
CrawlNow actually performs crawling for the current prices
func CrawlPast ¶
func CrawlPast(stockID string, page int) []structs.StockPrice
CrawlPast actually performs crawling for the past prices
func GetCollectionStartingDate ¶
GetCollectionStartingDate gets time until when to crawl
Types ¶
type DateChecker ¶
type DateChecker struct {
// contains filtered or unexported fields
}
DateChecker is a struct holding holidays as a map
func NewDateChecker ¶
func NewDateChecker() *DateChecker
NewDateChecker returns a new DateChecker with holidays unfilled. Holidays are updated
func (*DateChecker) Description ¶
func (d *DateChecker) Description() string
func (*DateChecker) IsHoliday ¶
func (c *DateChecker) IsHoliday(day time.Time) bool
IsHoliday checks if the day is holiday or not.
func (*DateChecker) UpdateHolidays ¶
func (c *DateChecker) UpdateHolidays(year int)
UpdateHolidays updates the holidays of the given year.
type StockAccess ¶
type StockAccess interface { AccessStockItem(stockid string) (structs.Stock, bool) AccessStockItemByName(stockname string) (structs.Stock, bool) }
StockAccess Accessor for stock info
type StockItemChecker ¶
type StockItemChecker struct {
// contains filtered or unexported fields
}
StockItemChecker is a simple struct holding stock info and a DB client.
func NewStockItemChecker ¶
func NewStockItemChecker(dbClient *database.DBClient) *StockItemChecker
NewStockItemChecker returns a new StockItemChecker with stocks unfilled. Stock info will be updated.
func (*StockItemChecker) AllStockID ¶
func (checker *StockItemChecker) AllStockID() []string
func (*StockItemChecker) IsValid ¶
func (checker *StockItemChecker) IsValid(stockid string) bool
IsValid checks if the given stock ID exists in the list.
func (*StockItemChecker) StockFromID ¶
func (checker *StockItemChecker) StockFromID(stockid string) (structs.Stock, bool)
StockFromID finds structs.Stock from stock id returns false if not found
func (*StockItemChecker) StockFromName ¶
func (checker *StockItemChecker) StockFromName(stockname string) (structs.Stock, bool)
StockFromName finds structs.Stock from stock id returns false if not found
func (*StockItemChecker) UpdateStocks ¶
func (checker *StockItemChecker) UpdateStocks()
UpdateStocks updates stock info from the KRX server.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher is a struct for watching the market
func (*Watcher) Collect ¶
func (w *Watcher) Collect()
Collect collects the past price data of the market.
func (*Watcher) Description ¶
Description description of this Watcher
func (*Watcher) Register ¶
Register use it to register a new stock of interest. Internally, it investigates if the stock had been registered before If registered, it updates the last timestamp of the price. Else, it will collect price data from the beginning.
func (*Watcher) StartWatchingStock ¶
func (w *Watcher) StartWatchingStock(stockID string) <-chan StockPrice
StartWatchingStock use it to start watching the market. A channel of StockPrice is returned to get the price info for the given stock id. The channel is valid only for one day, since the channel will be closed after the market closing time. returns : <-chan StockPrice, which will give stock price until StopWatching is called.
func (*Watcher) StopWatching ¶
func (w *Watcher) StopWatching()
StopWatching call it when to stop watching the market.
func (*Watcher) StopWatchingStock ¶
StopWatchingStock call it when to stop watching the specific stock.
type WatcherAccess ¶
type WatcherAccess interface {
AccessWatcher() *Watcher
}
WatcherAccess provides access to Watcher
type WatchingStock ¶
type WatchingStock = structs.WatchingStock
WatchingStock is just a simple type alias