Skip to content

Commit f951faa

Browse files
版本 1.1.2
适配 KTrader-Broker-API v1.1.2 更新 CtpTdApi 增加登录超时机制、登录进度消息推送 规范错误信息推送
1 parent 4c51388 commit f951faa

File tree

8 files changed

+127
-106
lines changed

8 files changed

+127
-106
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ repositories {
139139
}
140140

141141
dependencies {
142-
implementation("org.rationalityfrontline.ktrader:ktrader-broker-ctp:1.1.1")
142+
implementation("org.rationalityfrontline.ktrader:ktrader-broker-ctp:1.1.2")
143143
// 如果需要使用其它版本的 JCTP,取消注释下面一行,并填入自己需要的版本号
144144
// implementation("org.rationalityfrontline:jctp") { version { strictly("6.6.1_P1_CP-1.0.0") } }
145145
}
@@ -151,11 +151,11 @@ dependencies {
151151
<dependency>
152152
<groupId>org.rationalityfrontline.ktrader</groupId>
153153
<artifactId>ktrader-broker-ctp</artifactId>
154-
<version>1.1.1</version>
154+
<version>1.1.2</version>
155155
</dependency>
156156
```
157157

158-
插件下载:
158+
**插件下载:**
159159

160160
[Releases](https://github.com/ktrader-tech/ktrader-broker-ctp/releases)
161161

examples/library-basic/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88
}
99

1010
dependencies {
11-
implementation("org.rationalityfrontline.ktrader:ktrader-broker-ctp:1.1.1")
11+
implementation("org.rationalityfrontline.ktrader:ktrader-broker-ctp:1.1.2")
1212
// 如果需要使用其它版本的 JCTP,取消注释下面一行,并填入自己需要的版本号
1313
// implementation("org.rationalityfrontline:jctp") { version { strictly("6.6.1_P1_CP-1.0.0") } }
1414
}

examples/library-basic/app/src/main/kotlin/com/example/basic/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fun main() {
3232
val brokerEvent = event.data
3333
when (brokerEvent.type) {
3434
// Tick 推送
35-
BrokerEventType.MD_TICK -> {
35+
BrokerEventType.TICK -> {
3636
val tick = brokerEvent.data as Tick
3737
// 当某合约触及涨停价时,以跌停价挂1手多单开仓限价委托单
3838
if (tick.lastPrice == tick.todayHighLimitPrice) {

examples/plugin-basic/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repositories {
1010
dependencies {
1111
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1")
1212
implementation("org.rationalityfrontline.workaround:pf4j:3.7.0")
13-
implementation("org.rationalityfrontline.ktrader:ktrader-broker-api:1.1.1")
13+
implementation("org.rationalityfrontline.ktrader:ktrader-broker-api:1.1.2")
1414
}
1515

1616
application {

examples/plugin-basic/app/src/main/kotlin/com/example/basic/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fun main() {
5252
val brokerEvent = event.data
5353
when (brokerEvent.type) {
5454
// Tick 推送
55-
BrokerEventType.MD_TICK -> {
55+
BrokerEventType.TICK -> {
5656
val tick = brokerEvent.data as Tick
5757
}
5858
// 其它事件(网络连接、订单回报、成交回报等)

lib/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ plugins {
99
}
1010

1111
group = "org.rationalityfrontline.ktrader"
12-
version = "1.1.1"
12+
version = "1.1.2"
1313
val NAME = "ktrader-broker-ctp"
1414
val DESC = "CTP implementation of KTrader-Broker-API"
1515
val GITHUB_REPO = "ktrader-tech/ktrader-broker-ctp"
1616

1717
val pluginClass = "org.rationalityfrontline.ktrader.broker.ctp.CtpBrokerPlugin"
1818
val pluginId = "broker-ctp-rf"
1919
val pluginVersion = version as String
20-
val pluginRequires = "1.1.1"
20+
val pluginRequires = "1.1.2"
2121
val pluginDescription = DESC
2222
val pluginProvider = "RationalityFrontline"
2323
val pluginLicense = "Apache License 2.0"

lib/src/main/kotlin/org/rationalityfrontline/ktrader/broker/ctp/CtpMdApi.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ internal class CtpMdApi(val config: CtpConfig, val kEvent: KEvent, val sourceId:
219219
val errorInfo = "${pRspInfo.errorMsg}, requestId=$nRequestID, isLast=$bIsLast"
220220
val connectRequests = requestMap.values.filter { it.tag == "connect" }
221221
if (connectRequests.isEmpty()) {
222-
postBrokerEvent(BrokerEventType.MD_ERROR, errorInfo)
222+
postBrokerEvent(BrokerEventType.ERROR, "【行情接口发生错误】$errorInfo")
223223
} else {
224224
resumeRequestsWithException("connect", errorInfo)
225225
}
@@ -275,7 +275,7 @@ internal class CtpMdApi(val config: CtpConfig, val kEvent: KEvent, val sourceId:
275275
if (subscriptions.isNotEmpty() && tradingDay == pRspUserLogin.tradingDay) {
276276
runBlocking {
277277
runWithRetry({ subscribeMarketData(subscriptions.toList(), mapOf("isForce" to true)) }, { e ->
278-
postBrokerEvent(BrokerEventType.MD_ERROR, "重连后自动订阅行情失败:$e")
278+
postBrokerEvent(BrokerEventType.ERROR, "【行情接口发生错误】重连后自动订阅行情失败:$e")
279279
})
280280
}
281281
}
@@ -284,7 +284,7 @@ internal class CtpMdApi(val config: CtpConfig, val kEvent: KEvent, val sourceId:
284284
subscriptions.clear()
285285
tradingDay = pRspUserLogin.tradingDay
286286
}
287-
postBrokerEvent(BrokerEventType.MD_USER_LOGGED_IN, Unit)
287+
postBrokerEvent(BrokerEventType.MD_LOGGED_IN, Unit)
288288
resumeRequests("connect", Unit)
289289
}, { errorCode, errorMsg ->
290290
resumeRequestsWithException("connect", "请求用户登录失败:$errorMsg ($errorCode)")
@@ -357,11 +357,11 @@ internal class CtpMdApi(val config: CtpConfig, val kEvent: KEvent, val sourceId:
357357
val code = getCode(data.instrumentID)
358358
val lastTick = lastTicks[code]
359359
val newTick = Translator.tickC2A(code, data, lastTick, tdApi.instruments[code]?.volumeMultiple, tdApi.getInstrumentStatus(code)) { e ->
360-
postBrokerEvent(BrokerEventType.MD_ERROR, "OnRtnDepthMarketData updateTime 解析失败:$code, ${data.updateTime}.${data.updateMillisec}, $e")
360+
postBrokerEvent(BrokerEventType.ERROR, "【行情接口发生错误】OnRtnDepthMarketData updateTime 解析失败:$code, ${data.updateTime}.${data.updateMillisec}, $e")
361361
}
362362
lastTicks[code] = newTick
363363
// 过滤掉订阅时自动推送的第一笔数据
364-
if (lastTick != null) postBrokerEvent(BrokerEventType.MD_TICK, newTick)
364+
if (lastTick != null) postBrokerEvent(BrokerEventType.TICK, newTick)
365365
}
366366
}
367367
}

0 commit comments

Comments
 (0)