Skip to content

BeginnerUtilities & ToolsPython

Run this module

cd "Market Data"
python "api_utils.py"

View source on GitHub


Market Data Utilities

This folder contains utilities for processing, analyzing, and fetching market data for financial applications.

Available Utilities

Market Data (market_data_utils.py)

  • Return calculations (simple and logarithmic)
  • Outlier detection and missing data handling
  • Market sentiment analysis
  • Data validation and quality control
  • Market timing indicators
  • Data smoothing techniques

API (api_utils.py)

  • HTTP request handling with retry logic
  • API key generation and secure storage
  • Error handling and timeout management
  • Response parsing and validation

Usage

# Market data operations
from market_data_utils import calculate_returns, detect_outliers, calculate_market_sentiment
from api_utils import make_api_request, retry_api_request, generate_api_key

# Data analysis
returns = calculate_returns(prices, 'log')
outliers = detect_outliers(data, 'iqr')
sentiment = calculate_market_sentiment(news_data, keywords)

# API operations
response = make_api_request("https://api.example.com/stocks/AAPL")
api_key = generate_api_key(32)

Installation

Requires numpy, scipy, and requests:

pip install numpy scipy requests

Testing

Run each utility directly to see demonstrations:

python market_data_utils.py
python api_utils.py

Common Use Cases

  • Data Processing: Clean and validate market data
  • Technical Analysis: Calculate indicators and signals
  • API Integration: Fetch data from external sources
  • Quality Control: Ensure data accuracy and completeness
  • Sentiment Analysis: Analyze market sentiment from news
  • Algorithm Development: Prepare data for trading strategies

Continue in Utilities & Tools

  • Core Utilities

    This folder contains core mathematical and date/time utilities that form the foundation for quantitative finance calculations.

  • Currency Converter

    This utility does NOT use any external APIs. All exchange rates are entered manually for learning and experimentation.

  • Data Processing

    This folder contains utilities for data processing, validation, and manipulation in financial applications.

  • Economic Calendar

    This utility does NOT use any external APIs. All data is managed locally for learning and experimentation.

  • Historical Data

    A Node.js script that fetches historical bars (OHLCV data) for stocks or crypto from the Alpaca Market Data API. It prompts interactively for the symbol type, symbol, timeframe, and date range, then prints the results as JSON.

  • Logging

    A pair of minimal, dependency-light logging utilities implemented in both Python and JavaScript. Each supports adding, reading, editing, and deleting log entries through an interactive command-line menu. All entries are persisted to a plain-text log.txt file in the working directory.

Browse all modules Learning paths