-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
402b58c
commit 1a1b963
Showing
5 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,49 @@ | ||
# fugle-kt | ||
# fugle-kt | ||
|
||
[](https://github.com/chehsunliu/fugle-kt/actions/workflows/build.yml) | ||
[](https://github.com/chehsunliu/fugle-kt/actions/workflows/publish.yml) | ||
[](https://search.maven.org/artifact/io.github.chehsunliu.fuglekt/fugle-kt-core) | ||
|
||
fugle-kt is a client for Fugle Realtime API. | ||
|
||
## Installation | ||
|
||
Fetch the dependency via Gradle: | ||
|
||
```kotlin | ||
implementation("io.github.chehsunliu.fuglekt:fugle-kt-core:0.2.0-beta.1") | ||
|
||
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.1")) | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") | ||
``` | ||
|
||
## Usage | ||
|
||
Get the metadata of TSMC: | ||
|
||
```kotlin | ||
import io.github.chehsunliu.fuglekt.core.FugleAsyncClient | ||
import kotlinx.coroutines.runBlocking | ||
|
||
fun main() = runBlocking { | ||
FugleAsyncClient.create(token = "xxx").use { client -> | ||
val response = client.getMeta(symbolId = "2330") | ||
println(response) | ||
} | ||
} | ||
|
||
// GetMetaResponse(apiVersion=0.3.0, data=Data(info=StockInfo(date=2022-04-29, type=EQUITY, exchange=TWSE, market=TSE, symbolId=2330, countryCode=TW, timeZone=Asia/Taipei, lastUpdatedAt=2022-04-29T13:30+08:00), meta=Meta(market=TSE, nameZhTw=台積電, industryZhTw=半導體業, priceReference=531.0, priceHighLimit=584.0, priceLowLimit=478.0, canDayBuySell=true, canDaySellBuy=true, canShortMargin=true, canShortLend=true, tradingUnit=1000, currency=TWD, isTerminated=false, isSuspended=false, typeZhTw=一般股票, abnormal=正常, isUnusuallyRecommended=false, isNewlyCompiled=null))) | ||
``` | ||
|
||
Here is the `FugleAsyncClient` interface: | ||
|
||
```kotlin | ||
interface FugleAsyncClient : Closeable { | ||
suspend fun getMeta(symbolId: String, oddLot: Boolean? = null): GetMetaResponse | ||
suspend fun getQuote(symbolId: String, oddLot: Boolean? = null): GetQuoteResponse | ||
suspend fun getChart(symbolId: String, oddLot: Boolean? = null): GetChartResponse | ||
suspend fun getDealts(symbolId: String, limit: Int? = null, offset: Int? = null, oddLot: Boolean? = null): GetDealtsResponse | ||
suspend fun getVolumes(symbolId: String, oddLot: Boolean? = null): GetVolumesResponse | ||
suspend fun getCandles(symbolId: String, startDate: LocalDate, endDate: LocalDate): GetCandlesResponse | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
plugins { | ||
kotlin("jvm") version "1.6.21" | ||
id("com.github.johnrengelman.shadow") version "7.1.2" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation(project(":fugle-kt-core")) | ||
|
||
implementation(platform("org.jetbrains.kotlin:kotlin-bom")) | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
|
||
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.1")) | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") | ||
} |
11 changes: 11 additions & 0 deletions
11
fugle-kt-example/src/main/kotlin/io/github/chehsunliu/fuglekt/example/GetMetaExample.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.github.chehsunliu.fuglekt.example | ||
|
||
import io.github.chehsunliu.fuglekt.core.FugleAsyncClient | ||
import kotlinx.coroutines.runBlocking | ||
|
||
fun main() = runBlocking { | ||
FugleAsyncClient.create(token = System.getenv("FUGLE_TOKEN")).use { client -> | ||
val response = client.getMeta(symbolId = "2330") | ||
println(response) | ||
} | ||
} |