-
Notifications
You must be signed in to change notification settings - Fork 345
Expand file tree
/
Copy pathtest_aggs.py
More file actions
113 lines (106 loc) · 3.09 KB
/
test_aggs.py
File metadata and controls
113 lines (106 loc) · 3.09 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
from base import BaseTest
from massive.rest.models import (
Agg,
GroupedDailyAgg,
DailyOpenCloseAgg,
PreviousCloseAgg,
)
class AggsTest(BaseTest):
def test_list_aggs(self):
aggs = [
a for a in self.c.list_aggs("AAPL", 1, "day", "2005-04-02", "2005-04-04")
]
expected = [
Agg(
open=1.5032,
high=1.5064,
low=1.4489,
close=1.4604,
volume=642646396.0,
vwap=1.469,
timestamp=1112331600000,
transactions=82132,
),
Agg(
open=1.4639,
high=1.4754,
low=1.4343,
close=1.4675,
volume=578172308.0,
vwap=1.4589,
timestamp=1112587200000,
transactions=65543,
),
]
self.assertEqual(aggs, expected)
def test_get_aggs(self):
aggs = self.c.get_aggs("AAPL", 1, "day", "2005-04-01", "2005-04-04")
expected = [
Agg(
open=1.5032,
high=1.5064,
low=1.4489,
close=1.4604,
volume=642646396.0,
vwap=1.469,
timestamp=1112331600000,
transactions=82132,
),
Agg(
open=1.4639,
high=1.4754,
low=1.4343,
close=1.4675,
volume=578172308.0,
vwap=1.4589,
timestamp=1112587200000,
transactions=65543,
),
]
self.assertEqual(aggs, expected)
def test_get_grouped_daily_aggs(self):
aggs = self.c.get_grouped_daily_aggs("2005-04-04", True)
expected = [
GroupedDailyAgg(
ticker="GIK",
open=9.99,
high=10.02,
low=9.9,
close=10.02,
volume=895345,
vwap=9.9979,
timestamp=1602705600000,
transactions=96,
)
]
self.assertEqual(aggs, expected)
def test_get_daily_open_close_agg(self):
aggs = self.c.get_daily_open_close_agg("AAPL", "2005-04-01", True)
expected = DailyOpenCloseAgg(
after_hours=123,
close=123,
from_="2021-04-01",
high=124.18,
low=122.49,
open=123.66,
pre_market=123.45,
status="OK",
symbol="AAPL",
volume=75089134,
)
self.assertEqual(aggs, expected)
def test_get_previous_close_agg(self):
aggs = self.c.get_previous_close_agg("AAPL")
expected = [
PreviousCloseAgg(
ticker="AAPL",
close=156.8,
high=162.34,
low=156.72,
open=162.25,
timestamp=1651003200000,
volume=95595226.0,
vwap=158.6074,
)
]
self.assertEqual(aggs, expected)