quiverquant 0.2.2

A crate for accessing the QuiverQuant API.
Documentation
//! Data types for the Congressional Trading, House Trading, and Senate Trading datasets.
//!
//! From the QuiverQuant API: 
//! > The Stock Trading on Congressional Knowledge Act requires members of U.S. Congress to publicly
//! file and disclose any financial transaction within 45 days of its occurrence. We download those
//! disclosures and parse them for stock trades.
//!
//! NOTE: All three datasets rely on the `TradingEntry` struct. Those fields may be accessed under
//! the `common` field of the `CongressTradingEntry` struct when using the Congress Trading dataset.

use super::*;

pub type CongressTrading = Vec<CongressTradingEntry>;
pub type SenateTrading = Vec<TradingEntry>;
pub type HouseTrading = Vec<TradingEntry>;

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
/// Direction of Transaction
/// Sale or Purchase
pub enum Transaction {
    Sale,
    Purchase,
    Exchange
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
/// House of Congress
pub enum CongressHouse {
    Senate,
    Representatives,
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
/// An Entry in the [`CongressTrading`] dataset
pub struct CongressTradingEntry {
    /// Date of Report
    pub report_date: Date,

    /// House the Representative serves in
    pub house: CongressHouse,
    
    #[serde(flatten)]
    pub common: TradingEntry
}


#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
/// This is the Structure returned from QuiverQuant's API for the HouseTrading and SenateTrading
/// API endpoints.
pub struct TradingEntry {
    /// Date of Transaction
    #[serde(alias = "TransactionDate")]
    #[serde(alias = "Date")]
    pub transaction_date: Date,
    /// Ticker of Transaction
    pub ticker: Ticker,
    /// Name of Senator
    #[serde(alias = "Senator")]
    #[serde(alias = "Representative")]
    pub representative: String,
    /// Transaction Direction
    pub transaction: Transaction,
    /// Amount of Transaction
    pub amount: Option<f64>
}