Skip to content

Commit

Permalink
feat: upbit balance
Browse files Browse the repository at this point in the history
  • Loading branch information
traeper committed Jul 15, 2019
1 parent 1ebb3fc commit 7f61ed3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class UpbitAccountOperation(
private val upbitRawPrivateHttpClient: UpbitRawPrivateHttpClient
) : AccountOperation(accessKey, secretKey) {
override fun balance(): Flux<Balance> {
TODO("not implemented")
return upbitRawPrivateHttpClient
.userData()
.balance()
.flatMapMany {
Flux.fromIterable(it)
}
.map {
Balance(
it.currency,
it.balance,
it.locked
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.njkim.reactivecrypto.upbit.http.raw
import com.fasterxml.jackson.module.kotlin.convertValue
import com.njkim.reactivecrypto.core.common.util.toMultiValueMap
import com.njkim.reactivecrypto.upbit.UpbitJsonObjectMapper
import com.njkim.reactivecrypto.upbit.model.UpbitBalance
import com.njkim.reactivecrypto.upbit.model.UpbitOrderStatus
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.bodyToMono
Expand Down Expand Up @@ -53,4 +54,19 @@ class UpbitRawUserDataOperator internal constructor(
.upbitErrorHandling()
.bodyToMono()
}

fun balance(): Mono<List<UpbitBalance>> {
val sign = sign(emptyMap(), accessKey, secretKey)

return webClient
.get()
.uri {
it.path("/v1/accounts")
.build()
}
.header("Authorization", "Bearer $sign")
.retrieve()
.upbitErrorHandling()
.bodyToMono()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,5 @@ data class UpbitBalance(
val avgBuyPriceModified: Boolean,

@get:JsonProperty("unit_currency")
val unitCurrency: String,

@get:JsonProperty("avg_krw_buy_price")
val avgKrwBuyPrice: BigDecimal,

@get:JsonProperty("modified")
val modified: Boolean
val unitCurrency: String
)

0 comments on commit 7f61ed3

Please sign in to comment.