Skip to content

Grabs 1 min stock bars and real time trades from alpaca

License

Notifications You must be signed in to change notification settings

thedavidhanks/market-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project gets 1 min bars and real-time data from alpaca and writes them to a database.

Installation

  1. Start the container. This project utilizes Dev Containers extension for Visual Studio Code. If you're running VS code start up is as follows.
  • Start Docker Desktop
  • In VS Code, install Dev Containers extension
  • Open this project in VS code
  • F1 Dev Containers: Rebuild Container If you're not running VS code, this project runs Python 3.12. Python module versions are in requirements.txt
  1. Create a postgreSQL server

  2. Install the TimescaleDB extension

  3. Create the tables, views, and refresh policy

    • Create the database and enable the timescaledb extension
    CREATE DATABASE mlmarketdata;
    \c mlmarketdata
    CREATE EXTENSION IF NOT EXISTS timescaledb;
    
    • in psql run the following files:
      • \i ./data/db_create.sql
      • \i ./data/db_create2.sql
      • \i ./data/db_create3.sql
  4. Add a .env file to the root directory with the following constants:

MS_ALPACA_API_KEY = "Your API"
MS_ALPACA_API_SECRET = "YOUR_API_SECRET"
MS_DB_PWD = "DATABASE_PASSWORD"
MS_DB_URL="DATABASE URL"
MS_DB_PORT=5432
MS_DB_USER="DATABASE USER"
MS_DB_NAME="DATABASE NAME"

Run

Run the program using the following command:

$ python main.py

Help info

To view other arguments a --help argument is available.

$ python main.py --help

usage: main.py [-h] [-v VERBOSITY] [--log-verbosity LOG_VERBOSITY]

Capture the market data in a database.

options:
  -h, --help            show this help message and exit
  -v VERBOSITY, --verbosity VERBOSITY
                        Set console output verbosity level. 0 None, 1 Errors, 2 Info, 3 Debug
  --log-verbosity LOG_VERBOSITY
                        Set log file verbosity level. Options are "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL". Default is "INFO".

License

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

About

Grabs 1 min stock bars and real time trades from alpaca

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published