forked from gofinance/ib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistorical_data_manager_test.go
49 lines (38 loc) · 1014 Bytes
/
historical_data_manager_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package ib
import (
"testing"
"time"
)
func TestHistoricalDataManager(t *testing.T) {
engine := NewTestEngine(t)
defer engine.ConditionalStop(t)
request := RequestHistoricalData{
Contract: Contract{
Symbol: "NZD",
SecurityType: "CASH",
Exchange: "IDEALPRO",
Currency: "USD",
},
EndDateTime: time.Now(),
Duration: "1 D",
BarSize: HistBarSize30Min,
WhatToShow: HistBid,
UseRTH: true,
}
hdm, err := NewHistoricalDataManager(engine, request)
if err != nil {
t.Fatalf("error creating HistoricalDataManager, %v", err)
}
defer hdm.Close()
SinkManagerTest(t, hdm, 15*time.Second, 1)
items := hdm.Items()
if len(items) == 0 {
t.Fatal("expected items to be returned, but got 0")
}
for _, histItem := range items {
t.Logf("%s: %.4f %.4f %.4f %.4f\n", histItem.Date, histItem.Open, histItem.High, histItem.Low, histItem.Close)
}
if b, ok := <-hdm.Refresh(); ok {
t.Fatalf("Expected the refresh channel to be closed, but got %t", b)
}
}