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:
Client::get_prices↔getPricesClient::get_instruments↔getInstrumentsClient::get_intraday↔getIntradayClient::get_intraday_instruments↔getIntradayInstruments
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::itd_group_cols;
Modules§
- adjust
- Price-adjustment logic, ported from the JS
adjust()usingrust_decimalfor 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,extractAndStoreanditdUpdateManager. - models
- Data structures parsed from the TSETMC server, mirroring the JS classes.
- request
- HTTP request layer, replacing the JS
rqobject built onnode-fetch. - storage
- File-based cache storage, replacing the Node
fs/zlibbranch of the original JSstorageobject. - util
- Date helpers, Persian text cleanup, and small utilities.