Skip to content

Commit 9160f59

Browse files
版本 1.0.0
完善文档 去除查询方法中的 retry 参数 去除 USER_LOGGED_OUT 事件 重命名 entities.kt 中部分字段 更新 README
1 parent 32bd7ba commit 9160f59

File tree

7 files changed

+660
-47
lines changed

7 files changed

+660
-47
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# KTrader-Broker-API
2-
[![Apache License 2.0](https://img.shields.io/github/license/rationalityfrontline/ktrader-broker-api)](https://github.com/RationalityFrontline/ktrader-broker-api/blob/master/LICENSE)
2+
[![Maven Central](https://img.shields.io/maven-central/v/org.rationalityfrontline.ktrader/ktrader-broker-api.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.rationalityfrontline.ktrader%22%20AND%20a:%22ktrader-broker-api%22) [![Apache License 2.0](https://img.shields.io/github/license/ktrader-tech/ktrader-broker-api)](https://github.com/ktrader-tech/ktrader-broker-api/blob/master/LICENSE)
33

4-
[KTrader](https://github.com/RationalityFrontline/ktrader) 量化交易平台的 broker 统一接口
4+
[KTrader](https://github.com/ktrader-tech/ktrader) 量化交易平台的 Broker 统一接口
55

66
## License
77

8-
Ktrader-Broker-API is released under the [Apache 2.0 license](https://github.com/RationalityFrontline/ktrader-broker-api/blob/master/LICENSE).
8+
Ktrader-Broker-API is released under the [Apache 2.0 license](https://github.com/ktrader-tech/ktrader-broker-api/blob/master/LICENSE).
99

1010
```
1111
Copyright 2021 RationalityFrontline

lib/build.gradle.kts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,22 @@ plugins {
33
`java-library`
44
`maven-publish`
55
signing
6-
id("org.jetbrains.dokka") version "1.4.32"
6+
id("org.jetbrains.dokka") version "1.5.0"
77
id("org.javamodularity.moduleplugin") version "1.8.7"
88
}
99

1010
group = "org.rationalityfrontline.ktrader"
11-
version = "0.1.6-SNAPSHOT"
11+
version = "1.0.0"
1212
val NAME = "ktrader-broker-api"
1313
val DESC = "KTrader Broker API"
14-
val GITHUB_REPO = "RationalityFrontline/ktrader-broker-api"
14+
val GITHUB_REPO = "ktrader-tech/ktrader-broker-api"
1515

1616
repositories {
17-
mavenLocal()
1817
mavenCentral()
1918
}
2019

2120
dependencies {
22-
compileOnly("org.pf4j:pf4j:3.7.0-SNAPSHOT")
21+
compileOnly("org.rationalityfrontline.workaround:pf4j:3.7.0")
2322
api("org.rationalityfrontline:kevent:2.0.0")
2423
}
2524

@@ -78,8 +77,8 @@ publishing {
7877
developer {
7978
name.set("RationalityFrontline")
8079
email.set("[email protected]")
81-
organization.set("RationalityFrontline")
82-
organizationUrl.set("https://github.com/RationalityFrontline")
80+
organization.set("ktrader-tech")
81+
organizationUrl.set("https://github.com/ktrader-tech")
8382
}
8483
}
8584
scm {

lib/src/main/kotlin/org/rationalityfrontline/ktrader/broker/api/Broker.kt

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,59 @@ package org.rationalityfrontline.ktrader.broker.api
33
import org.pf4j.ExtensionPoint
44
import org.rationalityfrontline.kevent.KEvent
55

6+
/**
7+
* 交易接口插件类,用于获取相关信息及生成 [BrokerApi] 实例
8+
*/
69
abstract class Broker : ExtensionPoint {
10+
11+
/**
12+
* 交易接口名称。例:"CTP"
13+
*/
714
abstract val name: String
15+
16+
/**
17+
* 交易接口版本。
18+
*/
819
abstract val version: String
20+
21+
/**
22+
* 实例化 [BrokerApi] 时所需的参数说明。[Pair.first] 为参数名,[Pair.second] 为参数说明。
23+
* 例:Pair("password", "String 投资者资金账号的密码")
24+
*/
925
abstract val configKeys: List<Pair<String, String>>
26+
27+
/**
28+
* [BrokerApi] 成员方法的额外参数(extras: Map<String, Any>?)说明。[Pair.first] 为方法名,[Pair.second] 为额外参数说明。
29+
* 例:Pair("insertOrder", "[minVolume: Int]【最小成交量。仅当下单类型为 OrderType.FAK 时生效】")
30+
*/
1031
open val methodExtras: List<Pair<String, String>> = listOf()
32+
33+
/**
34+
* 自定义方法的说明(对应 [BrokerApi.customRequest]/[BrokerApi.customSuspendRequest])。[Pair.first] 为方法名,[Pair.second] 为方法文档(参数说明及返回值说明)。
35+
* 例:Pair("suspend fun queryMaxOrderVolume(code: String, direction: Direction, offset: OrderOffset): Int", "[合约代码,买卖方向,开平类型]【查询并返回最大下单量,未查到则返回 0】")
36+
*/
1137
open val customMethods: List<Pair<String, String>> = listOf()
38+
39+
/**
40+
* 自定义事件的说明(对应 [CustomEvent])。[Pair.first] 为事件类型,[Pair.second] 为事件说明。
41+
* 例:Pair("TD_MARKET_STATUS_CHANGE", "[data: MarketStatus]【市场交易状态变动】")
42+
*/
1243
open val customEvents: List<Pair<String, String>> = listOf()
44+
45+
/**
46+
* 创建 [BrokerApi] 实例
47+
* @param config 参见 [configKeys]
48+
* @param kEvent 会通过该 [KEvent] 实例推送 [BrokerEvent],如 [Tick]、成交回报等
49+
*/
1350
abstract fun createApi(config: Map<String, Any>, kEvent: KEvent): BrokerApi
14-
private fun formatPairList(list: List<Pair<String, String>>): String {
15-
return if (list.isEmpty()) "null" else {
16-
val indent = " "
17-
list.joinToString(separator = "\n", prefix = "{\n", postfix = "\n$indent}") { "$indent ${it.first}: ${it.second}" }
18-
}
19-
}
51+
2052
override fun toString(): String {
53+
fun formatPairList(list: List<Pair<String, String>>): String {
54+
return if (list.isEmpty()) "null" else {
55+
val indent = " "
56+
list.joinToString(separator = "\n", prefix = "{\n", postfix = "\n$indent}") { "$indent ${it.first}: ${it.second}" }
57+
}
58+
}
2159
return """
2260
Broker@${hashCode()}, name=$name, version=$version
2361
configKeys:

0 commit comments

Comments
 (0)