koreasecurities

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

README

krsec

CI Go Reference

한국 증권사 REST API 통합 게이트웨이. 증권사마다 다른 인증, 파라미터, 응답 구조를 broker.Broker 인터페이스 하나로 통일합니다.

지원 증권사

증권사 상태
한국투자증권 (KIS)
키움증권
LS증권 예정

설치

go install github.com/smallfish06/krsec/cmd/krsec@latest

바이너리: Releases

설정

cp config.example.yaml config.yaml
server:
  port: 8080

accounts:
  - name: "main"
    broker: kis
    sandbox: true
    app_key: "YOUR_APP_KEY"
    app_secret: "YOUR_APP_SECRET"
    account_id: "12345678-01"

실행

krsec -config config.yaml

API

Method Path 설명
GET /quotes/{market}/{symbol} 현재가
GET /quotes/{market}/{symbol}/ohlcv 일봉
GET /instruments/{market}/{symbol} 종목 정보
GET /accounts/{id}/balance 잔고
GET /accounts/{id}/positions 포지션
GET /accounts/summary 멀티계좌 통합 잔고
POST /accounts/{account_id}/orders 주문
GET /accounts/{account_id}/orders/{id} 주문 상태
GET /accounts/{account_id}/orders/{id}/fills 체결내역
PUT /accounts/{account_id}/orders/{id} 주문 정정
DELETE /accounts/{account_id}/orders/{id} 주문 취소
GET /swagger/ Swagger UI
curl http://localhost:8080/quotes/KRX/005930
{"ok": true, "data": {"symbol": "005930", "price": 70000, ...}, "broker": "KIS"}

라이브러리로 사용

import (
    "github.com/smallfish06/krsec/pkg/broker"
    apiserver "github.com/smallfish06/krsec/pkg/server"
)

srv := apiserver.New(apiserver.Options{
    Port: 8080,
    Accounts: []apiserver.Account{{ID: "acc-1", Name: "Main", Broker: "custom"}},
    Brokers:  map[string]broker.Broker{"acc-1": myBroker},
})
srv.Run()

구조

cmd/krsec/        서버
pkg/broker/           공개 인터페이스
pkg/server/           임베드 가능한 HTTP 서버
internal/kis/         KIS 클라이언트 + 어댑터
internal/kiwoom/      키움 클라이언트 + 어댑터
internal/server/      HTTP 핸들러
examples/             사용 예시

개발

make test      # 테스트
make build     # 빌드
make lint      # lint
make mock      # mock 재생성

License

Apache 2.0

Documentation

Overview

Package koreasecurities provides a unified gateway for Korean securities broker APIs.

This module abstracts away the differences between Korean broker REST APIs (KIS, Kiwoom, LS, etc.) behind a single github.com/smallfish06/krsec/pkg/broker.Broker interface.

Most users will import one of the sub-packages:

Or run the standalone server:

krsec -config config.yaml

Directories

Path Synopsis
cmd
krsec command
examples
all-balances command
kis-balance command
kiwoom-balance command
internal
kis
pkg
broker
Package broker defines the common interface and types shared across all broker adapters.
Package broker defines the common interface and types shared across all broker adapters.
server
Package server provides a ready-to-use HTTP API server that can be wired with any github.com/smallfish06/krsec/pkg/broker.Broker implementation.
Package server provides a ready-to-use HTTP API server that can be wired with any github.com/smallfish06/krsec/pkg/broker.Broker implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL