Skip to content

Commit

Permalink
Fixed Alpaca broker bug for loading existing orders
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaron committed Jun 18, 2024
1 parent 706fc03 commit ce3a957
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class AlpacaBroker(
private fun syncOrders() {
_account.orders.forEach {
if (it.open) {
// println("orderid=${it.order.id}")
val orderId = UUID.fromString(it.order.id)
val alpacaOrder = alpacaAPI.trader().orders().getOrderByOrderID(orderId, false)
logger.debug { "open order id=$orderId alpaca-order=$alpacaOrder" }
Expand Down Expand Up @@ -209,7 +210,7 @@ class AlpacaBroker(
OrderType.TRAILING_STOP -> TrailOrder(asset, Size(qty), order.trailPercent!!.toDouble())
else -> throw UnsupportedException("unsupported order type for order $order")
}

rqOrder.id = order.id ?: throw UnsupportedException("Unsupported order $order because no known id")
return rqOrder
}

Expand Down
7 changes: 2 additions & 5 deletions roboquant/src/main/kotlin/org/roboquant/Roboquant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ data class Roboquant(
val broker: Broker = SimBroker()
) {


private val kotlinLogger = Logging.getLogger(Roboquant::class)

private val logger = Logging.getLogger(Roboquant::class)

init {
kotlinLogger.debug { "Created new roboquant instance=$this" }
logger.debug { "Created new roboquant instance=$this" }
}

/**
Expand Down Expand Up @@ -139,7 +137,6 @@ data class Roboquant(

}


/**
* Blocking version of runAsync
*/
Expand Down

0 comments on commit ce3a957

Please sign in to comment.