Skip to content

Commit

Permalink
Fixed bug and moved to 3.0 release preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaron committed May 5, 2024
1 parent f45a428 commit 3e98997
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/run/perf.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
* limitations under the License.
*/

@file:DependsOn("org.roboquant:roboquant-perf:2.3.0-SNAPSHOT")
@file:DependsOn("org.roboquant:roboquant-perf:3.0.0-SNAPSHOT")

org.roboquant.perf.main()
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>roboquant parent</name>
<description>Algorithmic trading platform written in Kotlin</description>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-alpaca/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-alpaca</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AlpacaBroker(
* Closed orders will be ignored all together.
*/
private fun loadExistingOrders() {
val openOrders = alpacaAPI.trader().orders().getAllOrders("OPEN", null, null, null, null, false, "", "")
val openOrders = alpacaAPI.trader().orders().getAllOrders(null, 500, null, null, null, false, "", "")
for (order in openOrders) {
logger.debug { "received open $order" }
val rqOrder = toOrder(order)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class AlpacaHistoricFeed(
fun retrieveStockPriceBars(
symbols: String,
timeframe: Timeframe,
frequency: String = "1D"
frequency: String = "1Day"
) {
val (start, end) = toOffset(timeframe)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.roboquant.alpaca

import net.jacobpeterson.alpaca.AlpacaAPI
import net.jacobpeterson.alpaca.openapi.trader.model.OrderSide
import net.jacobpeterson.alpaca.openapi.trader.model.OrderType
import net.jacobpeterson.alpaca.openapi.trader.model.PostOrderRequest
import org.roboquant.common.AssetType
import org.roboquant.common.UnsupportedException
Expand Down Expand Up @@ -71,9 +72,19 @@ internal class AlpaceOrderPlacer(private val alpacaAPI: AlpacaAPI, private val e
.timeInForce(tif)
.extendedHours(extendedHours)

if (order is LimitOrder) {
result.limitPrice(order.limit.toString())
}
when (order) {

is LimitOrder -> {
result.type(OrderType.LIMIT)
result.limitPrice(order.limit.toString())
}

is MarketOrder -> result.type(OrderType.MARKET)

else -> throw UnsupportedException("unsupported ordertype $order")

}

return result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,24 @@ internal class AlpacaSamples {
val events = feed.toList()

with(events) {
println("events=$size start=${first().time} last=${last().time}")
println("events=$size start=${first().time} last=${last().time} symbols=${feed.assets.symbols.toList()}")
}

}

@Test
@Ignore
internal fun alpacaHistoricFeed3() {

val feed = AlpacaHistoricFeed()

// We get minute data
val tf = Timeframe.parse("2024-01-04", "2024-01-05")
feed.retrieveStockPriceBars("AAPL", timeframe = tf, "1Min")
val events = feed.toList()

with(events) {
println("events=$size start=${first().time} last=${last().time} symbols=${feed.assets.symbols.toList()}")
}

}
Expand All @@ -120,7 +137,7 @@ internal class AlpacaSamples {
@Ignore
internal fun singleOrder() {
val broker = AlpacaBroker {
extendedHours = true
extendedHours = false
}
val order = MarketOrder(Asset("IBM"), Size.ONE)
broker.place(listOf(order))
Expand Down
2 changes: 1 addition & 1 deletion roboquant-alphavantage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-alphavantage</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-avro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-avro</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-binance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-binance</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-charts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-charts</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-ibkr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-ibkr</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-jupyter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-jupyter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-ml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-ml</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-perf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-perf</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-polygon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-polygon</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions roboquant-questdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-questdb</artifactId>
Expand Down Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>org.roboquant</groupId>
<artifactId>roboquant</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-server</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-ssr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-ssr</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-ta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-ta</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-tiingo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-tiingo</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant-xchange/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant-xchange</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion roboquant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>roboquant-parent</artifactId>
<groupId>org.roboquant</groupId>
<version>2.3.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>roboquant</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class MultiRunJournal(private val fn: (String) -> MetricsJournal) {
return journals.getValue(run)
}

fun getRuns() = journals.keys.toList()

fun getMetric(name: String) : Map<String, TimeSeries> {
return journals.mapValues { it.value.getMetric(name) }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.roboquant.journals

import org.roboquant.common.years
import org.roboquant.run
import org.roboquant.feeds.random.RandomWalkFeed
import org.roboquant.metrics.AccountMetric
import org.roboquant.strategies.EMAStrategy
import kotlin.test.Test
import kotlin.test.assertEquals


internal class MultiRunJournalTest {

@Test
fun basic() {
val feed = RandomWalkFeed.lastYears(5)
val mrj = MultiRunJournal {
MetricsJournal(AccountMetric())
}
val tfs = feed.timeframe.split(1.years)
for (tf in tfs) {
run(feed, EMAStrategy(), mrj.getJournal(tf.toString()), timeframe=tf)
}

assertEquals(tfs.size, mrj.getRuns().size)

}
}

0 comments on commit 3e98997

Please sign in to comment.