forked from HuobiRDCenter/huobi_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_get_best_quote.py
53 lines (46 loc) · 1.36 KB
/
test_get_best_quote.py
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
import unittest
from huobi.impl.utils import *
from huobi.model.constant import *
from huobi.impl.restapirequestimpl import RestApiRequestImpl
data = '''
{
"status": "ok",
"ch": "market.ethusdt.detail.merged",
"ts": 1550223581490,
"tick": {
"amount": 222930.8868295491,
"open": 122.4,
"close": 122.24,
"high": 123.42,
"id": 100417063447,
"count": 68987,
"low": 120.25,
"version": 100417063447,
"ask": [
122.26,
0.8271
],
"vol": 27123490.874530632,
"bid": [
122.24,
2.6672
]
}
}
'''
class TestGetBestQuote(unittest.TestCase):
def test_request(self):
impl = RestApiRequestImpl("", "")
request = impl.get_best_quote("btcusdt")
self.assertEqual("GET", request.method)
self.assertTrue(request.url.find("/market/detail/merged") != -1)
self.assertTrue(request.url.find("symbol=btcusdt") != -1)
def test_result(self):
impl = RestApiRequestImpl("", "")
request = impl.get_best_quote("btcusdt")
best_quote = request.json_parser(parse_json_from_string(data))
self.assertEqual(1550223581490, best_quote.timestamp)
self.assertEqual(122.26, best_quote.ask_price)
self.assertEqual(0.8271, best_quote.ask_amount)
self.assertEqual(122.24, best_quote.bid_price)
self.assertEqual(2.6672, best_quote.bid_amount)