프로젝트

일반

사용자정보

b 호가 » 이력 » 개정판 4

개정판 3 (이태훈, 2025/02/04 04:56) → 개정판 4/5 (이태훈, 2025/02/04 04:58)

h1. 호가 

 h3. 소스코드 

 <pre> 
 import pybithumb 

 orderbook = pybithumb.get_orderbook("BTC") # [[호가 전체 정보]] 호가 정보 
 print(orderbook) 

 # [[매수 호가]] 호가 키워드 
 for k in orderbook: 
     print(k) 
 </pre> 

 h3. 결과 

 <pre> 
 {'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}]} 
 timestamp 
 payment_currency 
 order_currency 
 bids 
 asks 
 </pre> 

 h3. 부가 설명 

 timestamp : 호가 조회 시간 
 payment_currency : 결제 통화 
 order_currency : 가상화폐 티커 
 bids : 매수 호가 
 asks : 매도 호가 

 *timestamp 시간 변환 소스코드* 

 <pre> 
 import pybithumb 
 import datetime 

 orderbook = pybithumb.get_orderbook("BTC") # 호가 정보 
 ms = int(orderbook['timestamp']) 

 dt = datetime.datetime.fromtimestamp(ms/1000) # 시간 계산 
 print(dt) 
 </pre> 

 *결과* 

 <pre> 
 2025-02-04 13:53:03.395000 
 </pre> 

 %{color:red}※timestamp 계산법% 

 <pre> 
 timestamp값 / 1000(초로 변환) / 86400(1일에 해당하는 초) / 365(1년) 
 </pre>