alpaca-base
Base library with common structs, traits, and logic for Alpaca API clients.
Overview
alpaca-base provides the foundational building blocks for the Alpaca Market API Rust clients. It includes shared data models, authentication utilities, custom error types, and common helper functions used by both alpaca-http and alpaca-websocket.
Features
- Core Data Models: Comprehensive Rust representations of Alpaca API objects (Orders, Positions, Assets, etc.).
- Authentication: Utilities for managing API keys and generating authentication headers.
- Robust Error Handling: Centralized error types for API errors, validation errors, and rate limits.
- Utility Functions: Helpers for URL encoding, timestamp parsing, and more.
- Test Utilities: Fixtures and helpers for testing Alpaca integrations (available with
test-utilsfeature).
Installation
Add to your Cargo.toml:
[]
= "0.25.1"
Usage
While alpaca-base is primarily used internally by other crates in the workspace, you can use its types and authentication utilities directly.
[!TIP] Automated .env Loading:
Credentials::from_env()automatically attempts to load a.envfile at the start of execution using thedotenvcrate. You don't need to calldotenv().ok()manually in your code.
use Credentials;
// Automatically loads from .env
let credentials = from_env?;
Contribution and Contact
We welcome contributions to this project! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure that the project still builds and all tests pass.
- Commit your changes and push your branch to your forked repository.
- Submit a pull request to the main repository.
If you have any questions, issues, or would like to provide feedback, please feel free to contact the project maintainer:
Contact Information
- Author: Joaquín Béjar García
- Email: jb@taunais.com
- Telegram: @joaquin_bejar
- Repository: https://github.com/joaquinbejar/alpaca-rs
- Documentation: https://docs.rs/alpaca-base
We appreciate your interest and look forward to your contributions!
License: MIT
Disclaimer
This software is not officially associated with Alpaca Markets. Trading financial instruments carries risk, and this library is provided as-is without any guarantees. Always test thoroughly with a paper trading account before using in a live trading environment.