Skip to content

Commit 65f3438

Browse files
committed
minor fixes
1 parent d2ef496 commit 65f3438

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ publishTo := {
3434
publishConfiguration := publishConfiguration.value.withOverwrite(true)
3535
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)
3636

37-
version := "0.7"
37+
version := "0.8"
3838

3939
scalaVersion := "2.13.1"
4040

src/main/scala/ai/quantnet/data.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object data {
4141
) : List[StockInfo] = {
4242

4343
val uri = s"/assets?min_date=$minDate&max_date=$maxDate"
44-
val dataBytes = net.httpRequestWithRetry(baseUrl + uri)
44+
val dataBytes = net.httpRequestWithRetry(toUrl(uri))
4545
if(dataBytes == null) {
4646
return List.empty
4747
}
@@ -153,7 +153,7 @@ object data {
153153
maxDate: LocalDate = LocalDate.now()
154154
) : List[IndexInfo] = {
155155
val uri = s"/idx/list?min_date=$minDate&max_date=$maxDate"
156-
val dataBytes = net.httpRequestWithRetry(baseUrl + uri)
156+
val dataBytes = net.httpRequestWithRetry(toUrl(uri))
157157
net.OBJECT_MAPPER.readValue[List[IndexInfo]](dataBytes)
158158
}
159159

@@ -168,7 +168,7 @@ object data {
168168
maxDate: LocalDate = LocalDate.now()
169169
): DataFrame[LocalDate, String, Double] = {
170170
val params = Map("ids" -> ids, "min_date"-> minDate.toString, "max_date"-> maxDate.toString)
171-
val resBytes = net.httpRequestWithRetry(baseUrl + "/idx/data", params)
171+
val resBytes = net.httpRequestWithRetry(toUrl("/idx/data"), params)
172172
var resFrame = netcdf.netcdf2DToFrames(resBytes)
173173

174174
val sortedTime = resFrame.rowIdx.toIndexedSeq.sorted
@@ -202,7 +202,7 @@ object data {
202202
"max_date" -> maxDate.toString
203203
)
204204
while (go) {
205-
val bytes = net.httpRequestWithRetry(baseUrl + "/sec.gov/forms", params)
205+
val bytes = net.httpRequestWithRetry(toUrl("/sec.gov/forms"), params)
206206
val p = net.OBJECT_MAPPER.readValue[List[Map[String,Any]]](bytes)
207207
p.foreach(r => lst.addOne(new SecForm(r)))
208208
offset += p.length
@@ -356,7 +356,7 @@ object data {
356356
"min_date" -> minDate.toString,
357357
"max_date" -> maxDate.toString
358358
)
359-
val dataBytes = net.httpRequestWithRetry(baseUrl + uri, params)
359+
val dataBytes = net.httpRequestWithRetry(toUrl(uri), params)
360360
netcdf.netcdf3DToFrames(dataBytes)
361361
}
362362

@@ -376,9 +376,12 @@ object data {
376376
}
377377

378378
private def baseUrl = {
379-
System.getenv().getOrDefault("DATA_BASE_URL", "http://127.0.0.1:8000")
379+
System.getenv().getOrDefault("DATA_BASE_URL", "http://127.0.0.1:8000/")
380380
}
381381

382+
private def toUrl(uri: String): String
383+
= if(baseUrl.last == '/') (baseUrl.substring(0, baseUrl.length - 1) + uri) else (baseUrl + uri)
384+
382385
private val clientToServerIdMapping = mutable.HashMap[String,String]()
383386
private val serverToClientIdMapping = mutable.HashMap[String,String]()
384387
private val idMappingFile = new File("id-translation.csv")

0 commit comments

Comments
 (0)