Skip to content

ivanob/fear-greed-twitter-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

List of goals to learn

  • Terraform: create a couple of lambdas and a SQS queue in between them, also a DynamoDB table to store some data.
  • Twitter API: basic usage of the API
  • Typescript must be set in the most strict level in .tsconfig
  • Compile TS project and bundle it to deploy as JS lambda [1]
  • Find a good graphical diagram tool
  • monorepo management tool: lerna

Before deploying

You need to create a file called terraform.tfvars in the /infra folder with the credentials to access your twitter app:

twitter_appKey="asDhdjs..."
twitter_appSecret="S9dncq9d..."
twitter_accessToken="231231..."
twitter_accessSecret="nifjCVU..."

Then you can build the 2 lambdas using npm run build in each folder and it would be ready to deploy. To deploy go to the /infra folder and execute terraform init, terraform plan and terraform apply

Description

The idea is to tweet periodically some information about the Fear&Greed index [1]. To do this a lambda will check every X hours the external resource, scrap the status about this index and send it to a SQS queue and also store it into a DynamoDB table. A second lambda will be in charge of dealing with the twitter API. As soon as any message arrives to the SQS queue it will pusblish it in a new tweet.

[1] https://edition.cnn.com/markets/fear-and-greed

[1] After trying different solutions for sending the TS project to lambda once its transpiled into JS I came into the conclusion that the best tool is esBundle.js (https://esbuild.github.io/) I tried webpack but it is a much complex configuration and the uglification of the code changes the structure of the code too much, so lambda can not find the name of the lambda. I didnt want to use SLS or AWS SAM for this cause I want to do it all from terraform. Also esBundle transpiles all TS into one single JS that I did not uglified, so its readable. A much more efficient way of bundling would be the following, but code is less readable and for debugging purposes I wanted to keep it easy. "build": "esbuild index.ts --bundle --minify --sourcemap --platform=node --target=es2020 --outfile=dist/index.js",

About Fear and Greed index

What is the CNN Business Fear & Greed Index?

The Fear & Greed Index is a way to gauge stock market movements and whether stocks are fairly priced. The theory is based on the logic that excessive fear tends to drive down share prices, and too much greed tends to have the opposite effect.

How is Fear & Greed Calculated?

The Fear & Greed Index is a compilation of seven different indicators that measure some aspect of stock market behavior. They are market momentum, stock price strength, stock price breadth, put and call options, junk bond demand, market volatility, and safe haven demand. The index tracks how much these individual indicators deviate from their averages compared to how much they normally diverge. The index gives each indicator equal weighting in calculating a score from 0 to 100, with 100 representing maximum greediness and 0 signaling maximum fear.

How often is the Fear & Greed Index calculated?

Every component and the Index are calculated as soon as new data becomes available.

How to use Fear & Greed Index?

The Fear & Greed Index is used to gauge the mood of the market. Many investors are emotional and reactionary, and fear and greed sentiment indicators can alert investors to their own emotions and biases that can influence their decisions. When combined with fundamentals and other analytical tools, the Index can be a helpful way to assess market sentiment.

Lerna management orders

npx nx graph // To visualize the project structure npx lerna run build // To build the whole project (from root) npx lerna run test // To test the project (each package)

Bibliography:

About

Bot written in Typescript and deployed in AWS to publish periodically the Fear&Greed index

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors