mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b35006323 | ||
|
|
3b823e2e54 |
16
client.go
16
client.go
@@ -440,7 +440,12 @@ func (this *Client) GetHistoryMinuteTrade(date, code string, start, count uint16
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetHistoryTradeFull 获取上市至今的分时成交
|
// GetHistoryTradeFull 获取上市至今的分时成交
|
||||||
func (this *Client) GetHistoryTradeFull(code string) (protocol.Trades, error) {
|
func (this *Client) GetHistoryTradeFull(code string, w *Workday) (protocol.Trades, error) {
|
||||||
|
return this.GetHistoryTradeBefore(code, w, time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHistoryTradeBefore 获取上市至今的分时成交
|
||||||
|
func (this *Client) GetHistoryTradeBefore(code string, w *Workday, before time.Time) (protocol.Trades, error) {
|
||||||
ls := protocol.Trades(nil)
|
ls := protocol.Trades(nil)
|
||||||
resp, err := this.GetKlineMonthAll(code)
|
resp, err := this.GetKlineMonthAll(code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -451,14 +456,15 @@ func (this *Client) GetHistoryTradeFull(code string) (protocol.Trades, error) {
|
|||||||
}
|
}
|
||||||
start := time.Date(resp.List[0].Time.Year(), resp.List[0].Time.Month(), 1, 0, 0, 0, 0, resp.List[0].Time.Location())
|
start := time.Date(resp.List[0].Time.Year(), resp.List[0].Time.Month(), 1, 0, 0, 0, 0, resp.List[0].Time.Location())
|
||||||
var res *protocol.TradeResp
|
var res *protocol.TradeResp
|
||||||
for ; start.Before(time.Now()); start = start.Add(time.Hour * 24) {
|
w.Range(start, before, func(t time.Time) bool {
|
||||||
res, err = this.GetHistoryTradeDay(start.Format("20060102"), code)
|
res, err = this.GetHistoryTradeDay(start.Format("20060102"), code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return false
|
||||||
}
|
}
|
||||||
ls = append(ls, res.List...)
|
ls = append(ls, res.List...)
|
||||||
}
|
return true
|
||||||
return ls, nil
|
})
|
||||||
|
return ls, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHistoryTradeDay 获取历史某天分时全部交易,通过多次请求来拼接,只能获取昨天及之前的数据
|
// GetHistoryTradeDay 获取历史某天分时全部交易,通过多次请求来拼接,只能获取昨天及之前的数据
|
||||||
|
|||||||
Reference in New Issue
Block a user