import (
"fmt"
"github.com/sirupsen/logrus"
capital "github.com/chuanfoo/capital-go/rest"
)
// rest
client := capital.New("a", "b", "c")
// 创建session,只用创建一次会定时刷新
err = client.CreateNewSession()
if err != nil {
panic(err)
}
// 获取AMD股票的历史价格,注意时间区间不最大是:1000 * MINUTE
prices, err := client.HistoricalPrices("AMD", "MINUTE", "1000", "2022-04-01T00:00:00", "2022-04-01T01:59:00")
if err != nil {
panic(err)
}
bz, err := json.Marshal(prices)
if err != nil {
panic(err)
}
// ws订阅
log := logrus.New()
log.SetLevel(logrus.DebugLevel)
cfg := capitalws.Config{
APIKey: client.ApiKey,
Log: log,
}
ws, err := capitalws.New(cfg, client.CstToken, client.SecurityToken)
if err != nil {
fmt.Println(err)
}
// 订阅AMD
err = ws.Subscribe(capitalws.OHLCSubscribe, []string{"AMD"})
if err != nil {
fmt.Println(err)
}
err = ws.Connect()
if err != nil {
fmt.Println(err)
}
defer ws.Close()
for {
select {
case <-ws.Error():
return
case out, more := <-ws.Output():
if !more {
return
}
switch out.(type) {
case models.OHLC:
fmt.Println(out)
default:
fmt.Println("default", out)
}
}
}
capital-go's Introduction
capital-go's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.