eFriendOpenAPI 1.0.9

dotnet add package eFriendOpenAPI --version 1.0.9                
NuGet\Install-Package eFriendOpenAPI -Version 1.0.9                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="eFriendOpenAPI" Version="1.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add eFriendOpenAPI --version 1.0.9                
#r "nuget: eFriendOpenAPI, 1.0.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install eFriendOpenAPI as a Cake Addin
#addin nuget:?package=eFriendOpenAPI&version=1.0.9

// Install eFriendOpenAPI as a Cake Tool
#tool nuget:?package=eFriendOpenAPI&version=1.0.9                

KIS (eFriend Expert)

NuGet version

C# - eFriend Expert OCX 예제를 .NET Core/5+ Console App에서 사용하는 방법 ; https://www.sysnet.pe.kr/2/0/13482

Usage instructions

Initialize Client object with appkey, appsecret and account

// Install-Package eFriendOpenAPI

(string appKey, string secretKey, string account) = (...);
bool isVTS = false; // true: 모의 Domain, false: 실전 Domain

eFriendClient client = new eFriendClient(isVTS, appKey, secretKey, account);

// AccessToken 발급
if (await client.CheckAccessToken() == false)
{
    Console.WriteLine("Failed to get AccessToken");
    return;
}

// 웹소켓 연결
if (await client.ConnectWebSocketAsync() == false)
{
    Console.WriteLine("Failed to get connection for websocket");
    return;
}

Call API

국내주식주문

주식주문(현금)[v1_국내주식-001] (/uapi/domestic-stock/v1/trading/order-cash)
string 종목코드 = "329200"; // 종목코드(6자리)
var 시세 = await client.주식현재가시세(종목코드);
uint 주문단가 = 시세?.하한가 ?? 10_000;

(주식주문현금DTO? order, string error) = await client.주식현금매수주문(종목코드, /*주문수량*/ 1, /*지정가*/ "00", 주문단가);

주식주문(정정취소)[v1_국내주식-003] (/uapi/domestic-stock/v1/trading/order-rvsecncl)
(주식주문현금DTO? order, string error) = await client.주식현금매수주문(종목코드, /*주문수량*/ 1, /*지정가*/ "00", 주문단가);

await Task.Delay(1000 * 5); // 5초 후 전량 취소

(var canceled, error) = await client.주식주문전량취소(order.KRX_FWDG_ORD_ORGNO, order.ODNO);

주식잔고조회 (/uapi/domestic-stock/v1/trading/inquire-balance)
var array = await client.주식잔고조회();

foreach (주식잔고조회DTO dto in array)
{
    Console.WriteLine($"\t{dto}");
}

국내주식시세

주식현재가 시세 (/uapi/domestic-stock/v1/quotations/inquire-price)
var dto = await client.주식현재가시세("305720");
Console.WriteLine(dto);
// 출력 결과:
// (최저가: 23235) ~ (현재가: 23235) ~ (최고가: 23895), 전일 대비: -465, 호가 단위: 5, (305720, ETF)

실시간시세(국내주식)

국내주식 실시간체결가 (/tryitout/H0STCNT0)

// 실시간 체결가 이벤트 핸들러 등록
client.국내주식실시간체결가Arrived += (sender, e) =>
{
    foreach (var item in e)
    {
        Console.WriteLine($"[실시간 체결] {item}");
    }
};

// 실시간 체결가 등록
await client.국내주식실시간체결가(종목코드, true); // true == 이벤트 등록

await Task.Delay(1000 * 5); // 5초 후 등록 해제

await client.국내주식실시간체결가(종목코드, false); // false == 이벤트 해제

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.9 212 1/12/2024
1.0.8 158 12/23/2023
1.0.7 132 12/23/2023