i am trying to do a trade on coinbase via script. I can pull the prices, i get the account data, the payment methods and so on....finally i would like to buy some coins with my EUR-Wallet. There is some amount of money on this account for testing purposes.
The ID of the payment method etc shall be chosen correctly but nevertheless the error above in the headline arises. I would be glad for your experiences and help;) with kind regards, John
In the following ,i will try to describe all the actions done in my script for reproducing this error:
accounts=client.get_accounts() #get my accounts (i have EUR-Wallet, ETH, LTC and BTC Accounts)
payment_method=client.get_payment_methods()[0] #Chooses the EUR-Wallet as my paymentmethod
account=client.get_account("abcdefghihklmnoqrstuvwxyz") # Argument is the ID of EUR-Wallet
buy = account.buy(amount='0.00001', currency="LTC", payment_method=payment_method.id)
print payment_method
So as you can see i have the correct payment_method ID as well as the correct EUR-Wallet ID. And all my accounts are allowed to deal with the whole set of requests that coinbase API can offer. this is done in the configuration on my coinbase account.
I would be glad for support.
This is the full error message:
Traceback (most recent call last):
File "/home/pi/Desktop/First_Script.py", line 265, in <module>
payment_method=payment_method.id)
File "/usr/local/lib/python2.7/dist-packages/coinbase-2.0.6-py2.7.egg/coinbase/wallet/model.py", line 200, in buy
return self.api_client.buy(self.id, **params)
File "/usr/local/lib/python2.7/dist-packages/coinbase-2.0.6-py2.7.egg/coinbase/wallet/client.py", line 381, in buy
response = self._post('v2', 'accounts', account_id, 'buys', data=params)
File "/usr/local/lib/python2.7/dist-packages/coinbase-2.0.6-py2.7.egg/coinbase/wallet/client.py", line 132, in _post
return self._request('post', *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/coinbase-2.0.6-py2.7.egg/coinbase/wallet/client.py", line 116, in _request
return self._handle_response(response)
File "/usr/local/lib/python2.7/dist-packages/coinbase-2.0.6-py2.7.egg/coinbase/wallet/client.py", line 125, in _handle_response
raise build_api_error(response)
InvalidRequestError: APIError(id=invalid_request): Can't buy with this account
and this the relevant section in the package that throws the error:
def _request(self, method, *relative_path_parts, **kwargs):
"""Internal helper for creating HTTP requests to the Coinbase API.
Raises an APIError if the response is not 20X. Otherwise, returns the
response object. Not intended for direct use by API consumers.
"""
uri = self._create_api_uri(*relative_path_parts)
data = kwargs.get('data', None)
if data and isinstance(data, dict):
kwargs['data'] = encode_params(data)
if self.VERIFY_SSL:
kwargs.setdefault('verify', COINBASE_CRT_PATH)
else:
kwargs.setdefault('verify', False)
kwargs.update(verify=self.VERIFY_SSL)
response = getattr(self.session, method)(uri, **kwargs)
return self._handle_response(response)
def _handle_response(self, response):
"""Internal helper for handling API responses from the Coinbase server.
Raises the appropriate exceptions when necessary; otherwise, returns the
response.
"""
if not str(response.status_code).startswith('2'):
raise build_api_error(response)
return response
def _get(self, *args, **kwargs):
return self._request('get', *args, **kwargs)
def _post(self, *args, **kwargs):
return self._request('post', *args, **kwargs)
def _put(self, *args, **kwargs):
return self._request('put', *args, **kwargs)
Dear guys,
i am trying to do a trade on coinbase via script. I can pull the prices, i get the account data, the payment methods and so on....finally i would like to buy some coins with my EUR-Wallet. There is some amount of money on this account for testing purposes. The ID of the payment method etc shall be chosen correctly but nevertheless the error above in the headline arises. I would be glad for your experiences and help;) with kind regards, John
In the following ,i will try to describe all the actions done in my script for reproducing this error:
shows:
So as you can see i have the correct payment_method ID as well as the correct EUR-Wallet ID. And all my accounts are allowed to deal with the whole set of requests that coinbase API can offer. this is done in the configuration on my coinbase account. I would be glad for support.
This is the full error message:
and this the relevant section in the package that throws the error: