Skip to main content

Add your description here

Project description

๐Ÿ“ฆ Enode Quant SDK

Author: Oscar Thiele Serrano

Context: ESADE ENODE Association โ€“ Quant Finance Team (student quant fund)

A lightweight, beginner-friendly Python SDK for accessing Enode's internal market data (stocks, options, and candles) stored in our AWS RDS PostgreSQL database.

This library is for our team: it standardises how we fetch data for research, prototyping, and strategy development.


๐Ÿงญ Overview

The Enode Quant SDK lets researchers work with market data using simple Python functions instead of SQL.

Example:

from enode_quant import get_stock_quotes, get_option_contracts

get_stock_quotes("AAPL")
get_option_contracts("AAPL", option_type="call")
get_stock_candles("AAPL")

The SDK provides:

  • High-level Python functions for stocks, options, and candles
  • A built-in CLI for authentication (enode login)
  • Secure local credential storage
  • SQL query builders (users never write SQL)
  • Optional pandas DataFrame output
  • Clean error handling and a simple API surface

Designed to be usable by both beginners and more advanced quants in the ENODE team.


๐ŸŒณ Project Structure

enode_quant/
โ”œโ”€โ”€ __init__.py            # Public shortcuts (lazy imports)
โ”‚
โ”œโ”€โ”€ api/                   # High-level data access (researcher-facing)
โ”‚   โ”œโ”€โ”€ candles.py         # Stock OHLCV / candles helper functions
โ”‚   โ”œโ”€โ”€ options.py         # Option contracts & option quotes
โ”‚   โ””โ”€โ”€ stocks.py          # Stocks, L1 quotes, stock metadata
โ”‚
โ”œโ”€โ”€ cli/                   # Authentication CLI (`enode login`, `whoami`)
โ”‚   โ”œโ”€โ”€ login.py
โ”‚   โ”œโ”€โ”€ logout.py
โ”‚   โ”œโ”€โ”€ main.py            # Defines the `enode` CLI entrypoint
โ”‚   โ””โ”€โ”€ whoami.py
โ”‚
โ”œโ”€โ”€ client.py              # Core HTTP client โ†’ API Gateway โ†’ Lambda โ†’ RDS
โ”œโ”€โ”€ config.py              # Loads/stores ~/.enode/credentials
โ”œโ”€โ”€ errors.py              # Custom SDK exception classes
โ”‚
โ”œโ”€โ”€ sql/                   # SQL query builders
โ”‚   โ”œโ”€โ”€ option_queries.py
โ”‚   โ”œโ”€โ”€ stock_queries.py
โ”‚   โ””โ”€โ”€ utils.py
โ”‚
โ””โ”€โ”€ utils/                 # Internal helpers
    โ”œโ”€โ”€ df_helpers.py      # Convert raw rows โ†’ pandas DataFrame
    โ””โ”€โ”€ validation.py      # Validation for symbols, dates, limits, etc.

# Top-level project files
โ”œโ”€โ”€ pyproject.toml         # Package metadata & dependencies
โ”œโ”€โ”€ README.md              # Main SDK documentation
โ”œโ”€โ”€ DATABASE_SCHEMA.md     # Internal description of the market schema
โ””โ”€โ”€ test.ipynb             # Local notebook for testing the SDK


๐Ÿ” Authentication & Credentials

Each team member authenticates once using the CLI:

enode login

You will be prompted for:

  • API URL (our API Gateway endpoint)
  • API Key (hidden input)

Credentials are stored securely in:

~/.enode/credentials

Check the current login:

enode whoami

Log out:

enode logout

This keeps our fund's data secure while staying simple for everyone.


๐Ÿงช Quick Start

1. Install

From PyPI:

pip install enode-quant

or

uv add enode-quant  # if using uv (recommended)

2. Fetch Stock Quotes

from enode_quant import get_stock_quotes

df = get_stock_quotes(
    symbol="AAPL",
    start_date="2024-01-01",
    end_date="2024-02-01",
    limit=200,
    as_dataframe=True,
)

