123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- package main
- import (
- "fmt"
- "tickserver/api/lmaxapi"
- "tickserver/api/lmaxapi/main/common"
- "tickserver/api/lmaxapi/request"
- "tickserver/api/lmaxapi/response"
- "runtime"
- "time"
- )
- var session *lmaxapi.Session
- func main() {
- fmt.Println(runtime.NumCPU())
- runtime.GOMAXPROCS(runtime.NumCPU())
- fmt.Println("HistoricMarketDataRequest")
- common.EnableLog("proto.log")
- session, _ = common.CreateSession()
- session.RegisterHistoricMarketDataEvent(HistoricEvent)
- req := request.NewHistoricSubscriptionRequest()
- session.Subscribe(req, func(err error) {
- if err == nil {
- req1 := request.NewAggregateHistoricRequest("1", 4001,
- time.Date(2012, 9, 1, 0, 0, 0, 0, time.UTC),
- time.Date(2013, 9, 2, 0, 0, 0, 0, time.UTC),
- "CSV",//暂时只有一种格式
- "MINUTE",//还可以 DAY, 也就是只有分钟线 和 日线两种
- []string{"ASK"} //BID/ASK/TRADE 可以是这三种形式
- )
- session.RequestHistoricMarketData(req1, func(err error) {
- if err != nil {
- fmt.Println("Failed to request historic market data:", err)
- }
- })
- } else {
- fmt.Println("Failed to subscribe:", err)
- }
- })
- common.Heartbeat(session)
- session.Start()
- fmt.Println("stop")
- }
- func HistoricEvent(s *lmaxapi.Session, event *response.HistoricMarketDataEvent) {
- fmt.Println(event)
- }
|