| Crates.io | korea_investment_rs |
| lib.rs | korea_investment_rs |
| version | 0.1.6 |
| created_at | 2025-03-19 10:24:48.771884+00 |
| updated_at | 2025-10-01 02:10:41.180192+00 |
| description | Korea Investment & Securities Open API |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1597863 |
| size | 129,564 |
korea_investment_rs는 한국투자증권의 Open Trading API를 쉽게 사용할 수 있게 해주는 Rust 라이브러리입니다. REST API와 WebSocket을 통해 국내/해외 주식 시세 조회 및 실시간 데이터 수신, 주문 등 다양한 기능을 제공합니다.
Cargo.toml에 다음 의존성을 추가하세요:
[dependencies]
korea_investment_rs = "0.1.0"
tokio = { version = "1", features = ["full"] }
API 사용을 위해 발급받은 앱 키와 시크릿 키를 설정하세요:
use korea_investment_rs::auth::Auth;
async fn main() {
let auth = Auth::new("YOUR_APP_KEY", "YOUR_APP_SECRET").await.unwrap();
println!("발급된 토큰: {}", auth.access_token);
}
use korea_investment_rs::domestic::quotations::InquireDailyItemChartPrice;
#[tokio::main]
async fn main() {
// 환경 변수에서 API 키 로드
dotenv::dotenv().ok();
let app_key = std::env::var("APP_KEY").expect("APP_KEY not set");
let app_secret = std::env::var("APP_SECRET").expect("APP_SECRET not set");
// 인증 및 API 객체 생성
let auth = Auth::new(app_key, app_secret).await.unwrap();
// 삼성전자(005930) 일별 시세 조회
let params = InquireDailyItemChartPrice::new("J", "1", "005930");
let response = params.send(&auth).await.unwrap();
println!("조회 결과: {:?}", response);
}
/uapi/domestic-stock/v1/quotations/inquire-price: 현재가 시세 조회/uapi/domestic-stock/v1/quotations/inquire-daily-itemchartprice: 일별 시세 조회/uapi/domestic-stock/v1/quotations/inquire-elw-price: ELW 시세 조회HDFSCNT0)라이브러리에 포함된 예제 코드를 실행하려면:
# 일별 시세 조회 예제 실행
cargo run --example get_inquire_daily_itemchartprice --features ex
# 실시간 시세 구독 예제 실행
cargo run --example overseas_realtime_websocket --features ex
use korea_investment_rs::websocket::oauth::ApproveOauth;
async fn get_approval_key() {
let app_key = std::env::var("APP_KEY").expect("APP_KEY not set");
let app_secret = std::env::var("APP_SECRET").expect("APP_SECRET not set");
let oauth = ApproveOauth::new(app_key, app_secret).await.unwrap();
println!("WebSocket 접속키: {}", oauth.approval_key);
}
MIT License
Oauth::from_env, Oauth::from_env_with_cache]get_inquire_price]get_inquire_price2]get_recent_ticks]get_inquire_period_price]get_today_minutes]get_minutes_by_day]get_overseas_price]