Skip to content

Commit

Permalink
Fix stock download. #3
Browse files Browse the repository at this point in the history
  • Loading branch information
slomkowski committed Oct 9, 2020
1 parent c858f1b commit bd44413
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class StockView(
val high: BigDecimal,
val low: BigDecimal,
val close: BigDecimal,
val volume: Int,
val openInt: Int) {
val volume: Long,
val openInt: Long) {
init {
require(ticker.isNotBlank())
require(interval > Duration.ZERO)
Expand Down Expand Up @@ -70,8 +70,8 @@ class StockView(
record[5].toBigDecimal(),
record[6].toBigDecimal(),
record[7].toBigDecimal(),
record[8].toInt(),
record[9].toInt())
record[8].toLong(),
record[9].toLong())
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import java.time.DayOfWeek
import java.time.LocalDate
import kotlin.test.assertNotNull

internal class StockViewTest {

Expand All @@ -27,5 +28,12 @@ internal class StockViewTest {
val stockData = runBlocking { StockView.downloadStockData(lastWeekDay) }
assertTrue(stockData.isNotEmpty())
logger.info("Downloaded {} stocks.", stockData.size)

val stockDataByTicker = stockData.groupBy { it.ticker }
logger.info("Found {} tickers.", stockDataByTicker.size)

assertNotNull(stockDataByTicker["CDR"])
assertNotNull(stockDataByTicker["TPE"])
assertNotNull(stockDataByTicker["PKO"])
}
}

0 comments on commit bd44413

Please sign in to comment.