- Remove ~44k LOC of dead code, legacy v1 TS simulator/strategy stack, event-bus, analytics FastAPI prototype, legacy calculation archives, and unused deps (data-ingestion provider API handlers untouched) - Extract @stock-bot/di/http-security and isolate @stock-bot/browser to data-ingestion via ServiceContainerBuilder.withRegistrations() - Harden @stock-bot/mongodb read-only proxies, flatten @stock-bot/postgres with unified master+research migrations, and fix @stock-bot/config EnvLoader, ServiceApplication worker lifecycle, NamespacedCache.clear(), and BatchProcessor error propagation - Flatten workspace root (remove apps/stock/package.json) and collapse orchestrator re-export shims - Pin all Docker image versions, add shm_size/nofile/RAM caps and docker-compose.quant.yml, fix 05-add-visible-column.sql view recreation, and decouple dev/QA Compose project names for side-by-side execution - Update PLATFORM-PLAN, DATA-CONTRACTS (bars_1m PARTITION BY MONTH, Rust bulk ETL, DuckDB limits), MILESTONES, and servers docs |
||
|---|---|---|
| .. | ||
| src | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
MongoDB Client Library
A comprehensive MongoDB client library for the Stock Bot trading platform, designed for handling document storage, raw data, and unstructured content.
Features
- Connection Management: Robust connection pooling and failover
- Schema Validation: Built-in validation using Zod schemas
- Type Safety: Full TypeScript support with typed collections
- Error Handling: Comprehensive error handling and retry logic
- Health Monitoring: Connection health monitoring and metrics
- Transactions: Support for multi-document transactions
- Aggregation: Helper methods for complex aggregation pipelines
Usage
import { MongoDBClient } from '@stock-bot/mongodb';
// Initialize client
const mongoClient = new MongoDBClient();
await mongoClient.connect();
// Get a typed collection
const collection = mongoClient.getCollection('sentiment_data');
// Insert document
await collection.insertOne({
symbol: 'AAPL',
sentiment: 'positive',
source: 'reddit',
timestamp: new Date()
});
// Query with aggregation
const results = await collection.aggregate([
{ $match: { symbol: 'AAPL' } },
{ $group: { _id: '$sentiment', count: { $sum: 1 } } }
]);
Collections
The client provides typed access to the following collections:
- sentiment_data: Social media sentiment analysis
- raw_documents: Unprocessed documents and content
- news_articles: Financial news and articles
- sec_filings: SEC filing documents
- earnings_transcripts: Earnings call transcripts
- analyst_reports: Research reports and analysis
Configuration
Configure using environment variables:
MONGODB_HOST=localhost
MONGODB_PORT=27017
MONGODB_DATABASE=trading_documents
MONGODB_USERNAME=trading_admin
MONGODB_PASSWORD=your_password
Health Monitoring
The client includes built-in health monitoring:
const health = await mongoClient.getHealth();
console.log(health.status); // 'healthy' | 'degraded' | 'unhealthy'