forked from curtismckee/go-alpha-vantage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers_test.go
More file actions
169 lines (155 loc) · 6.74 KB
/
helpers_test.go
File metadata and controls
169 lines (155 loc) · 6.74 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package av
import (
"bytes"
"net/http"
"net/url"
)
const (
testApiKey = "test"
)
type responseConnection struct {
endpoint *url.URL
response *http.Response
}
func NewResponseConnection(res *http.Response) *responseConnection {
return &responseConnection{response: res}
}
func (c *responseConnection) Request(endpoint *url.URL) (*http.Response, error) {
c.endpoint = endpoint
return c.response, nil
}
type errorConnection struct {
endpoint *url.URL
err error
}
func NewErrorConnection(err error) *errorConnection {
return &errorConnection{err: err}
}
func (c *errorConnection) Request(endpoint *url.URL) (*http.Response, error) {
c.endpoint = endpoint
return nil, c.err
}
type ResetBuffer struct {
contents string
buf *bytes.Buffer
}
func NewBuffCloser(contents string) *ResetBuffer {
buff := &ResetBuffer{
contents: contents,
}
buff.Restart()
return buff
}
func (b *ResetBuffer) Restart() {
b.buf = bytes.NewBufferString(b.contents)
}
func (b *ResetBuffer) Read(p []byte) (int, error) {
return b.buf.Read(p)
}
func (b *ResetBuffer) Close() error {
b.Restart()
return nil
}
const (
sampleTimeSeriesData = `timestamp,open,high,low,close,volume
2018-01-04,1097.0900,1104.0800,1094.2600,1095.7600,1289293
2018-01-03,1073.9300,1096.1000,1073.4300,1091.5200,1550593
2018-01-02,1053.0200,1075.9800,1053.0200,1073.2100,1555809
2017-12-29,1055.4900,1058.0500,1052.7000,1053.4000,1156357
2017-12-28,1062.2500,1064.8400,1053.3800,1055.9500,982285
2017-12-27,1066.6000,1068.2700,1058.3800,1060.2000,1027634
2017-12-26,1068.6400,1068.8600,1058.6400,1065.8500,914574
2017-12-22,1070.0000,1071.7200,1067.6400,1068.8600,860800
2017-12-21,1075.3900,1077.5200,1069.0000,1070.8500,1211012
2017-12-20,1080.9200,1081.2300,1068.6000,1073.5600,1429035
2017-12-19,1083.0200,1084.9700,1072.2700,1079.7800,1287930
2017-12-18,1076.4500,1086.4900,1070.3700,1085.0900,1482768
2017-12-15,1063.7800,1075.2500,1060.0900,1072.0000,3080738
2017-12-14,1055.4900,1067.0800,1053.6000,1057.4700,1531504
2017-12-13,1052.0800,1055.4800,1046.5800,1051.3900,1369580
2017-12-12,1050.0000,1062.5000,1044.8700,1048.7700,1684977
2017-12-11,1051.1100,1056.0000,1044.1200,1051.9700,1096997
2017-12-08,1051.8100,1056.4200,1045.8600,1049.3800,1479665
2017-12-07,1036.0700,1048.9200,1035.3600,1044.5700,1437448
2017-12-06,1016.5200,1039.5800,1015.3100,1032.7200,1369276
2017-12-05,1010.9900,1036.6800,1002.3200,1019.6000,1927802
2017-12-04,1027.8000,1031.3400,1009.2200,1011.8700,1896325
2017-12-01,1030.4100,1037.2400,1016.9000,1025.0700,1866985
2017-11-30,1039.9400,1044.1400,1030.0700,1036.1700,2231818
2017-11-29,1056.1800,1058.7700,1029.6500,1037.3800,2787784
2017-11-28,1073.9900,1080.0000,1054.5400,1063.2900,1694098
2017-11-27,1058.5700,1073.0400,1054.7700,1072.0100,1708195
2017-11-24,1054.3900,1060.0700,1051.9200,1056.5200,825342
2017-11-22,1051.1600,1055.4300,1047.2500,1051.9200,721498
2017-11-21,1040.0400,1050.3900,1039.1400,1050.3000,1075568
2017-11-20,1036.0000,1038.7000,1032.6800,1034.6600,850423
2017-11-17,1049.8000,1051.0000,1033.7300,1035.8900,1286044
2017-11-16,1038.7500,1051.7600,1038.0000,1048.4700,1125995
2017-11-15,1035.0000,1039.6300,1030.7600,1036.4100,900695
2017-11-14,1037.7200,1042.3000,1029.3300,1041.6400,982782
2017-11-13,1040.8000,1048.7400,1039.2600,1041.2000,914852
2017-11-10,1043.8700,1046.6300,1041.2200,1044.1500,955500
2017-11-09,1048.0000,1050.8800,1035.8500,1047.7200,1776722
2017-11-08,1050.0500,1062.6900,1047.0500,1058.2900,1214600
2017-11-07,1049.6500,1053.4100,1043.0000,1052.3900,1254965
2017-11-06,1049.1000,1052.5900,1042.0000,1042.6800,897897
2017-11-03,1042.7500,1050.6600,1037.6500,1049.9900,1370874
2017-11-02,1039.9900,1045.5200,1028.6600,1042.9700,1233333
2017-11-01,1036.3200,1047.8600,1034.0000,1042.6000,2105729
2017-10-31,1033.0000,1041.0000,1026.3000,1033.0400,1490660
2017-10-30,1029.1600,1039.8300,1022.3300,1033.1300,2245352
2017-10-27,1030.9900,1063.6200,1026.8500,1033.6700,5139945
2017-10-26,998.4700,1006.5100,990.4700,991.4200,1827682
2017-10-25,986.2700,994.4300,977.7200,991.4600,1368042
2017-10-24,986.5000,989.2600,977.0800,988.4900,1416283
2017-10-23,1005.1800,1005.7900,983.1000,985.5400,1623580
2017-10-20,1007.0500,1008.6500,1002.2700,1005.0700,1568454
2017-10-19,1004.7500,1007.3200,997.3000,1001.8400,1677021
2017-10-18,1011.0500,1016.3100,1005.3200,1012.7400,1270218
2017-10-17,1007.4400,1014.5600,1006.0500,1011.0000,991412
2017-10-16,1009.6300,1012.0000,1001.5200,1009.3500,1066744
2017-10-13,1009.1100,1014.7600,1007.0600,1007.8700,1308881
2017-10-12,1003.8400,1011.5400,1001.1000,1005.6500,1521137
2017-10-11,989.0400,1007.5700,987.9400,1005.6500,1748443
2017-10-10,995.3000,997.4700,981.1100,987.8000,1158864
2017-10-09,995.0000,1000.4600,991.5000,992.3100,1151035
2017-10-06,980.0000,994.2600,978.5100,993.6400,1490744
2017-10-05,972.7900,986.5100,970.2700,985.1900,1627255
2017-10-04,971.7600,974.4000,965.6100,966.7800,896531
2017-10-03,967.5600,972.4400,962.7100,972.0800,1080312
2017-10-02,975.6500,977.7400,961.9500,967.4700,1466444
2017-09-29,966.0000,975.8100,966.0000,973.7200,1906445
2017-09-28,956.2500,966.1800,955.5500,964.8100,1347750
2017-09-27,942.7400,965.4300,941.9500,959.9000,2313498
2017-09-26,936.6900,944.0800,935.1200,937.4300,1618182
2017-09-25,939.4500,939.7500,924.5100,934.2800,1847436
2017-09-22,942.7700,950.0000,940.8400,943.2600,1067617
2017-09-21,948.1300,952.8000,939.3800,947.5500,1302726
2017-09-20,937.7300,950.0000,937.5000,947.5400,1896919
2017-09-19,933.4100,937.9400,926.6600,936.8600,1217430
2017-09-18,935.0100,936.8600,925.4000,929.7500,1445532
2017-09-15,940.0900,941.7500,931.2500,935.2900,1940047
2017-09-14,946.0000,948.0300,938.3600,940.1300,1415168
2017-09-13,945.5000,952.8500,944.7400,950.4400,1092849
2017-09-12,946.9200,948.0900,937.5000,946.6500,1245767
2017-09-11,947.2000,952.6800,941.0000,943.2900,1317796
2017-09-08,949.7000,950.7000,940.0100,941.4100,996449
2017-09-07,944.2500,950.5000,937.5300,949.8900,1103286
2017-09-06,943.8700,944.5000,932.6800,942.0200,1375952
2017-09-05,946.8600,951.3900,935.6000,941.4800,1455058
2017-09-01,957.4700,958.3300,950.2800,951.9900,1034769
2017-08-31,946.3000,957.2000,946.2500,955.2400,1672387
2017-08-30,935.6700,945.8600,934.0500,943.6300,1112814
2017-08-29,919.9500,938.1900,919.3100,935.7500,1144834
2017-08-28,931.8800,934.8500,926.1100,928.1300,1025199
2017-08-25,939.2100,940.7300,930.1000,930.5000,1169101
2017-08-24,943.7100,946.3100,930.7400,936.8900,1249098
2017-08-23,937.0000,945.4300,935.2400,942.5800,1126487
2017-08-22,926.9600,941.9600,926.1700,940.4000,1711377
2017-08-21,925.7700,928.2500,918.6000,920.8700,1292624
2017-08-18,926.9800,931.0200,923.4500,926.1800,1327288
2017-08-17,942.9500,943.8100,927.6400,927.6600,1653779
2017-08-16,941.2500,949.9000,940.0400,944.2700,1329301
2017-08-15,941.0300,943.0700,936.6400,938.0800,1006064
2017-08-14,939.0700,941.0400,934.4900,938.9300,1140212`
)