강의

멘토링

커뮤니티

Cộng đồng Hỏi & Đáp của Inflearn

Hình ảnh hồ sơ của mirrorlaw0346
mirrorlaw0346

câu hỏi đã được viết

Phát triển bot giao dịch thuật toán bitcoin

Triển khai bot giao dịch - tính năng chung

오류 문의

Viết

·

713

0

오픈 API 이해하기(조회, 매매) 강의  
 
#잔고조회
result = up.get_balances()
result
 
하면 
 
AttributeError                            Traceback (most recent call last)
<ipython-input-7-ba1dbc95b463> in <module>
      1 #잔고조회
----> 2 result = up.get_balances()
      3 result

~\anaconda3\lib\site-packages\pyupbit\exchange_api.py in get_balances(self)
    141         '''
    142         url = "https://api.upbit.com/v1/accounts"
--> 143         headers = self._request_headers()
    144         return _send_get_request(url, headers=headers)
    145 

~\anaconda3\lib\site-packages\pyupbit\exchange_api.py in _request_headers(self, data)
    105         if data is not None:
    106             payload['query'] = urlencode(data)
--> 107         jwt_token = jwt.encode(payload, self.secret, algorithm="HS256").decode('utf-8')
    108         authorization_token = 'Bearer {}'.format(jwt_token)
    109         headers = {"Authorization": authorization_token}

AttributeError: 'str' object has no attribute 'decode'

라고 나오는데 어떻게 처리하면 되나요?

투자pandas퀀트

Câu trả lời 3

0

mirrorlaw0346님의 프로필 이미지
mirrorlaw0346
Người đặt câu hỏi

친절히 알려 주셔서 감사합니다

 

0

multicoreit님의 프로필 이미지
multicoreit
Người chia sẻ kiến thức

안녕하세요 법경님.

제 PC에서 python3.7.9 버전으로 테스트했는데 정상적으로 동작하는 것를 확인했습니다. 원래 pyupbit 패키지를 다운로드 받으면 최신 버전은 마지막에 decode 함수를 호출하지 않는데 법경님 로그를 살펴보면 예전 버전이 설치된 것 같습니다. 다음과 같이 조치하실 것을 추천드립니다.

1. 가장 먼저 pyupbit 패지키를 재설치 해보는 것을 추천드립니다.

삭제 : pip uninstall pyupbit

설치 : pip install pyupblit

2. 그래도 오류가 계속 발생한다면

~\anaconda3\lib\site-packages\pyupbit\exchange_api.py 프로그램을 에디터로 열어서 다음과 같이 수정해주세요.

        #jwt_token = jwt.encode(payload, self.secret, algorithm="HS256").decode('utf-8')

        jwt_token = jwt.encode(payload, self.secret, algorithm="HS256")     # PyJWT >= 2.0

감사합니다.

0

multicoreit님의 프로필 이미지
multicoreit
Người chia sẻ kiến thức

안녕하세요 법경님.

혹시 사용하는 파이썬 버전이 어떻게 되세요?

mirrorlaw0346님의 프로필 이미지
mirrorlaw0346
Người đặt câu hỏi

3.7.9 입니다

 

Hình ảnh hồ sơ của mirrorlaw0346
mirrorlaw0346

câu hỏi đã được viết

Đặt câu hỏi