Python bitcoin bot
We import the requests, json and time modules in a normal way. And the numpy and matplotlib modules are imported in a normal way but I personally like to call it 'np' to the numpy module and 'plt' to the matplotlib module. Now we will create global declarations so that the program can recognize these variables in any part of the code and use them without having any change for any function that we believe.
In this case, they are simple The variable 's' represents the module requests using the 'session' function. So that each time we make a request to the server this store the cookies locally.
Also for the server does not think that we are only a request sent from our software we will change the User-Agent to one of Firefox. In this way the server believes that the request is sent from a browser and we have no problem.
Now that we have the necessary modules to create the software? The first thing we will do is organize our ideas and understand how the server works and the Api responses of it. Then we open the coinmarketcap page to see the requests the server tells us using fiddler: Now we find a request or url to the server that returns the data of the coinmarketcap graph: Inside that url we will find all the graphics of the graphic.
But there is a problem That returns all the bitcoin data, since And we want more recent data to make a more accurate prediction. Then, click on the button in coinmarketcap that says: Now that we have the link we need to obtain the data we need, we analyze that request in Fiddler so we can replicate it in our software. It is a simple request API with the method 'GET' and the timestamp of the day of 1 week ago and the timestamp of the current moment. In python it is very easy to interpret this.
And we add the request with the corresponding headers of that request:. But it also works with a webhook from Slack! Composer installing the coinbase library. Coinbase API page c Coinbase. Keep your key and secret safe! When an attacker gains access to them it's like handing them over your house key. For Slack use this tutorial to get the webhook. You need to be an admin to setup a webhook for rocket.
Either host your own instance it's very easy with Docker or ask an admin you trust to do it for you. Using the following commands, the bot will create a transacitons.
After setup you can start the watchdog: The heart of the bot is an infinite loop that checks periodically every 10 seconds for price changes. You can start it yourself by using the command php trader. Bot working like charm. Raspberry Pi watching your coins for you. There are no ads on this https enforced blog.
Home About me Publications Cryptobin in the media.