Skip to main content

Crate tse_client

Crate tse_client 

Source
Expand description

§tse-client

A Rust port of the tse-client npm package: a client for fetching stock data from the Tehran Stock Exchange (TSETMC).

The public surface mirrors the original JS API:

Unlike the JS version, all per-call working state is owned locally and dropped when a call returns, so there is no cross-call accumulation.

§Example

use tse_client::{Client, IntradaySettings, PriceSettings};

let client = Client::new()?;

// getPrices
let res = client
    .get_prices(&["فملی".to_string()], &PriceSettings::default())
    .await?;
println!("{:#?}", res.data);

// getInstruments
let instruments = client.get_instruments().await?;
println!("{} instruments", instruments.len());

// getIntraday
let itd = client
    .get_intraday(&["فملی".to_string()], &IntradaySettings::default())
    .await?;
println!("{:#?}", itd.error);

Re-exports§

pub use client::Cell;
pub use client::Client;
pub use client::InstrumentPrices;
pub use client::PricesResult;
pub use config::Config;
pub use config::IntradaySettings;
pub use config::PriceSettings;
pub use error::Error;
pub use error::Result;
pub use error::ResultError;
pub use group::Period;
pub use group::group;
pub use models::COLS;
pub use models::COLS_FA;
pub use models::ClosingPrice;
pub use models::Column;
pub use models::Instrument;
pub use models::InstrumentItd;
pub use models::Share;
pub use models::itd_group_cols;

Modules§

adjust
Price-adjustment logic, ported from the JS adjust() using rust_decimal for exact decimal arithmetic with banker’s rounding (ROUND_HALF_EVEN).
client
The main client: instrument/price updates, merging, and get_prices.
config
Runtime configuration and per-call settings.
error
Error types for the crate.
group
Weekly / monthly price grouping based on the Jalali (Solar Hijri) calendar.
intraday
Intraday data fetching, ported from the JS getIntraday, extractAndStore and itdUpdateManager.
models
Data structures parsed from the TSETMC server, mirroring the JS classes.
request
HTTP request layer, replacing the JS rq object built on node-fetch.
storage
File-based cache storage, replacing the Node fs/zlib branch of the original JS storage object.
util
Date helpers, Persian text cleanup, and small utilities.