Giter VIP home page Giter VIP logo

ujhin / upbit-client Goto Github PK

View Code? Open in Web Editor NEW
55.0 4.0 42.0 1.77 MB

Upbit(업비트) Cryptocurrency Exchange Open API Client of Multi-Programming Language Support

Home Page: https://ujhin.github.io/upbit-client-docs/

License: MIT License

Python 9.00% Shell 0.44% Java 15.32% C++ 23.63% CMake 0.03% QMake 0.05% C# 18.47% Batchfile 0.01% Go 3.65% Scala 2.17% JavaScript 6.68% Kotlin 2.10% Lua 2.90% Ruby 2.04% Objective-C 4.45% PHP 1.62% R 3.62% Rust 3.83%
python client http-client open-api cryptocurrency crypto upbit-api upbit exchange cryptocurrency-exchanges

upbit-client's Introduction

Upbit Client

Upbit(업비트) Cryptocurrency Exchange API Client

Description

Upbit(업비트) Cryptocurrency Exchange Open API Client of Multi-Programming Language Support

Swagger Generated Support Languages

Install

  • pip command
pip install upbit-client
  • git command
git clone https://github.com/uJhin/upbit-client.git

Quick Start

REST Client

  • Check Your API Keys
# /v1/api_keys

from upbit.client import Upbit

access_key = "Your Access Key"
secret_key = "Your Secret Key"

client = Upbit(access_key, secret_key)
api_keys = client.APIKey.APIKey_info()
print(api_keys['result'])
  • Buy Currency
# /v1/orders

from upbit.client import Upbit

access_key = "Your Access Key"
secret_key = "Your Secret Key"

client = Upbit(access_key, secret_key)
order = client.Order.Order_new(
    market='KRW-BTC',
    side='bid',
    volume='0.1',
    price='3000000',
    ord_type='limit'
)
print(order['result'])
  • Sell Currency
# /v1/orders

from upbit.client import Upbit

access_key = "Your Access Key"
secret_key = "Your Secret Key"

client = Upbit(access_key, secret_key)
order = client.Order.Order_new(
    market='KRW-BTC',
    side='ask',
    volume='0.1',
    price='3000000',
    ord_type='limit'
)
print(order['result'])

WebSocket Client

  • Get Real-Time Ticker
# Using WebSocket

import json
import asyncio

from upbit.websocket import UpbitWebSocket


# Definition async function
async def ticker(sock, payload):
    async with sock as conn:
        await conn.send(payload)
        while True:
            recv = await conn.recv()
            data = recv.decode('utf8')
            result = json.loads(data)
            print(result)


sock = UpbitWebSocket()

currencies = ['KRW-BTC', 'KRW-ETH']
type_field = sock.generate_type_field(
    type='ticker',
    codes=currencies,
)
payload = sock.generate_payload(
    type_fields=[type_field]
)

event_loop = asyncio.get_event_loop()
event_loop.run_until_complete( ticker(sock, payload) )

Donation

uJhin's BTC
uJhin's ETH

upbit-client's People

Contributors

dependabot[bot] avatar pyup-bot avatar ujhin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

upbit-client's Issues

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Inquiry on upbit API client project (Rust).

Describe the bug
Hi,May I ask about your project on github? https://github.com/uJhin/upbit-client/tree/main/swg_generated/rust
I'm trying to develop bot using your api by Rust.
I had located rust source folder(swg_generated -> src -> rust) in my project butit generates compile errors, related with hyper crate.

Like,
use hyper::header::UserAgent;
-> unresolved import hyper::header::UserAgent
no UserAgent in header

I'm not sure whether my environment setting is wrong or the files itself have compile errors.
Can you check for these?

[feature] net_type

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

  • pr 드릴게요~
  • 기존 제안드린 pr 은 아무래도 merge 안해주실것 같아서 ..
  • commit 만 cherry pick 해주시면 어떨까 합니다. ㅎㅎ

Describe alternatives you've considered

Additional context

종류 API 요청 파라미터에 추가 (*필수 입력값) 응답 필드에 추가
서비스 정보 입출금 현황 (GET /v1/status/wallet)   O
입금 입금 리스트 조회 (GET /v1/deposits)   O
입금 개별 입금 조회 (GET /v1/deposit)   O
입금 입금 주소 생성 요청 (POST /v1/deposits/generate_coin_address) O  
입금 전체 입금 주소 조회 (GET /v1/deposits/coin_addresses)   O
입금 개별 입금 주소 조회 (GET /v1/deposits/coin_address) O O
출금 출금 리스트 조회 (GET /v1/withdraws)   O
출금 개별 출금 조회 (GET /v1/withdraw)   O
출금 출금 가능 정보 (GET /v1/withdraws/chance) O  
출금 디지털 자산 출금하기 (POST /v1/withdraws/coin) O O
출금 [신규] 출금 허용 주소 조회 (GET /v1/withdraws/coin_addresses)   O

