CTPMarketData.Core
1.0.0
dotnet add package CTPMarketData.Core --version 1.0.0
NuGet\Install-Package CTPMarketData.Core -Version 1.0.0
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="CTPMarketData.Core" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CTPMarketData.Core" Version="1.0.0" />
<PackageReference Include="CTPMarketData.Core" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CTPMarketData.Core --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CTPMarketData.Core, 1.0.0"
#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.
#:package CTPMarketData.Core@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CTPMarketData.Core&version=1.0.0
#tool nuget:?package=CTPMarketData.Core&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CTPMarketData.Core
CTP期货行情订阅类库 - 独立的行情订阅和缓存解决方案
功能特性
✅ 独立的行情订阅服务
- 基于CTPFuture.Net封装
- 解决SWIGTYPE_p_p_char类型问题
- 支持多合约订阅
✅ 线程安全的内存缓存
- ConcurrentDictionary实现
- 自动过期清理
- 行情更新事件通知
✅ 简单易用的API
- 连接/断开
- 订阅/取消订阅
- 缓存查询
使用示例
using CTPMarketData.Core;
// 创建服务
var mdService = new MarketDataService();
// 订阅日志事件
mdService.LogReceived += (s, e) => Console.WriteLine(e.Message);
// 订阅连接状态
mdService.ConnectionStatusChanged += (s, e) =>
{
Console.WriteLine($"状态: {e.Status} - {e.Message}");
};
// 订阅行情更新事件
mdService.Cache.MarketDataUpdated += (s, e) =>
{
Console.WriteLine($"{e.Data.InstrumentID}: {e.Data.LastPrice}");
};
// 连接服务器
mdService.Connect(
"tcp://180.168.146.187:10211", // SimNow行情地址
"9999", // BrokerID
"your_user_id", // UserID
"your_password" // Password
);
// 订阅合约
mdService.Subscribe("rb2505", "MO2511-C-7500");
// 查询缓存
var lastPrice = mdService.Cache.GetLastPrice("rb2505");
if (lastPrice.HasValue)
{
Console.WriteLine($"最新价: {lastPrice.Value}");
}
// 清理
mdService.Dispose();
缓存API
// 获取行情数据
var data = mdService.Cache.Get("rb2505");
// 获取最新价
double? price = mdService.Cache.GetLastPrice("rb2505");
// 获取所有缓存
var all = mdService.Cache.GetAll();
// 检查是否有行情
bool has = mdService.Cache.Contains("rb2505");
// 清理过期数据(5分钟未更新)
int removed = mdService.Cache.RemoveExpired(300);
架构说明
CTPMarketData.Core/
├── MarketDataService.cs # 主服务类
├── MarketDataCache.cs # 缓存管理器
├── MarketDataSpiImpl.cs # SPI回调实现
└── README.md # 文档
版本
- 当前版本: 1.0.0
- 基于: CTPFuture.Net 6.3.15.5
- 目标框架: .NET 8.0
License
MIT
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- CTPFuture.Net (>= 6.3.15.5)
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.0 | 198 | 10/17/2025 |
v1.0.0 - 首次发布
- 独立的行情订阅服务
- 线程安全的内存缓存
- 解决SWIGTYPE_p_p_char类型问题
- 支持多合约订阅