r/learnpython • u/djrdog578 • Jan 04 '21
I made a Python script that tracks Elon Musk's tweets and if he tweets about Doge coin it buys $20 of $DOGE on Robinhood
It uses the Twitter API and an unofficial Robinhood API. Feel free to critique it if you see anything that could be improved! Github
11
2
u/I3lack_Mage Jan 11 '21
I am a Python noob and I have a question. I read your code, but I'm not sure I understand what the "trigger" of it is. I mean, what's starting the whole listener part? It seems to me like it's all just setting variables. What am I missing?
1
u/djrdog578 Jan 11 '21
Yea it would be hard to tell from just the code, but Tweepy streams tweets constantly so it's starts "listening" when the program is run.
62
u/anh86 Jan 05 '21
Elon: EVERYONE SELL DOGE NOW!
<Doge plummets>
Bot: I’ve purchased more for you, sir!
20
61
u/deebz41 Jan 05 '21
r/wallstreetbets wants to know your location
11
u/glueQMJ Jan 05 '21
Even the guys at r/wallstreetbets won't accept this kind of craziness.
7
u/provoko Jan 05 '21
Neither does r/stocks, but I'm still so proud of OP right now
Great job u/djrdog578
3
5
41
u/Crowsby Jan 05 '21
Hello my name is Elon Musk and I'm excited to share my 34-tweet series about the chief magistrate and leader of the Republic of Venice between 726 and 1797.
6
14
Jan 05 '21
doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge doge
14
u/Yakhov Jan 05 '21
Musk could destroy you.
21
u/whohasthetardis Jan 05 '21
Yea, but he's definitely not a redditor, and definitely not the sort of person to troll some random person, right? /s
19
u/Yakhov Jan 05 '21
and he's totally not the kinda global elitist that would think it's fun to wipe out this poor guys bank account for shits and gigs. /s
1
5
Jan 05 '21
u/djrdog578 I'm new to Python and would like to make a bot like this in the next few months, do you need to rent a server to keep it running?
7
Jan 05 '21
[removed] — view removed comment
3
u/porkedpie1 Jan 05 '21
Or you could play with AWS. It would be very cheap to run this as via Lambda
2
Jan 05 '21
[removed] — view removed comment
2
u/porkedpie1 Jan 05 '21
essentially, yes. So no server overhead.
2
u/JunkyByte Jan 05 '21
In that regard you can also have a free instance on gcp running 24/7, look for gcp unlimited free trial.
4
u/grammarGuy69 Jan 05 '21
Robinhood has an API? interesting... If I had any money I might toy around with that.
3
Jan 05 '21
That only takes 50 lines?
5
Jan 05 '21
Welcome to python. I'm sure there are some people who could make it happen in half that.
1
Jan 05 '21
I wanted to build something exactly like this but though it was way beyond my capability. I guess basic trading scripts aren’t that bad?
2
u/vortex-street Jan 05 '21
I was actually thinking of this exact idea a couple days ago when doge spiked! Nice work
2
2
u/hisfastness Jan 05 '21
I love it! Nice job.
I think if I were to use something like this, I'd connect it to Twilio + Whatsapp and want to have more control over whether or not to actually purchase...it could message you when he tweets, with the full message, and then you just respond with 'Yes' or 'No' to buy Doge or not.
1
1
u/LadfromYYC12 Jan 05 '21
Can you create a bot for tracking the PS5 stock lol
6
u/anh86 Jan 05 '21
I made one that scrapes the PS5 page at nowinstock.net and sends me an email if they show it in stock at any retailers
4
u/DirtyMudder92 Jan 05 '21
I made one that scraped the ps store and alerted me when it went in stock and that's how I got mine!
4
u/bbqbot Jan 05 '21
Can you share your code with me please? I have zero interest in ps5 (pc gamer masterrace) but would love to see the scraping magic.
2
u/anh86 Jan 06 '21
It's on my Github here.
Plenty of avenues for improvement, I'm sure such as automatically firing up a tab to purchase the system or even completing the buy process automatically. At present, it's designed to check once every 60 seconds and send an email to an input user if it gets a hit. I also designed it to stop once it sends a single email because it was done for fun rather than to actually get me a PS5 (which I already have). I didn't want to potentially spam myself hundreds of times if it got a real hit or if there was some bug I hadn't anticipated while AFK.
-1
u/LeeCig Jan 05 '21
More likely you're interested in scalping them
3
u/bbqbot Jan 06 '21
Or I just like to see functional examples. I have zero interest in making a few extra bucks off desperate shoppers.
1
1
u/Murflaw7424 Jan 05 '21
How often does this refresh?
Is this a set it and forget it code as long as the computer is on?
1
1
u/Laurence-Lin Jan 05 '21
I'm recently interested in using programming to decide small scale financial trade for me. Thank you for sharing!
1
1
1
u/micqdf Jan 05 '21
so a few improvment sudgestions
Stop losses, just write a simple script that would pull out the trade if it goes in the other direction by something like 2%
Take profits, you want it to be a short scalp, looking at the jumps in the last few years, 50% might actually work.
1
u/wizon88 Jan 05 '21
that makes you the product then if you buy it because he advertises it
youre supposed to buy when its low and sell once he tweets about it
1
u/micqdf Jan 05 '21
this kinda bot would be preforming whats know as a scalp trade, you would still be buying low and selling high
1
u/marzbuzz Jan 05 '21
there's a ton of negative chatter, but I think you're on your way to developing an incredible investment tool friend!
1
1
1
u/cincopea Jan 05 '21
yikes unofficial robinhood api. I almost never read the source code, what if it steals your SSN, banking info, or just straight up messes up and over leverage you. scary
1
1
1
u/Ludwig_The_3rd Jan 29 '21
I spent $1200 on Doge coin and I'm up $600 in 2 days! Should I buy more? Tell everyone! Let's push for that dollar kings!!!
1
Jan 30 '21
LETS GO DOGE 🚀🚀🚀🚀 if yous need help finding a place to buy dogecoin I use CoinSpot. You get $100 of Bitcoin when you sign up using code REFBP7X89 :) enjoy
1
u/Disastrous_Drink5361 Feb 01 '21
New Crypto Pump Telegram Channel https://t.me/PumpandDump101 feel free to share!!
1
u/AceJohnson_ Feb 04 '21
How can I get this same code off Robinhood and on Schwab or other big name brokers?
1
u/RealAmerik Feb 10 '21
Hey there, I debated making something similar but did a quick google search and saw your repo. Can I ask where you're hosting this to run?
This is awesome - thanks!
1
1
1
u/ravius22 Apr 28 '21
Can you make it so when it buys it adds a trailing stop of say like 1% automatically so If your away from your computer when it buys, it Will exit for you, but you get a lot of the upside potential?
1
1
-1
0
Jan 04 '21
[deleted]
41
u/djrdog578 Jan 05 '21
Yea I guess I didn’t account for negative news 😳
28
Jan 05 '21
NLP sub module?
11
3
u/Kayofox Jan 05 '21
Google has free API that can analyze if something is said in bad or good direction. Amazon probably has it too. It's gaped by number of uses ( per month I think), but he probably won't tweet thousands of those in one month
2
19
u/chmod--777 Jan 05 '21
IIRC there's a stupid easy pypi package called textblob that gives you the sentiment of a blob of text in like two lines of code
0
7
u/kkruel56 Jan 05 '21
Should use some NLP to gauge the sentiment of the tweets and predict based on that
3
u/-Cachi- Jan 05 '21
Dogecoin is the coolest cryptocurrency, there's no way Elon is gonna say anything bad about it.
2
u/LeeCig Jan 05 '21
Just build a sentiment interpreter. Never mind, just saw the comment under mine.
2
u/OneGrumpyFuck Jan 05 '21
You could always use grammarly's text analysis as a method of context analysis too. They have highlighting features that tell you the context, though I don't know if it's too refined for the topic in question, you could refine your code to your needs based off of an analysis of theirs.
3
0
Jan 04 '21
[deleted]
75
u/Se7enLC Jan 04 '21
Child sex trafficking ring discovered via Doge coin transactions
86
24
u/zhaoz Jan 05 '21
This is good for doge coin!
7
7
2
u/pompomtom Jan 05 '21
This can be tested: is time-to-market more important than sentiment-analysis? (also does sentiment even matter?)
2
u/Sup3rT4891 Jan 05 '21
“See Doge helps cleanse out the bad actors. We have had enough of Goldman Sachs laundering money on behalf of these pedos”
4
1
u/sebyelcapo Jan 05 '21
So you are telling me that there is a money so secure and stable that billonares used it to that kind of illegal activity. I should buy some
18
2
Jan 05 '21 edited Feb 18 '25
[removed] — view removed comment
6
u/nemean_lion Jan 05 '21
Depends on how the account is setup. If it’s on margin then yeah could be an issue. But remember, stonks only go up so you’re good. Maybe. Idk. YMMV
90
u/lumpynose Jan 04 '21
Maybe follow this porn star as well:
https://finance.yahoo.com/news/dogecoin-sees-125-increase-trading-195309825.html
https://www.coindesk.com/doges-gone-wild-meme-coin-soars-after-adult-star-says-shes-a-hodler
I bet you never knew that porn stars are financial wizards.