Giter VIP home page Giter VIP logo

stephanakkerman / fintwit-bot Goto Github PK

View Code? Open in Web Editor NEW
59.0 4.0 11.0 6.93 MB

FinTwit-Bot is a Discord bot designed to track and analyze financial markets by pulling data from platforms like Twitter, Reddit, and Binance. It features customizable tools for sentiment analysis, market trends, and portfolio tracking to help traders stay informed and make data-driven decisions.

Home Page: http://akkerman.ai/fintwit-bot/

License: MIT License

Python 100.00%
discord-bot twitter twitter-sentiment-analysis cryptocurrency forex stocks binance ccxt crypto cryptocurrency-prices

fintwit-bot's Introduction

FinTwit-Bot: Comprehensive Financial Markets Overview via Discord

FinTwit-Bot Banner


Supported versions License Code style: black

This is a Discord bot written in Python, this bot aims to provide an overview of the financial markets discussed on X / Twitter. Not only data from Twitter is gathered, but other sources are used too, such as Reddit, Binance, Yahoo-Finance, TradingView, and many other related websites. This bot was written with flexibility in mind, meaning that you can toggle on and off certain features without issues by using the config.yaml file.

Key Features ⚙️

  • Automatic Sentiment Analysis: Analyze the sentiment of tweets to gauge market mood.
  • Market Analytics: Generate analytics for tickers mentioned in tweets and provide an overview of market trends.
  • Image Recognition: Identify and analyze charts in tweets for visual insights.
  • Ticker Trends: Track the most mentioned tickers to spot market interests.
  • Market Movers: Get updates on trending topics, gainers, and losers in crypto and stocks.
  • TradingView Insights: Display the top 10 TradingView ideas for various markets.
  • Market Events: Monitor listings, delistings, and other significant events in the crypto world.
  • Stock Halts: Keep track of the latest halted stocks on Nasdaq.
  • Portfolio Tracking: Enable users to follow their crypto and stock investments.
  • Live Trading Updates: View live trades from users who share their portfolios.
  • Hourly Market Updates: Receive regular updates on indices across crypto, stocks, and forex.

For a detailed guide on all commands and functionalities, refer to the documentation included in the repo.

Machine Learning Models 🤖

Currently, we use two machine learning models to help get better insights from the data collected by the bot. The following models are trained and developed by us with the purpose of being integrated with this Discord bot:

Both models are very lightweight and are automatically downloaded and setup if you run main.py.

Tweet Example

In the image above you can see what the bot does with the data it receives from Twitter. The green color of the embed shows that the sentiment of this tweet is positive. The tickers mentioned in the tweet and the quoted tweet are shown below, both with the exchanges they are available on and the 4-hour and 1-day technical analysis (TA) from TradingView.

Installation 🛠

# Clone this repository
git clone https://github.com/StephanAkkerman/fintwit-bot
# Install required packages
pip install -r requirements.txt

Twitter Credentials 🐦

To access data from Twitter you need to follow these steps:

  • To be able to get data from Twitter you need to have an account first (and follow some other users with it).
  • After signing in go to your Twitter Home page, here you can select either For You or Following. I suggest selecting Following as it makes it easier to manage the Tweets the bot will pull.
  • Open DevTools (F12) and go to the Network tab.
  • Locate HomeLatestTimeline, right click on it and press Copy as cURL (bash).
  • Create a new file in the root folder of this project named curl.txt and paste the contents there.

Setup .env 📝

If you open example.env you will find the lines that need to be filled in. Start by renaming example.env to .env so the bot will use this file for you credentials.

Creating a Discord bot

For the first part, you can watch this video (watch until 2:20).

Or follow these written instructions:

  • Setup your own Discord bot, following this written tutorial or this
  • Give the bot admin rights and all permissions possible, since this is the easiest way to set it up.
  • Invite the bot to your server.

At last fill in the lines in the example.env file:

  • Write your bot token behind DISCORD_TOKEN: (line 2)
  • Write your server name behind DISCORD_GUILD: (line 3)
Adding custom emojis (Optional)

The bot uses custom emojis to recognize on which cryptocurrency exchange things can be bought. If you wish to use it, follow these steps:

  • Locate the custom emoji pictures here.
  • Add them to your server (instructions).
  • You can add any exchange emoji, for instance, FTX, as long as the image is supported by Discord and the name is the same as the exchange.

Reddit API Credentials (Optional) 👽

If you do not want to track data from Reddit, feel free to skip this step. I suggest creating a new account for this too, if you feel uncomfortable leaving your username and password.

  • Go to https://old.reddit.com/prefs/apps/ and select script.
  • The name of the app is needed for REDDIT_APP_NAME, click on make app.
  • This will give you the REDDIT_PERSONAL_USE and REDDIT_SECRET tokens.
  • Finally, fill in your Reddit username and password for REDDIT_USERNAME and REDDIT_PASSWORD.

