-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exchange Get Order Function #32
Comments
Please update pyupbit module to the latest version. Could you attach your code with |
안녕하세요.
늦은 시간인데 이렇게 회신 주셔서 감사합니다.
코드는 하기와 같습니다.
주문을 넣고.. 바로 주문 코드를 가지고 현재 주문 상태를 확인 하려고 테스트 도중 에러가 발생하네요.
바쁘시겠지만 회신 주시면 너무 감사 할 것 같습니다.
그럼 좋은 하루 되세요.
symbol = 'KRW-DOGE'
###################################################
def get_tickers():
# get the current ticker list from the exch
ticker = pyupbit.get_tickers()
return ticker
def get_price(ticker, lev=0):
# get bid and ask of the ticker
# code modified to get the first item in the list for single ticker data return
price = pyupbit.get_orderbook(ticker)[0]
time = price['timestamp']
price = price['orderbook_units'][lev]
# insert time stamp into single price data
price['timestamp'] = time
# Calcute the value in currency
price['ask_val'] = round(price['ask_price']*price['ask_size'])
price['bid_val'] = round(price['bid_price']*price['bid_size'])
return price
def get_order_stat(orderID):
# fucntion to check the order status
# passing UUID but can pass other parameters to get list of orders
c_acct = pyupbit.Upbit(acc_key, sec_key)
cStatus = c_acct.get_order(orderID)
return cStatus['state']
def input_order(ticker, dir, price, amount):
c_acct = pyupbit.Upbit(acc_key, sec_key)
volume = amount/price
if dir == 'B':
orderID = c_acct.buy_limit_order(ticker, price, volume)
elif dir == 'S':
orderID = c_acct.sell_limit_order(ticker, price, volume)
# catch errors when the order is not input correctly
try:
cID = orderID['uuid']
except(KeyError):
cID = ''
return cID
def cancel_order(orderID):
# function to cancel order
c_acct = pyupbit.Upbit(acc_key, sec_key)
return c_acct.cancel_order(orderID)
tempOrder = input_order(symbol, 'S', 1000, 100000)
print(get_order_stat(tempOrder))
…On Mon, May 17, 2021 at 12:23 AM mr-yoo ***@***.***> wrote:
Please update pyupbit module to the latest version.
pip install -U pyupbit
Could you attach your code with uuid?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFQMLEYFADOVE6EFC6UDLSLTN7PO5ANCNFSM4462XEOQ>
.
--
최종희 (Nathan Choi)
Cell: +8210 9156 0957
eMail: ***@***.***
|
방금 말씀하신데로 업데이트 하고 다시 해 봤더니 되네요.
너무 감사합니다.
…On Mon, May 17, 2021 at 12:47 AM Jonghui Choi ***@***.***> wrote:
안녕하세요.
늦은 시간인데 이렇게 회신 주셔서 감사합니다.
코드는 하기와 같습니다.
주문을 넣고.. 바로 주문 코드를 가지고 현재 주문 상태를 확인 하려고 테스트 도중 에러가 발생하네요.
바쁘시겠지만 회신 주시면 너무 감사 할 것 같습니다.
그럼 좋은 하루 되세요.
symbol = 'KRW-DOGE'
###################################################
def get_tickers():
# get the current ticker list from the exch
ticker = pyupbit.get_tickers()
return ticker
def get_price(ticker, lev=0):
# get bid and ask of the ticker
# code modified to get the first item in the list for single ticker data return
price = pyupbit.get_orderbook(ticker)[0]
time = price['timestamp']
price = price['orderbook_units'][lev]
# insert time stamp into single price data
price['timestamp'] = time
# Calcute the value in currency
price['ask_val'] = round(price['ask_price']*price['ask_size'])
price['bid_val'] = round(price['bid_price']*price['bid_size'])
return price
def get_order_stat(orderID):
# fucntion to check the order status
# passing UUID but can pass other parameters to get list of orders
c_acct = pyupbit.Upbit(acc_key, sec_key)
cStatus = c_acct.get_order(orderID)
return cStatus['state']
def input_order(ticker, dir, price, amount):
c_acct = pyupbit.Upbit(acc_key, sec_key)
volume = amount/price
if dir == 'B':
orderID = c_acct.buy_limit_order(ticker, price, volume)
elif dir == 'S':
orderID = c_acct.sell_limit_order(ticker, price, volume)
# catch errors when the order is not input correctly
try:
cID = orderID['uuid']
except(KeyError):
cID = ''
return cID
def cancel_order(orderID):
# function to cancel order
c_acct = pyupbit.Upbit(acc_key, sec_key)
return c_acct.cancel_order(orderID)
tempOrder = input_order(symbol, 'S', 1000, 100000)
print(get_order_stat(tempOrder))
On Mon, May 17, 2021 at 12:23 AM mr-yoo ***@***.***> wrote:
> Please update pyupbit module to the latest version.
> pip install -U pyupbit
>
> Could you attach your code with uuid?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#32 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFQMLEYFADOVE6EFC6UDLSLTN7PO5ANCNFSM4462XEOQ>
> .
>
--
최종희 (Nathan Choi)
Cell: +8210 9156 0957
eMail: ***@***.***
--
최종희 (Nathan Choi)
Cell: +8210 9156 0957
eMail: ***@***.***
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
get_order function results in error when passed in UUID as follows:
{'error': {'message': 'market does not have a valid value', 'name': 'validation_error'}}
The text was updated successfully, but these errors were encountered: