Skip to main content

Crate thaler

Crate thaler 

Source
Expand description

The Thaler API from Rust: financial data from SEC filings, with the source filing for every value.

use thaler::{Client, MetricPeriod};

let client = Client::from_env()?; // THALER_API_KEY, or Client::new("thaler_…")
let rows = client
    .metrics("AAPL")
    .period(MetricPeriod::Annual)
    .keys(["revenue", "net_income"])
    .send()
    .await?;
for row in &rows.data {
    println!("{:?} {} {}", row.fiscal_year, row.metric_key, row.value);
}
println!("{} left this month", rows.rate_limit.and_then(|l| l.month).and_then(|m| m.remaining).unwrap_or(0));

Every figure is a Decimal (a decimal string, exact to the digit as filed), every day a chrono::NaiveDate, and every answer a Response carrying the request ID and the account’s limits beside its data. The client keeps at most four requests in flight, waits when the minute’s limit is spent, retries a 429 after its Retry-After and a 500, 502, 503 or 504 after a growing pause, and returns a typed Error for the rest.

The types in types are generated from the API’s OpenAPI document; API_VERSION names the document they came from.

Re-exports§

pub use client::Client;
pub use client::ClientBuilder;
pub use client::DEFAULT_BASE_URL;
pub use client::FilingRequest;
pub use client::FilingsDayRequest;
pub use client::FilingsRequest;
pub use client::HolderRequest;
pub use client::HoldersRequest;
pub use client::InsiderActivityRequest;
pub use client::MetricCatalogRequest;
pub use client::MetricLineageRequest;
pub use client::MetricRevisionsRequest;
pub use client::MetricsRequest;
pub use client::PricesRequest;
pub use client::ProfileRequest;
pub use client::RawConceptsRequest;
pub use client::ReleaseRequest;
pub use client::Response;
pub use client::ScreenRequest;
pub use client::SearchHoldersRequest;
pub use client::SearchSecuritiesRequest;
pub use client::SegmentsRequest;
pub use error::ApiError;
pub use error::ApiErrorKind;
pub use error::Error;
pub use filters::Clause;
pub use filters::ClauseValue;
pub use filters::Op;
pub use ratelimit::RateLimit;
pub use ratelimit::Window;
pub use types::*;

Modules§

client
The client and its requests.
error
What can go wrong.
filters
The Screener’s filters, written as clauses.
ratelimit
The account’s limits, as every answer reports them.
types
The Thaler API’s types, generated by sdk/codegen from its OpenAPI document (1.0.0-beta.2). Do not edit.

Structs§

Decimal
A figure as a decimal string: 416161000000, 39.75, -58000000, 0.3018. The API never sends a number, because a double loses digits past the fifteenth; this keeps the digits and lets you parse them into the arithmetic type you use. With the rust_decimal feature, Decimal::to_decimal gives the rust_decimal crate’s type.
NotADecimal
Why a string is not a decimal.

Constants§

VERSION
The crate’s version, as the User-Agent announces it.