lassebenni / shortbet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shortbet

Shortbets creates a simple overview of the earnings dates for heavily shorted stock tickers. This is not investment advice.

Latest results in Flat Data

Process Tickers (generated by ChatGPT)

This project aims to extract information about shortable tickers from the internet, specifically from the yfinance library, and store them in a JSON file. The information that is extracted includes the name of the ticker, the short float, the price of the ticker, the earnings date and more. Code Overview

The code for this project consists of two main classes: ProcessTickers and ShortTicker. ProcessTickers

The ProcessTickers class has several methods that are responsible for extracting information about the tickers, storing them in a list of ShortTicker objects, and then writing that list to a JSON file. The run() method initiates the processing of symbols from a file "symbols.txt" and collects information about the symbols into a list of ShortTicker objects. The _store_first_symbol() method stores the first symbol from the symbol file into the list of ShortTicker objects.

The _store_ticker() method takes a symbol as an argument and creates a ShortTicker object with the symbol and then appends that object to the list of ShortTicker objects. The _read_symbols() method reads the symbols from the symbol file and returns them as a generator. The _read_tickers() method reads the previously stored tickers from a JSON file. The _overwrite_tickers_file() method writes the list of ShortTicker objects to a JSON file. ShortTicker

The ShortTicker class has several fields that store information about the ticker such as earnings_date, name, short_float, price, symbol, datetime, url. The init() method takes a symbol as an argument and uses it to extract information about the ticker from the yfinance library. The as_dict() method returns the fields of the ShortTicker object as a dictionary. How to use the code

In order to use the code, you will need to install the yfinance library and the dataclasses-csv library. You can do this by running the following command:

pip install yfinance dataclasses-csv

You will also need to create a file named "symbols.txt" in the same directory as the code and add symbols of the tickers you want to extract information about, one per line.

Once you have the necessary dependencies and the symbols file, you can run the following command in the terminal to execute the code:

python process_tickers.py

This will extract information about the tickers from the symbols file, store them in a list of ShortTicker objects and write the list to a JSON file named "latest.json".

You can also pass the argument "full_run=True" in the run method to process all symbols from the file instead of only the first one.

pts.run(full_run=True)

The code will print the duration of the processing and the output file will be overwritten with the new data each time the code is run.

About


Languages

Language:Python 97.3%Language:Makefile 2.7%