mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
优化GetHistoryTradeFull,需要传入Workday,减少非工作日的查询操作
This commit is contained in:
@@ -441,6 +441,11 @@ func (this *Client) GetHistoryMinuteTrade(date, code string, start, count uint16
|
||||
|
||||
// GetHistoryTradeFull 获取上市至今的分时成交
|
||||
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)
|
||||
resp, err := this.GetKlineMonthAll(code)
|
||||
if err != nil {
|
||||
@@ -451,7 +456,7 @@ func (this *Client) GetHistoryTradeFull(code string, w *Workday) (protocol.Trade
|
||||
}
|
||||
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
|
||||
w.Range(start, time.Now(), func(t time.Time) bool {
|
||||
w.Range(start, before, func(t time.Time) bool {
|
||||
res, err = this.GetHistoryTradeDay(start.Format("20060102"), code)
|
||||
if err != nil {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user