[feature] ~/.upbit/credentials

Is your feature request related to a problem? Please describe.
I want to use multiple user in get credentials in home directory.

# ~/.upbit/credentials
[default]
access_key = 
secret_key = 

[profile-a]
access_key = 
secret_key = 

[profile-b]
access_key = 
secret_key = 
...

Describe the solution you'd like

  • as-is
from upbit.client import Upbit

access_key = "Your Access Key"
secret_key = "Your Secret Key"

client = Upbit(access_key, secret_key)
api_keys = client.APIKey.APIKey_info()
print(api_keys['result'])
  • to-be
from upbit.client import Upbit

client = Upbit() # default
client = Upbit(profile="profile-a")
api_keys = client.APIKey.APIKey_info()
print(api_keys['result'])

Additional context
I will make pr.

Order_info_all 요청에 param넣을시 Error

아래와 같이 Order_info_all 요청에 param을 넣으면 error 가 발생합니다.
1.3.1.1 버전되면서 발생합니다.
1.3.1.0 에선 정상동작 합니다.

재현가능한 코드

from upbit.client import Upbit

access_key = "MY KEY"
secret_key = "MY KEY"

client = Upbit(access_key, secret_key)
resp = client.Order.Order_info_all(states=['done', 'cancel'])
print(resp['result'])

Error log

Traceback (most recent call last):
  File "/usr/lib/python3.8/urllib/parse.py", line 925, in urlencode
    if len(query) and not isinstance(query[0], tuple):
TypeError: object of type 'APIKeyAuthenticator' has no len()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/myhome/upbit_test/test.py", line 44, in <module>
    resp = client.Order.Order_info_all(state='done')
  File "/home/myhome/upbit_test/.venv/lib/python3.8/site-packages/upbit/models.py", line 454, in Order_info_all
    future = self.__client.Order.Order_info_all(**kwargs)
  File "/home/myhome/upbit_test/.venv/lib/python3.8/site-packages/bravado/client.py", line 276, in __call__
    return http_client.request(
  File "/home/myhome/upbit_test/.venv/lib/python3.8/site-packages/bravado/requests_client.py", line 399, in request
    self.authenticated_request(sanitized_params),
  File "/home/myhome/upbit_test/.venv/lib/python3.8/site-packages/bravado/requests_client.py", line 440, in authenticated_request
    return self.apply_authentication(requests.Request(**request_params))
  File "/home/myhome/upbit_test/.venv/lib/python3.8/site-packages/bravado/requests_client.py", line 445, in apply_authentication
    return self.authenticator.apply(request)
  File "/home/myhome/upbit_test/.venv/lib/python3.8/site-packages/upbit/authentication.py", line 38, in apply
    payload = self.generate_payload(request)
  File "/home/myhome/upbit_test/.venv/lib/python3.8/site-packages/upbit/authentication.py", line 59, in generate_payload
    query = self.generate_query(params)
  File "/home/myhome/upbit_test/.venv/lib/python3.8/site-packages/upbit/authentication.py", line 74, in generate_query
    query = self.urlencode({
  File "/usr/lib/python3.8/urllib/parse.py", line 933, in urlencode
    raise TypeError("not a valid non-string sequence "
  File "/usr/lib/python3.8/urllib/parse.py", line 925, in urlencode
    if len(query) and not isinstance(query[0], tuple):
TypeError: not a valid non-string sequence or mapping object

주문리스트 및 주문 조회시 response state 에 대한 질문

공식 문서에 반환되는 state는 3가지로 wait, cancel, done 이라고 적혀있습니다.
wait(주문대기), cancel(주문취소), done(체결완료) 라고 되어있는데

매수 주문에 관한 주문 조회시 wait 상태에서 -> cancel 상태이고
매도 주문 관한 주문 조회시 wait 상태에서 -> done 상태로 바뀌는데 의도하신건지 궁금해서 물어봅니다.

쉽게 말해서 bid(매수) 측 에서는 주문 체결시 cancel 상태가 되고
ask(매도) 측에서는 주문 체결시 done 상태가 됩니다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.