Discord Category and Channel Creation

Since there are multiple channels that are about the same topic, we need to put them in different categories so the bot knows where to find this channel. The categories are specified in the config file, feel free to change the names. Below you can find an example showing how we set up our Discord channel.

Example of Discord Categories and Channels

━━ 🔑 Information ━━

This is an optional category, where the github channel tracks the commits of this repo using the GitHub webhook for Discord.

  • 🌐┃general
  • 💻┃github
  • ⌨┃commands
━━━ 🐦Twitter ━━━
  • 📰┃news
  • 📷┃images
  • ❓┃other
  • 💸┃highlights
━━━ 🎰 Crypto ━━━
  • 📈┃charts
  • 💬┃text
  • 📊┃index
  • 💡┃ideas
  • 🔥┃trending
  • 🚀┃gainers
  • 💩┃losers
  • 🏦┃funding
  • 🆕┃listings
  • 📰┃news
  • 💸┃liquidations
  • 🏆┃overview
━━━ 🐒 NFTs ━━━
  • 🏆┃top
  • 🔥┃trending
  • 🌠┃upcoming
  • 🎮┃p2e
━━━ 💵 Stocks ━━━
  • 📈┃charts
  • 💬┃text
  • 📊┃index
  • 💡┃ideas
  • 🔥┃trending
  • 🚀┃gainers
  • 💩┃losers
  • 📅┃earnings
  • 🎤┃stocktwits
  • 🏆┃overview
━━━🎯 Options ━━━
  • 🏆┃overview
  • 💣┃volume
  • 💰┃spacs
  • 📉┃shorts
━━━ 💱 Forex ━━━
  • 📈┃charts
  • 💬┃text
  • 📊┃index
  • 📣┃events
  • 🏢┃yield
━━━ 👨 Users ━━━
  • 💲┃trades
━━━ 👽 Reddit ━━━
  • 🤑┃wallstreetbets
━━ Selected Traders ━━

These channels are also optional, but these are some of my favorite traders on Twitter.

  • 🐺┃hsakatrades
  • 🦁┃anbessa100
  • 🔫┃cryptobullet1

Contributing

Contributions are welcome! If you have a feature request, bug report, or proposal for code refactoring, please feel free to open an issue on GitHub. We appreciate your help in improving this project.
https://github.com/StephanAkkerman/FinTwit_Bot/graphs/contributors

License

This project is licensed under the MIT License. See the [LICENSE] file for details.

fintwit-bot's People

Contributors

dependabot[bot] avatar imgbotapp avatar mergify[bot] avatar snyk-bot avatar stephanakkerman avatar timkoornstra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fintwit-bot's Issues

Keep track of user's crypto portfolio

!portfolio <exchange> <key> <secret>
Doing this command will add a new row to the database, the exchange options are KuCoin and Binance.
After this has happened we open a user socket so we can keep track of the user's buys and sells.
We also make calls every hour to check the prices of the assets on their account (if there are any)

  • Make a command for adding exchange information
  • Format the exchange (always lower) and check if we support this exchange, if not don't add to db
  • Save this information to a database (pandas dataframe, which will be pickled everytime something changes)
  • Get the account balance if !portfolio has been used and save the (user, symbol, quantity, price) in db
  • Start user socket (and publish new trades in dedicated channel)
  • Check assets on account and make a new channel dedicated to this user (for showing their current assets)
  • Send the user a message if their SL or TP has been hit

Fix timestamp

Currently 1 hour less compared to discord timestamp

Prettify Embeds

  • add tweet timestamp
  • add more fields to embed
  • add footer
  • add header with bot avatar

[Side project] Use image recognition to decide if a image is a chart or not

This is a project on its own, but could be implemented here to remove useless images from the chart channels

  • Create a dataset of all images and charts that get posted (use scraping script)
  • Try fitting unsupervised clustering on it
  • Try labeling part of the data and applying pre-trained model (maybe fine-tuned)

  • Add pretrained model
  • Implement logic

Possible models

We need to consider efficiency, since it should be able to run on the raspberry pi and finetuning should be possible on a home PC.

Post count of mentioned tickers in the last 24h

If a tweet contains a ticker add the ticker, user, sentiment, category, time of tweet to the database.
For every new tweet send a message containing the list of the tickers mentioned in the last 24h and delete the tickers older than 24h.

Also every x hours compare the top 10 (or more depending on rate limit) tickers with twitter's global sentiment.

First ensure that:

  • #185 is working correctly to save time on deciding the ticker category

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.