Skip to content

Commit 5b43d3d

Browse files
authored
Merge pull request #12 from namjug-kim/develop
Develop
2 parents 71c1950 + fc407db commit 5b43d3d

File tree

71 files changed

+2184
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2184
-25
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ A Kotlin library for cryptocurrency trading.
88
### Websocket
99
Support public market feature (tickData, orderBook)
1010

11-
| Exchange | ver | doc |
12-
|----------------|---|---|
13-
| Binance | * | [ws](https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md)|
14-
| Upbit | v1.0.3 | [ws](https://docs.upbit.com/docs/upbit-quotation-websocket) |
15-
| HuobiKorea | * | [ws](https://github.com/alphaex-api/BAPI_Docs_ko/wiki) |
16-
| Okex | v3 | [ws](https://www.okex.com/docs/en/#spot_ws-all) |
17-
| Bithumb⚠️ | - | - |
11+
| logo | name | ExchangeVendor | ver | doc |
12+
| --------------------------------------------------------------------------------------------------------------------- | ----------- | ---------------- |--------|---|
13+
| ![binance](https://user-images.githubusercontent.com/16334718/57194951-e5e88600-6f87-11e9-918e-74de5c58e883.jpg) | Binance | BINANCE | * | [ws](https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md) |
14+
| ![upbit](https://user-images.githubusercontent.com/16334718/57194949-e54fef80-6f87-11e9-85b3-67b8f82db564.jpg) | Upbit | UPBIT | v1.0.3 | [ws](https://docs.upbit.com/docs/upbit-quotation-websocket) |
15+
| ![huobi korea](https://user-images.githubusercontent.com/16334718/57194946-e4b75900-6f87-11e9-940a-08ceb98193e4.jpg) | HuobiKorea | HUOBI_KOREA | * | [ws](https://github.com/alphaex-api/BAPI_Docs_ko/wiki) |
16+
| ![okex](https://user-images.githubusercontent.com/16334718/57195022-90f93f80-6f88-11e9-8aaa-f6a515d300ae.jpg) | Okex | OKEX | v3 | [ws](https://www.okex.com/docs/en/#spot_ws-all) |
17+
| ![bithumb](https://user-images.githubusercontent.com/16334718/57194948-e54fef80-6f87-11e9-90d8-41f108789c77.jpg) | Bithumb | BITHUMB | ⚠️ | ⚠️ |
18+
| ![hubi](https://user-images.githubusercontent.com/16334718/57194945-e4b75900-6f87-11e9-8fea-889fc93a7ba4.jpg) | Hubi | HUBI | * | [ws](https://www.hubi.com/docs/index-en.pdf) |
19+
| ![bitmex](https://user-images.githubusercontent.com/16334718/57194950-e54fef80-6f87-11e9-8b54-3f2192012306.jpg) | Bitmex | BITMEX | * | [ws](https://www.bitmex.com/app/wsAPI) |
1820

1921
⚠️ : Uses endpoints that are used by the official web. This is not an official api and should be used with care.
2022

@@ -48,15 +50,15 @@ Step 2. Add the dependency
4850

4951
### Gradle
5052

51-
```
53+
``` groovy
5254
repositories {
5355
...
5456
maven { url 'https://jitpack.io' }
5557
}
5658
```
5759
Step 1. Add jitpack repository
5860

59-
```
61+
``` groovy
6062
dependencies {
6163
implementation 'com.github.namjug-kim.reactive-crypto:reactive-crypto-{exchange-name}:v0.1.0.RELEASE'
6264
}
@@ -82,13 +84,15 @@ fun binanceTickDataExample() {
8284
### Java
8385

8486
```java
85-
public void binanceTickDataExample() {
86-
// create websocketClient for each crypto currency exchange
87-
ExchangeWebsocketClient exchangeWebsocketClient = ExchangeClientFactory.Companion.getInstance(ExchangeVendor.BINANCE);
88-
89-
List<CurrencyPair> targetPairs = Collections.singletonList(CurrencyPair.parse("BTC", "USDT"));
90-
exchangeWebsocketClient.createTradeWebsocket(targetPairs)
91-
.doOnNext(tickData -> log.info("new tick data {}", tickData))
92-
.subscribe();
87+
class SampleClass {
88+
public void binanceTickDataExample() {
89+
// create websocketClient for each crypto currency exchange
90+
ExchangeWebsocketClient exchangeWebsocketClient = ExchangeClientFactory.getInstance(ExchangeVendor.BINANCE);
91+
92+
List<CurrencyPair> targetPairs = Collections.singletonList(CurrencyPair.parse("BTC", "USDT"));
93+
exchangeWebsocketClient.createTradeWebsocket(targetPairs)
94+
.doOnNext(tickData -> log.info("new tick data {}", tickData))
95+
.subscribe();
96+
}
9397
}
9498
```

reactive-crypto-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/BinanceCommonUtil.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.binance
218

319
import com.njkim.reactivecrypto.core.common.model.currency.CurrencyPair

reactive-crypto-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/BinanceJsonObjectMapper.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.binance
218

319
import com.fasterxml.jackson.core.JsonParser

reactive-crypto-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/BinanceWebsocketClient.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.binance
218

319
import com.fasterxml.jackson.databind.ObjectMapper
@@ -10,6 +26,7 @@ import com.njkim.reactivecrypto.core.common.model.ExchangeVendor
1026
import com.njkim.reactivecrypto.core.common.model.currency.CurrencyPair
1127
import com.njkim.reactivecrypto.core.common.model.order.OrderBook
1228
import com.njkim.reactivecrypto.core.common.model.order.TickData
29+
import com.njkim.reactivecrypto.core.common.util.toEpochMilli
1330
import mu.KotlinLogging
1431
import reactor.core.publisher.Flux
1532
import reactor.netty.http.client.HttpClient
@@ -37,7 +54,7 @@ class BinanceWebsocketClient : ExchangeWebsocketClient {
3754
.map { it.data }
3855
.map { binanceTradeRawData ->
3956
TickData(
40-
binanceTradeRawData.tradeId.toString() + binanceTradeRawData.currencyPair + binanceTradeRawData.eventTime.toInstant().toEpochMilli(),
57+
binanceTradeRawData.tradeId.toString() + binanceTradeRawData.currencyPair + binanceTradeRawData.eventTime.toEpochMilli(),
4158
binanceTradeRawData.eventTime,
4259
binanceTradeRawData.price,
4360
binanceTradeRawData.quantity,

reactive-crypto-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/model/BinanceOrderBook.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.binance.model
218

319
import com.njkim.reactivecrypto.core.common.model.order.OrderBookUnit

reactive-crypto-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/model/BinanceResponseWrapper.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.binance.model
218

319
import com.njkim.reactivecrypto.binance.BinanceCommonUtil.parseCurrencyPair

reactive-crypto-binance/src/main/kotlin/com/njkim/reactivecrypto/binance/model/BinanceTickData.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.binance.model
218

319
import com.fasterxml.jackson.annotation.JsonProperty

reactive-crypto-bithumb/src/main/kotlin/com/njkim/reactivecrypto/bithumb/BithumbJsonObjectMapper.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.bithumb
218

319
import com.fasterxml.jackson.core.JsonParser

reactive-crypto-bithumb/src/main/kotlin/com/njkim/reactivecrypto/bithumb/BithumbWebsocketClient.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.bithumb
218

319
import com.fasterxml.jackson.module.kotlin.readValue
@@ -12,6 +28,7 @@ import com.njkim.reactivecrypto.core.common.model.order.OrderBook
1228
import com.njkim.reactivecrypto.core.common.model.order.OrderBookUnit
1329
import com.njkim.reactivecrypto.core.common.model.order.OrderSideType
1430
import com.njkim.reactivecrypto.core.common.model.order.TickData
31+
import com.njkim.reactivecrypto.core.common.util.toEpochMilli
1532
import mu.KotlinLogging
1633
import reactor.core.publisher.Flux
1734
import reactor.core.publisher.toFlux
@@ -85,7 +102,7 @@ class BithumbWebsocketClient : ExchangeWebsocketClient {
85102
.map { BithumbJsonObjectMapper.instance.readValue<BithumbResponseWrapper<BithumbOrderBook>>(it) }
86103
.map {
87104
OrderBook(
88-
"${it.header.currency}${ZonedDateTime.now().toInstant().toEpochMilli()}",
105+
"${it.header.currency}${ZonedDateTime.now().toEpochMilli()}",
89106
CurrencyPair(it.header.currency, Currency.KRW), // Bithumb only have KRW market
90107
ZonedDateTime.now(),
91108
ExchangeVendor.BITHUMB,

reactive-crypto-bithumb/src/main/kotlin/com/njkim/reactivecrypto/bithumb/model/BithumbOrderBook.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2019 namjug-kim
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
117
package com.njkim.reactivecrypto.bithumb.model
218

319
import com.fasterxml.jackson.annotation.JsonProperty

0 commit comments

Comments
 (0)