Skip to content
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

sos GET OPEN ORDERS #23

Closed
Al13n0 opened this issue Sep 29, 2016 · 5 comments
Closed

sos GET OPEN ORDERS #23

Al13n0 opened this issue Sep 29, 2016 · 5 comments
Labels
help wanted Wizard needs food question General discussion about the api or wrapper

Comments

@Al13n0
Copy link

Al13n0 commented Sep 29, 2016

Hello i am a young developer this is my first time with the api of poloniex, I am developing a python bot for Poloniex , but is all the day that i try to make a request to get the open order but it fails!!
My code is very similar to your but I dont know, why it dosent works the request status is 200 but this is the reply:
{'error': 'Invalid command.'}

this is my code:
`# Returns open orders for a given market

def getOpenOrders(self,url,comand, market):

    nonce = int(time.time())
    urlrequest = url  + '?apikey=' + self.apiKey +'&command='+comand + '&nonce=' +str(nonce) + '&market=' + str(market)
    print(urlrequest)
    param =  'command='+comand + '&nonce=' +str(nonce) + "&market=" +str(market)
    signature =  hmac.new(self.Secret.encode(),param.encode(), hashlib.sha512).hexdigest()
    headers = {
            'Sign':signature,
            'Key': self.apiKey
        }

    self.r = requests.post(urlrequest,headers= headers,)
    print(self.r)
    print(self.r.json())

could you help me to fix??

i hope to receive your answear and sorry again`

@s4w3d0ff
Copy link
Owner

s4w3d0ff commented Sep 29, 2016

If you use this repo:

pip install git+https://github.com/s4w3d0ff/python-poloniex.git

To get the public order book for a market:

import poloniex
polo = poloniex.Poloniex()
orders = polo.marketOrders(pair='BTC_CGA', depth=10)
print(orders)
#or
orders = polo.api('returnOrderBook', { 'currencyPair': 'BTC_CGA', 'depth': '10' } )
print(orders)

To get your personal order book:

import poloniex
polo = poloniex.Poloniex('YOUR-TRADE-API-KEY-HERE', 'YourApiSecretKeyGoesHere')
orders = polo.myOrders(pair='all')
print(orders)
#or
orders = polo.api('returnOpenOrders', {'currencyPair': 'all'})
print(orders)

@s4w3d0ff s4w3d0ff added help wanted Wizard needs food question General discussion about the api or wrapper labels Sep 29, 2016
@s4w3d0ff
Copy link
Owner

Everything you are trying to write code for has already been done for you. You just need to install and use an api wrapper (like this repo!).

@Al13n0
Copy link
Author

Al13n0 commented Sep 29, 2016

ok i will do it is better dont reinvent the wheeil

@Al13n0 Al13n0 closed this as completed Sep 29, 2016
@s4w3d0ff
Copy link
Owner

This function is probably what you are looking for. It identifies the command as public or private, then encodes the command as a url and posts the request. If the command is "private" then the function will sign the headers and send the request with the encoded url and signed headers. It is all wrapped in a class called Poloniex that holds the api key and secret. It also keeps nonces in order and has a call limiter called coach.

@Al13n0
Copy link
Author

Al13n0 commented Sep 29, 2016

now everthing works good
thank you so much !!

i really suggest to use this library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Wizard needs food question General discussion about the api or wrapper
Projects
None yet
Development

No branches or pull requests

2 participants