Skip to content

Commit 69dfafc

Browse files
committed
fix(ls): rate limit foreign index TRs
1 parent 65d04f1 commit 69dfafc

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

internal/ls/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (c *Client) trLimiter(trCD string) *ratelimit.Limiter {
310310

311311
func lsTRRateLimit(trCD string) (float64, int, bool) {
312312
switch strings.ToLower(strings.TrimSpace(trCD)) {
313-
case TRStockChart, TROverseasStockChart:
313+
case TRStockChart, TROverseasStockChart, TRForeignIndexHistory, TRForeignIndexQuote:
314314
return 1, 1, true
315315
case TROverseasStockQuote, "g3102", TROverseasStockInstrument, "g3106", TROverseasStockMaster:
316316
return 10, 1, true

internal/ls/client_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ func TestLSTRRateLimit_UsesDocumentedChartQuotas(t *testing.T) {
295295
t.Fatalf("g3204 limit = rps %v burst %d ok %v, want 1/1/true", rps, burst, ok)
296296
}
297297

298+
rps, burst, ok = lsTRRateLimit(TRForeignIndexQuote)
299+
if !ok || rps != 1 || burst != 1 {
300+
t.Fatalf("t3521 limit = rps %v burst %d ok %v, want 1/1/true", rps, burst, ok)
301+
}
302+
303+
rps, burst, ok = lsTRRateLimit(TRForeignIndexHistory)
304+
if !ok || rps != 1 || burst != 1 {
305+
t.Fatalf("t3518 limit = rps %v burst %d ok %v, want 1/1/true", rps, burst, ok)
306+
}
307+
298308
rps, burst, ok = lsTRRateLimit(TROverseasStockQuote)
299309
if !ok || rps != 10 || burst != 1 {
300310
t.Fatalf("g3101 limit = rps %v burst %d ok %v, want 10/1/true", rps, burst, ok)

internal/ls/paths.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,24 @@ const (
2121
PathStockOrder = "/stock/order"
2222
PathStockMisc = "/stock/etc"
2323
PathStockItemSearch = "/stock/item-search"
24+
PathStockInvestInfo = "/stock/investinfo"
2425

2526
PathOverseasStockMarket = "/overseas-stock/market-data"
2627
PathOverseasStockChart = "/overseas-stock/chart"
2728
)
2829

2930
const (
30-
TRStockQuote = "t1102"
31-
TRStockChart = "t8410"
32-
TRStockBalance = "t0424"
33-
TRStockOrder = "CSPAT00601"
34-
TRStockMaster = "t8436"
35-
TRRealtimeKOSPI = "S3_"
36-
TRRealtimeKOSDAQ = "K3_"
37-
TRRealtimeUnified = "US3"
38-
TRRealtimeNXT = "NS3"
31+
TRStockQuote = "t1102"
32+
TRStockChart = "t8410"
33+
TRStockBalance = "t0424"
34+
TRStockOrder = "CSPAT00601"
35+
TRStockMaster = "t8436"
36+
TRForeignIndexHistory = "t3518"
37+
TRForeignIndexQuote = "t3521"
38+
TRRealtimeKOSPI = "S3_"
39+
TRRealtimeKOSDAQ = "K3_"
40+
TRRealtimeUnified = "US3"
41+
TRRealtimeNXT = "NS3"
3942

4043
TROverseasStockQuote = "g3101"
4144
TROverseasStockInstrument = "g3104"

0 commit comments

Comments
 (0)