luisgc93 / stock_reminder_bot Goto Github PK
View Code? Open in Web Editor NEWA twitter bot that reminds you of stock and crypto predictions
Home Page: https://twitter.com/stock_reminder
License: MIT License
A twitter bot that reminds you of stock and crypto predictions
Home Page: https://twitter.com/stock_reminder
License: MIT License
When a threaded mention is an extended tweet, reminders are typically not created since the text is truncated. See example:
https://twitter.com/stock_reminder/status/1378655603808202752?s=20
These tweets can be handled with tweepy with the tweet_mode="extended"
property:
https://docs.tweepy.org/en/latest/extended_tweets.html#examples
Let's try this out to speed up our CI:
When creating reminders, it is assumed that the user buys the stock. It would be nice if users could short the stock as well. E.g. "@stock_reminder short $BTC, remind me in 2 weeks".
The update_with_media
endpoint has long been deprecated:
http://docs.tweepy.org/en/latest/api.html?highlight=media#API.media_upload
Use this one instead:
http://docs.tweepy.org/en/latest/api.html?highlight=media#API.media_upload
We currently calculate a "naive" returns % that doesn't include the US dollar's depreciation.
Ideally, the calculate_returns
method should take this into account.
When a mention contains multiple stocks and one of them is not found (e.g. due to a typo or the stock not trading in the NASDAQ), the bot should reply saying that it will remind the user of those stocks that have been found but that one (or more ) of them couldn't be found.
Instead, what happens currently is that the bot responds with the stock not found reply:
This is despite succesfully creating reminders for the other stocks ($BABA and $BTC in the above example. $TCENY is a typo and should be $TCEHY instead, hence why the stock wasn't found).
Depencies should be pinned for stable release versions.
For some reason only print statements show up in the heroku container logs. Fix this and add relevant logs.
Travis CI pipeline currently just runs pytest outside of docker. The make test
command should be updated as well as the .travis.yml
file.
https://docs.travis-ci.com/user/docker/
Similar to the report feature but you use PE and other metrics to assess which company is better on paper. E.g. @stock_reminder compare $AAPL and $MSFT. The response could include a similar report image with PER and EPS ratios and a buying recommendation.
An event-based architecture where redis notifies the bot about new mentions might be better than having the bot query the database every 2 minutes.
E.g. create reminders for stocks reaching new all time highs or a specific price. Example response "@user knock knock. It's your favourite twitter bot. Just wanted to let you know that
The basic features of #7 are covered but the appearance of the report details needs some work.
The current implementation for generating the image and adding the test uses the Pillow library, which is not designed specifically for generating images based on a table.
An alternative approach would be to save the report data into a pandas data frame which would then be converted into a table and saved as a .png file. I had to revert my attempt of this since the dfi.export
method caused an OSError error: Chrome executable not able to be found on your machine
The approach would be something like this:
https://stackoverflow.com/questions/35634238/how-to-save-a-pandas-dataframe-table-as-a-png
I was able to create this locally but it raised an OSError when deployed:
When a user mentions the bot with "@stock_reminder show me my track record" or something among those lines, the bot replies with a list of stocks and investment results that the user created reminders for. E.g.: "$JNJ 4.3%, $BABA -3.2% etc."
As mentioned in the project's reddit thread the bot doesn't support stock splits.
If a user generates a reminder for a stock that undergoes a split before the reminder date, the results will show a large decrease in stock price, when this might not be the case.
To fix this, the OVERVIEW alpha vantage endpoint could be used to check the LastSplitDate
and MarketCapitalization
fields:
It's be nice to use type hints in all modules inside src.
When a user mentions the bot:
"@stock_reminder report on $X"
The bot replies with a generated report on company $X.
This would involve the overview alpha vantage api endpoint:
https://www.alphavantage.co/documentation/#company-overview
The bot could also perform some fundamental analysis of the metrics provided by the AV endpoint:
https://www.benzinga.com/money/fundamental-analysis/
It seems like Alpha vantage no longer sends this information, which triggers a key error in get_split_factor
:
KeyError
'LastSplitDate'
It's be nice if the bot could respond with different GIFs depending on the investment outcomes.
Adding more images other than the Mr. Burns and Scrooge McDuck ones would also be a good enhancement.
If a reminder is created when the stock market is not open, instead of using the intraday AV endpoint, we should use the quote endpoint.
This would be a very rare corner case but if a stock undergoes several splits between the time a reminder is created and the remind_on date, then the price adjustment would only count the latest split since the bot uses the overview endpoint:
All the cool kids are using it.
https://dev.to/frostming/a-review-pipenv-vs-poetry-vs-pdm-39b4
It's a DSN not a URL
This will avoid sending unnecessary files to docker:
https://docs.docker.com/engine/reference/builder/#dockerignore-file
Add dependabot for dependency management
Having async calls should make the code more efficient
Use of urllib.request.urlretrieve
should be mocked in tests that involve gif generation
Just how the test suite was split into several modules, the same should probably be done for bot.py since the code is getting a bit spaghetti.
Some ideas of how it could be broken down:
reply_mentions.py
, publish_reminders.py
, generate_report.py
This would involve 3 things:
is_finished
(boolean, default False) attribute to the Reminder
model to avoid duplicate repliesremind_on
from date field to datetime field (add new column remind_on_new
, then add the values by using remind_on
date plus plus 12:00 UTC, then drop remind_on
and rename remind_on_new
to remind_on
)publish_reminders
every 2 minutes like we do with reply_to_mentions
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.