print(df.head())

3. Fetch Option Contracts

from enode_quant import get_option_contracts

contracts = get_option_contracts(
    symbol="AAPL",
    option_type="call",         # "put" or "both"
    expiration_before="2025-12-01",
    as_dataframe=True,
)

print(contracts.head())

4. Fetch Candles (OHLCV)

from enode_quant import get_stock_candles

candles = get_stock_candles(
    symbol="AAPL",
    resolution="1D",            # depends on how we store data
    start_date="2024-01-01",
    end_date="2024-02-01",
    limit=200,
    as_dataframe=True,
)

print(candles.head())

All high-level functions support flexible filters, such as:

  • symbol or stock_id
  • start_date and end_date
  • option_type (call / put / both)
  • expiration windows
  • resolution (for candles)
  • limit
  • as_dataframe (True/False)

๐Ÿงฑ How the SDK Works (Short Version)

When you call something like:

get_stock_quotes("AAPL")

internally the SDK:

  1. Loads your credentials from ~/.enode/credentials
  2. Builds a safe SQL query (using the sql helpers)
  3. Sends the query to API Gateway via HTTP
  4. API Gateway triggers the Lambda DB worker
  5. Lambda executes the query on PostgreSQL (RDS)
  6. The result is returned as JSON and (optionally) converted into a pandas DataFrame

Errors are mapped to clear Python exceptions:

  • MissingCredentialsError
  • AuthenticationError
  • APIConnectionError
  • ServerError

So researchers don't have to debug HTTP or SQL directly.


๐Ÿงฐ Available Modules

Stocks (enode_quant.api.stocks)

  • get_stock_quotes(...)

Options (enode_quant.api.options)

  • get_option_contracts(...)
  • get_option_quotes(...)

Candles (enode_quant.api.candles)

  • get_stock_candles(...)

Core

  • run_query(sql) โ€“ low-level query runner (normally not needed by beginners)
  • sql_literal(...) โ€“ helper for building safe SQL values
  • apply_date_filters(...) โ€“ shared date filter helper

CLI

  • enode login
  • enode whoami
  • enode logout

๐ŸŽฏ Design Principles (for the ENODE Quant Team)

  • Beginner-friendly โ€“ new members can get data with just a few lines of Python
  • Flexible โ€“ advanced users can control filters and parameters
  • Safe โ€“ validated inputs and no raw SQL from users
  • Extensible โ€“ easy to add new functions as our database grows

Planned future extensions (not implemented yet, but on the roadmap):

  • A backtesting module that uses the same data layer
  • A quant-finance utilities module (risk, stats, indicators) for research

๐Ÿ› ๏ธ Troubleshooting

Problem Error Solution
Not logged in MissingCredentialsError Run enode login
Wrong API key AuthenticationError Re-run enode login
Bad URL / network APIConnectionError Check URL and connectivity
Schema mismatch ServerError Update SDK or fix the query

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

enode_quant-0.1.8.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

enode_quant-0.1.8-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file enode_quant-0.1.8.tar.gz.

File metadata

  • Download URL: enode_quant-0.1.8.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for enode_quant-0.1.8.tar.gz
Algorithm Hash digest
SHA256 1f47dd998f2149f632aab120fa80f207a7e74c7b0c3ab7850a8829d86c2fb8f5
MD5 19ca890451a5116df5e1e524c2b41d79
BLAKE2b-256 15801d8d7b0715989bc41670eed4d50a8d0295167fec417bac29d54e117e44a1

See more details on using hashes here.

File details

Details for the file enode_quant-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: enode_quant-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for enode_quant-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 c91e15fd10c09d66a16523f488aba40e9f7a634ddfb48eb4bd7efca8eba9e42c
MD5 bb030f4ccd6ff6cd7ab577704e424045
BLAKE2b-256 2478a7ea2b70286f816bd777e2c8dfb5de19b201d260b64b004073faa74e2f9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page