프로젝트

일반

사용자정보

B 호가 전체 정보 » 이력 » 버전 1

이태훈, 2025/02/04 04:58

1 1 이태훈
h1. 호가 전체 정보
2
3
h3. 소스코드
4
5
<pre>
6
import pybithumb
7
8
orderbook = pybithumb.get_orderbook("BTC") # 호가 정보
9
print(orderbook)
10
11
# 호가 키워드
12
for k in orderbook:
13
    print(k)
14
</pre>
15
16
h3. 결과
17
18
<pre>
19
{'timestamp': '1738644390448', 'payment_currency': 'KRW', 'order_currency': 'BTC', 'bids': [{'price': 155693000.0, 'quantity': 0.002}, {'price': 155685000.0, 'quantity': 0.0102}, {'price': 155682000.0, 'quantity': 0.0113}, {'price': 155681000.0, 'quantity': 0.0501}, {'price': 155680000.0, 'quantity': 0.0247}], 'asks': [{'price': 155694000.0, 'quantity': 0.0012}, {'price': 155695000.0, 'quantity': 0.0025}, {'price': 155737000.0, 'quantity': 0.0114}, {'price': 155740000.0, 'quantity': 0.0163}, {'price': 155754000.0, 'quantity': 0.0001}]}
20
timestamp
21
payment_currency
22
order_currency
23
bids
24
asks
25
</pre>
26
27
h3. 부가 설명
28
29
timestamp : 호가 조회 시간
30
payment_currency : 결제 통화
31
order_currency : 가상화폐 티커
32
bids : 매수 호가
33
asks : 매도 호가
34
35
*timestamp 시간 변환 소스코드*
36
37
<pre>
38
import pybithumb
39
import datetime
40
41
orderbook = pybithumb.get_orderbook("BTC") # 호가 정보
42
ms = int(orderbook['timestamp'])
43
44
dt = datetime.datetime.fromtimestamp(ms/1000) # 시간 계산
45
print(dt)
46
</pre>
47
48
*결과*
49
50
<pre>
51
2025-02-04 13:53:03.395000
52
</pre>
53
54
%{color:red}※timestamp 계산법%
55
56
<pre>
57
timestamp값 / 1000(초로 변환) / 86400(1일에 해당하는 초) / 365(1년)
58
</pre>