I am writing a bot to trade cryptocurrencies using bitvavo.com as my exchange. On their website, you can find an API section (https://docs.bitvavo.com/) with this bit of code:
from python_bitvavo_api.bitvavo import Bitvavo
bitvavo = Bitvavo('<APIKEY>', '<APISECRET>')
response = bitvavo.balance({})
for item in response:
print(item)
However, when I copied and pasted this code into my IDE, it gave me the following error:
__init__() takes from 1 to 2 positional arguments but 3 were given
When I tried just one variable inside the (), I noticed that the program ran, but Bitvavo.com game me an error due to not having the correct values: (APIKEY, APISECRET)
, which is normal.
After some research, I found out that in most of the cases, it has something to do with the variable "self" (which does not show) already using one of the two variable spots inside the Bitvavo()
. But as I didn't create this function myself due to it coming from the from python_bitvavo_api.bitvavo import Bitvavo
section, I don't know how to fix this.
If anyone knows perhaps how to fix this and is willing to show me the solution or give an alternative to this, I would be really thankful. And if possible, please explain it in the most basic way ever because I'm dumb! :)
CodePudding user response:
The python_bitvavo_api
library class takes a single dict
as it's argument, containing multiple params. You mean:
bitvavo = Bitvavo({'APIKEY': '<APIKEY>', 'APISECRET': '<APISECRET>' })
CodePudding user response:
Judging from the example(s) on the Bitvavo API Github page, you need to provide that information as a dictionary, rather than individual arguments.
from python_bitvavo_api.bitvavo import Bitvavo
bitvavo = Bitvavo({
'APIKEY': '<APIKEY>',
'APISECRET': '<APISECRET>',
'RESTURL': 'https://api.bitvavo.com/v2',
'WSURL': 'wss://ws.bitvavo.com/v2/',
'ACCESSWINDOW': 10000,
'DEBUGGING': False
})
This came from the readme here
Hence it complains about too many arguments. It was only expecting 1 (other than the class's own self
which is inserted automatically, hence a total of 2).