Skip to content

Commit 11b337b

Browse files
committed
Fixed candlesticks quering (last candle wasn't received)
1 parent baebb67 commit 11b337b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

routes.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function routes.get_candlesticks(secCode, classCode, interval, limit, skip)
6161
local dataSource, err = CreateDataSource(classCode, secCode, tonumber(interval))
6262
local limit = tonumber(limit)
6363
if limit == 0 then
64-
limit = 10000000
64+
limit = 10000
6565
end
6666
local skip = tonumber(skip)
6767
if dataSource then
@@ -77,9 +77,9 @@ function routes.get_candlesticks(secCode, classCode, interval, limit, skip)
7777
return nil
7878
end
7979

80-
local start = math.max(1, size - limit - skip)
80+
local start = math.max(1, size - limit - skip + 1)
8181
local to = math.min(size, start - 1 + limit)
82-
for i = start - 1, to do
82+
for i = start, to do
8383
local candle = {}
8484
candle.O = dataSource:O(i)
8585
candle.H = dataSource:H(i)
@@ -89,6 +89,7 @@ function routes.get_candlesticks(secCode, classCode, interval, limit, skip)
8989
candle.T = dataSource:T(i)
9090
table.insert(res, candle)
9191
end
92+
--log_e("Candles start " .. start .. " to " .. to .. " skip " .. skip .. " limit " .. limit .. " size " .. size)
9293
dataSource:Close()
9394
return res
9495
else

0 commit comments

Comments
 (0)