프로젝트

일반

사용자정보

b 호가 » 이력 » 버전 1

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

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
timestamp : 호가 조회 시간
29
payment_currency : 결제 통화
30
order_currency : 가상화폐 티커
31
bids : 매수 호가
32
asks : 매도 호가
33
34
*timestamp 시간 변환 소스코드*
35
36
<pre>
37
import pybithumb
38
import datetime
39
40
orderbook = pybithumb.get_orderbook("BTC") # 호가 정보
41
ms = int(orderbook['timestamp'])
42
43
dt = datetime.datetime.fromtimestamp(ms/1000) # 시간 계산
44
print(dt)
45
</pre>
46
47
*결과*
48
49
<pre>
50
2025-02-04 13:53:03.395000
51
</pre>
52
53
%{color:red}※timestamp 계산법%
54
55
<pre>
56
timestamp값 / 1000(초로 변환) / 86400(1일에 해당하는 초) / 365(1년)
57
<pre>