python packages
π pip3 install urllib
π pip3 install requests
π pip3 install json
π pip3 install pprint
This is to get data in an easy reading way.
π pip3 install tweepy
Main Package to make tweets !
cron
π npm install cron
See Downloading and installing Node.js
and npm | npm Docs
for more details about npm
TESTING integration
π pip3 install textwrap
If you have some of those packages, download only necessary ones.
1οΈβ£ git clone https://github.com/GaloisField2718/Twitter_python
2οΈβ£ Get your Twitter API Keys on Twitter dev Portal. You will pass your twitter account in twitter dev account.
3οΈβ£ Add your keys in dogeaccountpy/config.py
file.
4οΈβ£ Get your API-key in CoinMarketCap and put it in dogeaccountpy/prices.py
(it's indicated in the code).
5οΈβ£ You can change messages in dogeaccountpy/messages.py
.
6οΈβ£ You can make a first try with :
python3 tweets.py
7οΈβ£ Automation with cron :
When you have cron you can launch on your computer a command like which provided in
crontab.txt
file.
I created two twitter account : @Marketcryptopy and @dogeaccountpy which is running since few month and I want to share this code.
It's not strong coded and we can improve it in several differents ways but for now it works and that's cool π.
I will briefly details after what I used to get cryptocurrencies prices π€, what config we need to use with tweepy and basic tweepy commands.
I also want to provide the basic shell commands I use to interact with @Marketcryptopy on my console. I'm trying to use this account only in command line and never interact through Twitter interface. Sometimes it's harder but it's fun to see it's possible.
π§ͺ I tried to connect CMC API with latest Listings url
, metadata url
and tweepy
to get information about new CMC listings. Especially get important data as website, description, social medias,...
γ· Unfortunately, the textwrap
python which I used seems to not produce convienent output :
Your Tweet text is too long. For more information on how Twitter determines text length see https://github.com/twitter/twitter-text.
I'm working hard on this issue to produce soon π a working bot for this job.
To get prices I use 2 differents API :
π MarketCryptoPy : CoinMarketCap-API.
π The unofficial documentation : python-binance but it's quite hard to onboard through this. There is an incredible Youtube Channel @cryptorobotfr, they are french but you can translate the video and their code is in english so don't worry π.
πΊ One very good video to begin with python-binance package [TUTO FR] CrΓ©er son PROPRE BOT DE TRADING CRYPTO facilement en Python ! and the associated github repo create personnal trading bot.
π DogeAccountPy : python-binance.
π Documentation : CoinMarketCap API Documentation
πΊ Youtube channels can help you to onboard with CoinMarketCap API.
π Looking for optimization Le Design Pattern Contre-Intuitif le plus utilisΓ© par les DΓ©veloppeurs Professionnels.--
To onboard with this package you definitely should see this video πΊ How to use the Twitter API v2 in Python using Tweepy. All my Tweepy code is based on this video !
The automation is made with cron - npm.
It's an automation tool in command line that you can install easily with :
npm install cron
.
After you install it you can check some use on crontab.guru.
I provide a crontab
file without extension which can be open by every text editor. It's a basic syntax but this file provide a solution when your shell doesn't find the good python compiler.
This automation actually runs on AWS EC2 Instance with a free account but I think it will be removed soon because I don't want to pay!
Still in french you can find a good detail about how to deploy an AWS free instance [Tuto FR] HΓ©berger votre BOT DE TRADING crypto GRATUITEMENT en Python sur un serveur avec FTX.
π config.py : which stores every twitter access keys.
π prices.py : which ask prices at CoinMarketCap and provide some functions to simplify messaging and accessing data. There is also a function metsLesVirgules
which makes the same thing as "{:=,}".format(value)
but I didn't know so I hardcoded this function and I let here.
π messages.py : uses every functions in prices to provide 3 messages.
π tweets.py : the last one obviously... to TWEET PRICES π€
π crontab : the file where the command is stored to automate post.
This uses python-binance package, and contains only two files :
π Twitter.py : it's my first file and contains Binance prices call, messages and tweeting via tweepy.
π config.py : still a config file to run all of this.
π listings_cmc.py : make the call to get latest CMC listings.
π metadata_listings.py : provide metadata related to latest listings taking from listings_cmc.py
.
π tweets_wrapper.py : a simple file which contains one function : tweets_wrapper
.
I think problems raised from tweets_wrapper or tweets. If someone is available to chat about this it will be a pleasure π
π tweets.py : obviously posting file, but also some textual operations to improve each threads.