Crates.io | jquants-api-client |
lib.rs | jquants-api-client |
version | 0.1.0 |
source | src |
created_at | 2024-11-22 16:36:13.44204 |
updated_at | 2024-11-22 16:36:13.44204 |
description | A Rust client for the J-Quants API, providing seamless access to financial data. |
homepage | |
repository | https://github.com/ktanaka101/jquants-api-client-rust |
max_upload_size | |
id | 1457532 |
size | 447,466 |
The J-Quants API Client is a Rust implementation designed to provide seamless access to various J-Quants API endpoints. It facilitates efficient data retrieval and manipulation through asynchronous processing, ensuring fast and reliable communication.
J-Quants is a financial data platform provided by JPX Market Innovation & Research, Inc. (JPXI).
It offers access to a wide range of financial data through its API, enabling developers, analysts, and investors to integrate and analyze financial information effectively.
To use the J-Quants API, you must register for an account. A Free plan is available, allowing users to access the API without any cost. You can register for an account below.
For an in-depth understanding of the data provided, service usage, and API specifications, please refer to the following resources:
Ensure Rust is installed on your system. Then, add the jquants-api-client
to your Cargo.toml
:
[dependencies]
jquants-api-client = "0.1.0"
The J-Quants API Client currently supports the following APIs:
API Endpoint | Description | Status |
---|---|---|
/token/auth_user |
Refresh Token | Implemented |
/token/auth_refresh |
ID Token | Implemented |
API Endpoint | Description | Status |
---|---|---|
/listed/info |
Listed Issue Information | Implemented |
/prices/daily_quotes |
Stock Prices (OHLC) | Implemented |
/fins/statements |
Financial Data | Implemented |
/fins/announcement |
Earnings Calendar | Implemented |
/markets/trading_calendar |
Trading Calendar | Implemented |
/markets/trades_spec |
Trading by Type of Investors | Implemented |
/indices/topix |
TOPIX Prices (OHLC) | Implemented |
/indices |
Indices (OHLC) | Implemented |
/option/index_option |
Index Option Prices (OHLC) | Implemented |
/derivatives/futures |
Futures (OHLC) | Implemented |
/derivatives/options |
Options (OHLC) | Implemented |
/markets/weekly_margin_interest |
Margin Trading Outstandings | Implemented |
/markets/short_selling |
Short Sale Value and Ratio by Sector | Implemented |
/markets/breakdown |
Breakdown Trading Data | Implemented |
/prices/prices_am |
Morning Session Stock Prices (OHLC) | Implemented |
/fins/dividend |
Cash Dividend Data | Implemented |
/fins/fs_details |
Financial Statement Data (BS/PL) | Implemented |
Below are examples of how to use the J-Quants API client.
This example demonstrates a basic fetch operation to retrieve listed issue information.
use jquants_api_client::{
JQuantsFreePlanClient, ListedIssueInfoApi,
};
use tokio;
#[tokio::main]
async fn main() {
// Replace with your actual refresh token.
// Ensure you keep your refresh token secure and do not expose it in public repositories.
let refresh_token = "YOUR_REFRESH_TOKEN";
// Initialize the client with the refresh token
let client = JQuantsFreePlanClient::new_from_refresh_token(refresh_token);
// Make the API call to get listed issue information for code "2789"
match client.get_listed_issue_info().code("2789").send().await {
Ok(info) => println!("Listed Information: {:?}", info),
Err(e) => eprintln!("Error: {:?}", e),
}
}
This example demonstrates how to handle paginated responses when retrieving daily stock prices.
use futures::stream::StreamExt;
use jquants_api_client::{
JQuantsFreePlanClient, DailyStockPricesApi, Paginatable,
};
use tokio;
#[tokio::main]
async fn main() {
// Replace with your actual refresh token.
// Ensure you keep your refresh token secure and do not expose it in public repositories.
let refresh_token = "YOUR_REFRESH_TOKEN";
// Initialize the client with the refresh token
let client = JQuantsFreePlanClient::new_from_refresh_token(refresh_token);
// Create a stream to fetch paginated daily stock prices
let mut stream = client
.get_daily_stock_prices()
.code("27890")
.date("2024-08-01")
.fetch_pages_stream();
// Iterate through each page in the stream
while let Some(response) = stream.next().await {
match response {
Ok(daily_stock_prices_response) => {
println!("{daily_stock_prices_response:?}");
}
Err(e) => {
eprintln!("Error: {e}");
}
}
}
}
For more detailed examples, please refer to the examples directory in the repository.
Note: For security reasons, never commit or expose your refresh tokens or any other sensitive information in your code repositories.
Run unit tests using the following command:
cargo test
To run specific tests or see detailed output, you can use:
cargo test -- --nocapture
Contributions are welcome! To ensure a smooth process, please follow these guidelines:
git clone https://github.com/your-username/jquants-api-client-rust.git
cd jquants-api-client-rust
git checkout -b feature/your-feature-name
cargo test
git commit -m "Add feature: your feature description"
git push origin feature/your-feature-name
Note: Never commit or expose your refresh tokens or any other sensitive information in your code repositories.
If you encounter any bugs or have feature suggestions, please open an issue on the Issues page.
Comprehensive documentation is available here.
For API reference, visit the API Specifications (English), API Specifications (Japanese).
We value your feedback! If you have any suggestions or encounter issues, please open an issue or reach out directly.
This project is licensed under the MIT License.