-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgobist.go
50 lines (38 loc) · 1.12 KB
/
gobist.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package gobist
import (
"context"
"github.com/guneyin/gobist/kap"
"github.com/guneyin/gobist/quote"
"github.com/guneyin/gobist/store"
)
type Bist struct {
quote *quote.API
kap *kap.API
store store.Store
}
func New() *Bist {
s := store.NewMemoryStore()
return &Bist{
quote: quote.NewAPI(s),
kap: kap.NewAPI(s),
}
}
func (b *Bist) WithStore(store store.Store) *Bist {
b.store = store
return b
}
func (b *Bist) GetSymbolList(ctx context.Context) (*quote.SymbolList, error) {
return b.quote.GetSymbolList(ctx)
}
func (b *Bist) GetQuote(ctx context.Context, symbols string, opts ...quote.OptionFunc) (*quote.Quote, error) {
return b.quote.GetQuote(ctx, symbols, opts...)
}
func (b *Bist) GetQuoteList(ctx context.Context, symbols []string, opts ...quote.OptionFunc) (*quote.List, error) {
return b.quote.GetQuoteList(ctx, symbols, opts...)
}
func (b *Bist) GetCompany(ctx context.Context, code string) (*kap.Company, error) {
return b.kap.GetCompany(ctx, code)
}
func (b *Bist) GetCompanyWithShares(ctx context.Context, code string) (*kap.Company, error) {
return b.kap.GetCompany(ctx, code, kap.WithShares())
}