Crate twstock

Crate twstock 

Source
Expand description

§Taiwan Stock Exchange (TWSE) API

twstock is a library for fetching data from the Taiwan Stock Exchange (TWSE) API.

Behind the scenes, it uses the reqwest crate to make HTTP requests to their server.

§Example:

use twstock::*;

async fn fetch() {
    let client = Client::new();
    match client
        .realtime()
        .fetch(Stock {
            kind: StockKind::Live,
            code: 2330,
        })
        .await
    {
        Ok(x) => assert_eq!(x.name, "台積電"),
        Err(err) => match err {
            Error::MarketClosed => {}
            _ => panic!("unexpected error: {:?}", err),
        },
    };
}

§Features:

  • serde: Enable serde support
  • native-tls: Use the native-tls backend
  • native-tls-vendored: Use the native-tls backend with vendored OpenSSL
  • rustls-tls: Use the rustls backend

Don’t forget to disable default features if you want to use a specific TLS backend.

Modules§

history
TWSE monthly trading history data API
list
TWSE list api
realtime
TWSE realtime data API

Structs§

Client
Client for fetching data from the Taiwan Stock Exchange (TWSE) API
Stock
Stock identifier and its variant

Enums§

Error
Error type that may occur when interacting with the TWSE API
StockKind
variant of stock