https://github.com/smpotts/day-trades-analysis
Examines trade data and finds the day trades that occurred within a given time period in a Jupyter Notebook hosted on a Docker container.
https://github.com/smpotts/day-trades-analysis
docker-compose financial-analysis jupyter-notebook postgresql trading-data
Last synced: about 1 year ago
JSON representation
Examines trade data and finds the day trades that occurred within a given time period in a Jupyter Notebook hosted on a Docker container.
- Host: GitHub
- URL: https://github.com/smpotts/day-trades-analysis
- Owner: smpotts
- Created: 2024-02-17T15:31:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-27T02:03:44.000Z (over 2 years ago)
- Last Synced: 2025-04-01T20:51:26.812Z (about 1 year ago)
- Topics: docker-compose, financial-analysis, jupyter-notebook, postgresql, trading-data
- Language: Jupyter Notebook
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Day Trades Notebook
## Overview
This project analyzes day trading data in a Jupyter Notebook hosted on a Docker container. It imports a file with trade data called `trades.csv`, where the input data are in this format:
| account_id | symbol | side | qty | timestamp |
| ---- | ---- | ---- | ---- | ---- |
| 77658 | GOOG | sell | 493 | 2023-09-04 09:30:00 |
| 19191 | NVDA | sell | 216 | 2023-09-04 09:30:03 |
These source data are loaded into a table called `public.trades` on Postgres instance hosted on a Docker container when the container starts up. The Docker configuration also starts a Jupyter notebook, which queries the `public.trades` table name puts the source data into a DataFrame.
The Jupyter notebook analyzes the trading data and looks for the number of day-trades the occurred per account within a given time period. The program outputs a file with day trades in the `/work` directory.
## How to run
### Starting Docker
The program runs on Docker and can be started with a `docker compose up -d --build` command.
There are two containers: one for the Postgresql instance and another for Jupyter Notebooks, verify they are running with a `docker ps` command.
### Starting Jupyter Notebooks
Once both containers are up, and they are healthy, open a browser and go to 'http://localhost:8888/'. This will launch the Jupyter notebook which contains the trading analysis.
Navigate inside the `work/` directory and open the `trades_notebook.ipynb` file. Run each block of code within the notebook. The final statement contains a method call where you can input a `start_time` and an `end_time` for the date range to analyze day trades by account. Running the final code block will run the `find_day_trades()` and the `write_output_file()` method will create a `.csv` file with the count of day trades per account over the given time window.