Skip to content

Commit 784490d

Browse files
committed
feat: 연 캔들 조회 메서드 get_candles_year 추가 (upbit api v1.5.4)
1 parent 4ba98f7 commit 784490d

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ data = res.json()
9797
| | 일(Day) 캔들 | get_candles_day |
9898
| | 주(Week) 캔들 | get_candles_week |
9999
| | 월(Month) 캔들 | get_candles_month |
100+
| | 연(Year) 캔들 | get_candles_year |
100101
| 시세 체결 조회 | 최근 체결 내역 | get_trades_ticks |
101102
| 시세 현재가 조회 | 현재가 정보 | get_ticker |
102103
| 시세 현재가 조회 | 마켓 단위 현재가 정보 | get_tickers_by_quote |

upbit/upbit.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,53 @@ def get_candles_month(self,
18941894

18951895
return self._request('get', url, params=params, **kwargs)
18961896

1897+
def get_candles_year(self,
1898+
market: str,
1899+
*,
1900+
to: Optional[str] = None,
1901+
count: Optional[int] = None,
1902+
**kwargs) -> Response:
1903+
"""연(Year) 캔들 조회
1904+
1905+
API 요청 및 응답에 대한 자세한 정보는 공식 문서 참고:
1906+
`Upbit API Doc <https://docs.upbit.com/reference/%EB%85%84year-%EC%BA%94%EB%93%A4>`_
1907+
1908+
:param market: 마켓 코드 (ex. KRW-BTC)
1909+
:param to: 마지막 캔들 시각 (exclusive). 포맷 : yyyy-MM-dd'T'HH:mm:ss'Z' or yyyy-MM-dd HH:mm:ss. 비워서 요청시 가장 최근 캔들
1910+
:param count: 캔들 개수. 최대 200
1911+
:param kwargs: `requests.Session.request` 호출에 사용할 파라미터
1912+
1913+
:return: API 서버 응답
1914+
1915+
Usage::
1916+
1917+
upbit = Upbit()
1918+
res = upbit.get_candles_second('KRW-BTC')
1919+
print(res.json())
1920+
1921+
[{
1922+
"market": "KRW-BTC",
1923+
"candle_date_time_utc": "2024-01-01T00:00:00",
1924+
"candle_date_time_kst": "2024-01-01T09:00:00",
1925+
"opening_price": 96290000,
1926+
"high_price": 1231356000,
1927+
"low_price": 124.5,
1928+
"trade_price": 85375000,
1929+
"timestamp": 1727845502277,
1930+
"candle_acc_trade_price": 60613272545.65653,
1931+
"candle_acc_trade_volume": 708.81714523,
1932+
"first_day_of_period": "2024-01-01"
1933+
}, ...]
1934+
"""
1935+
url = self._endpoint + "/candles/years/"
1936+
params = {
1937+
"market": market,
1938+
"to": to,
1939+
"count": count,
1940+
}
1941+
1942+
return self._request('get', url, params=params, **kwargs)
1943+
18971944
# --------------------------------------------------------------------------
18981945
# Quotation API > 시세 체결 조회
18991946
# --------------------------------------------------------------------------

0 commit comments

Comments
 (0)