KHOpenApi.NET
1.5.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package KHOpenApi.NET --version 1.5.1
NuGet\Install-Package KHOpenApi.NET -Version 1.5.1
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="KHOpenApi.NET" Version="1.5.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KHOpenApi.NET --version 1.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: KHOpenApi.NET, 1.5.1"
#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 KHOpenApi.NET as a Cake Addin #addin nuget:?package=KHOpenApi.NET&version=1.5.1 // Install KHOpenApi.NET as a Cake Tool #tool nuget:?package=KHOpenApi.NET&version=1.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
KHOpenApi.NET (영웅문-Hero, 영웅문-Global)
- 32비트/64비트 공용, 키움증권 OpenApi C# wrapper class
- 개발환경: Visual Studio 2022, netstandard2.0
- WinUI3, WPF, Winforms 지원
- 비동기 TR 요청 지원 (CommRqDataAsync, CommKwRqDataAsync, SendConditionAsync)
- 64비트사용시, 추가 설치 필요 https://github.com/teranum/64bit-kiwoom-openapi
KOAStudio WPF Full source Project : https://github.com/teranum/KOAStudio
1. WPF
MainWindow.xaml.cs
public partial class MainWindow : Window
{
// ocx인터페이스 추가
private AxKHOpenAPI axKHOpenAPI; // 국내 (영웅문)
private AxKFOpenAPI axKFOpenAPI; // 해외 (영웅문 글로벌)
public MainWindow()
{
InitializeComponent();
// ActiveX 세팅
System.IntPtr Handle = new WindowInteropHelper(Application.Current.MainWindow).EnsureHandle();
axKHOpenAPI = new AxKHOpenAPI(Handle);
axKHOpenAPI.OnEventConnect += axKHOpenAPI_OnEventConnect;
button_login_KH.IsEnabled = axKHOpenAPI.Created;
axKFOpenAPI = new AxKFOpenAPI(Handle);
axKFOpenAPI.OnEventConnect += axKFOpenAPI_OnEventConnect;
button_login_KF.IsEnabled = axKFOpenAPI.Created;
}
// 국내로그인 이벤트 핸들러
private void axKHOpenAPI_OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
{
if (e.nErrCode == 0)
{
log_list.Items.Add("국내 로그인 성공");
}
else
{
log_list.Items.Add("국내 로그인 실패");
}
}
// 해외로그인 이벤트 핸들러
private void axKFOpenAPI_OnEventConnect(object sender, _DKFOpenAPIEvents_OnEventConnectEvent e)
{
if (e.nErrCode == 0)
{
log_list.Items.Add("해외 로그인 성공");
}
else
{
log_list.Items.Add("해외 로그인 실패");
}
}
private void button_login_KH_Click(object sender, RoutedEventArgs e)
{
// 국내 로그인 요청
axKHOpenAPI.CommConnect();
}
private void button_login_KF_Click(object sender, RoutedEventArgs e)
{
// 해외 로그인 요청
axKFOpenAPI.CommConnect(1);
}
private void button_Async_Click(object sender, RoutedEventArgs e)
{
_ = TestAsync();
}
// 비동기 요청 테스트 (nuget 버전 1.5.0 이상 지원)
async Task TestAsync()
{
// 국내 종목정보 가져오기
string itemCode = "005930";
axKHOpenAPI.SetInputValue("종목코드", itemCode);
string 종목명 = string.Empty;
int nRet = await axKHOpenAPI.CommRqDataAsync("주식기본정보요청", "OPT10001", 0, "1000", e =>
{
종목명 = axKHOpenAPI.GetCommData(e.sTrCode, e.sRQName, 0, "종목명").Trim();
});
// nRet: 0 성공, 음수 실패(-901: 중복요청오류, -902: 5초이상 응답없음, 그외 키움 오류코드 참조)
if (nRet == 0)
log_list.Items.Add(종목명);
else
log_list.Items.Add($"비동기 요청실패({nRet})");
}
}
2. WinForms
Form1.cs
public partial class Form1 : Form
{
// ocx인터페이스 추가
private AxKHOpenAPI axKHOpenAPI; // 국내 (영웅문)
private AxKFOpenAPI axKFOpenAPI; // 해외 (영웅문 글로벌)
public Form1()
{
InitializeComponent();
// ActiveX 세팅
axKHOpenAPI = new AxKHOpenAPI(Handle);
// WPF샘플과 동일
...
}
...
}
3. WinUI3 (target platforms: x86/x64, UnPackaged)
*WinuUI3 x86모드에서 글로벌OpenApi는 오류발생, x64모드에서는 오류없음
MainWindow.xaml.cs
public sealed partial class MainWindow : Window
{
// ocx인터페이스 추가
private AxKHOpenAPI axKHOpenAPI; // 국내 (영웅문)
private AxKFOpenAPI axKFOpenAPI; // 해외 (영웅문 글로벌)
public MainWindow()
{
this.InitializeComponent();
// ActiveX 세팅
System.IntPtr Handle = WinRT.Interop.WindowNative.GetWindowHandle(this);
axKHOpenAPI = new AxKHOpenAPI(Handle);
// WPF샘플과 동일
...
}
...
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
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.5.7 | 71 | 11/1/2024 |
1.5.6 | 93 | 10/2/2024 |
1.5.4 | 133 | 8/12/2024 |
1.5.3 | 169 | 7/21/2024 |
1.5.2 | 212 | 3/31/2024 |
1.5.1 | 306 | 2/18/2024 |
1.5.0 | 385 | 1/9/2024 |
1.4.0 | 474 | 11/5/2023 |
1.3.0 | 670 | 1/14/2023 |
1.1.0 | 721 | 9/21/2022 |
1.0.4 | 826 | 8/23/2022 |
1.0.3 | 712 | 8/22/2022 |
1.0.2 | 707 | 8/20/2022 |
1.0.1 | 679 | 8/19/2022 |