watcher

package
v0.0.0-...-5a29284 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const CandleTimeUnitMinute = int64(15) // 15분

CandleTimeUnitMinute 하나의 캔들은 15분

View Source
const CandleTimeUnitNanoseconds = time.Minute * 15 // 15분

CandleTimeUnitNanoseconds 하나의 캔들은 15분, 이를 time.Time 구조체로 표현

View Source
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

func GetCollectionStartingDate(year int) time.Time

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.

func (*DateChecker) Year

func (c *DateChecker) Year() int

Year returns the current year.

type Stock

type Stock = structs.Stock

Stock is just a simple type alias

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 StockPrice

type StockPrice = structs.StockPrice

StockPrice is just a simple type alias

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher is a struct for watching the market

func New

func New(dbClient *database.DBClient, sleepingTime time.Duration) *Watcher

New creates a new Watcher struct

func (*Watcher) Collect

func (w *Watcher) Collect()

Collect collects the past price data of the market.

func (*Watcher) Description

func (w *Watcher) Description() string

Description description of this Watcher

func (*Watcher) Register

func (w *Watcher) Register(stock Stock) bool

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

func (w *Watcher) StopWatchingStock(stockID string)

StopWatchingStock call it when to stop watching the specific stock.

func (*Watcher) Withdraw

func (w *Watcher) Withdraw(stock Stock) bool

Withdraw withdraws a stock which was of interest.

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

Jump to

Keyboard shortcuts

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