tradingkit 0.1.0

Exchange-agnostic trading library for equities and crypto
Documentation
//! Exchange-facing traits and concrete exchange modules.

use std::error::Error;

use reqwest::header::HeaderMap;

/// Credentials for exchanges that still use payload signing.
pub trait Credentials {
    /// Signs a payload string and returns the exchange-specific signature.
    fn sign(&self, payload: &str) -> Result<String, Box<dyn Error>>;
}

/// Authentication header provider used by REST exchange implementations.
pub trait RequestHeaders {
    /// Builds request headers for a method, path, and serialized body.
    fn headers(&self, method: &str, path: &str, payload: &str)
    -> Result<HeaderMap, Box<dyn Error>>;
}

/// Minimal constructor trait kept for exchange-specific instantiation.
pub trait Exchange {
    /// Credential type accepted by the exchange constructor.
    type Credentials: Credentials;

    /// Creates a new exchange instance from credentials.
    fn new(x: Self::Credentials) -> Self;
}

pub mod alpaca;
pub mod okx;