docs: create/update README.md for all 17 crates
Create 8 missing READMEs (config, ctrader-openapi, market-data, ml-data, model_loader, risk-data, trading-data, training_uploader). Update 9 existing READMEs to standard template format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,50 +1,24 @@
|
||||
# Database Crate
|
||||
# database
|
||||
|
||||
## Overview
|
||||
PostgreSQL persistence layer for the Foxhunt HFT system.
|
||||
|
||||
The `database` crate manages the persistent storage layer for the Foxhunt HFT system, primarily utilizing PostgreSQL. It handles schema definitions, migrations, and provides utilities for storing and querying critical trading data, including time-series market data and audit logs.
|
||||
## Key Types
|
||||
|
||||
- `DatabasePool` — connection pool management
|
||||
- Schema definitions for trading events, market data, and audit logs
|
||||
- Migration management utilities
|
||||
|
||||
## Features
|
||||
|
||||
* **PostgreSQL Schema & Migrations:** Defines database schemas for trading events, market data, and user configurations, managed via an integrated migration system.
|
||||
* **Event Streaming & Audit Log:** Provides interfaces for recording and querying all significant system events, ensuring a comprehensive audit trail for compliance and post-trade analysis.
|
||||
* **Optimized Time-Series Storage:** Implements efficient storage and indexing strategies for high-volume, time-series market data.
|
||||
* **Query Utilities:** Offers a set of helper functions and ORM-like abstractions for common data retrieval and manipulation tasks.
|
||||
* **Connection Pooling:** Manages database connections efficiently using a connection pool to minimize overhead and improve throughput.
|
||||
* **Data Archiving & Retention:** Includes mechanisms for managing data lifecycle, such as archiving old data or implementing retention policies.
|
||||
- PostgreSQL schema and migrations
|
||||
- Event streaming and audit log
|
||||
- Optimized time-series storage and indexing
|
||||
- Connection pooling for high-throughput access
|
||||
- Data archiving and retention policies
|
||||
|
||||
## Usage
|
||||
|
||||
```rust
|
||||
use database::models::{TradeEvent, NewTradeEvent};
|
||||
use database::connection::establish_connection;
|
||||
use common::types::{InstrumentId, Price, Quantity};
|
||||
use chrono::Utc;
|
||||
|
||||
// This would typically come from a connection pool
|
||||
let mut conn = establish_connection().expect("Failed to connect to database");
|
||||
|
||||
let new_trade = NewTradeEvent {
|
||||
timestamp: Utc::now(),
|
||||
instrument_id: InstrumentId::new("ETHUSD".to_string()),
|
||||
price: Price::new(3000.50),
|
||||
quantity: Quantity::new(1.2),
|
||||
side: "BUY".to_string(),
|
||||
// ... other fields
|
||||
};
|
||||
|
||||
// Example: Insert a new trade event
|
||||
// let inserted_trade = database::crud::create_trade_event(&mut conn, new_trade)
|
||||
// .expect("Failed to insert trade event");
|
||||
// println!("Inserted trade: {:?}", inserted_trade);
|
||||
let conn = establish_connection()?;
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
cargo test --package database
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Detailed API documentation is available at [docs.rs/database](https://docs.rs/database).
|
||||
|
||||
Reference in New Issue
Block a user