Giter VIP home page Giter VIP logo

b2-stock-trader's Introduction

B2 Stock Trader: Alternative Data Trading using Python, Google Trends, NYT Articles, and Cohere

Description

Read our Medium article here: https://ryansh3n.medium.com/b2-stock-trader-425b5c5f409a

The B2 stock trader is an application that uses Google Trends and Cohere sentiment analysis on NYT articles to pick a portfolio of stocks. It uses an algorithmic strategy of finding undervalued (low Google interest) but highly-rated (high NYT sentiment scores) stocks that others neglect looking at, because most people focus on popular but likely overvalued stocks. We were inspired by B2EMO, a groundmech salvage assist droid in Star Wars: Andor that looked through junkyards for valuable scrap. Similarly, we scrape the internet to find undervalued stocks.

We built this project to learn about sourcing and processing data ourselves for the purpose of alternative data trading, improve our abilities to work with libraries and APIs, and practice using Git and debugging projects; we succeeded at reaching that goal. The goal was not necessarily to create a safe portfolio that maximizes profit which would be useful in the real world. However, B2 was still highly successful in choosing profitable portfolios.

image
The B2 portfolios beat the S&P 500 by a huge 1212% and 817%, respectively, between Jan 1, 2008 and Dec 31, 2022.

How to Install and Run

Download the project as a .zip file and extract it onto your computer. Run the main method. You will need to install pytrends, pynytimes, pandas, cohere, configparser, and yfinance using a package installer such as pip. Create your own config.ini file in the NYTScraper folder with your own free API keys for pynytimes and Cohere.

How to Use

Run main.py in the main folder, passing in the year you want to analyze in generateTickersByYear(), and making sure all the functions are uncommented. Wait for API calls to finish, and the .json and .txt files in the TempFiles folder should update with the chosen portfolio and results. It is set to parse the last month of the year's Google Trends data, and the full year's NYT articles. You can change these timeframes yourself in the respective files, at the cost of runtime and potentially reaching the API call limits.

image

Credits

This project was co-created by Ryan Shen and Alex Zhu, with research and use of:

b2-stock-trader's People

Contributors

probablyalexzhu avatar ryansh3n avatar

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.