Skip to content

Commit

Permalink
Undid some of perf optimizations since require extra code to synchron…
Browse files Browse the repository at this point in the history
…ize. Will later have to check if there are no good alternatives for append-only lists.
  • Loading branch information
jbaron committed Aug 11, 2023
1 parent ebfadde commit fef0adc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/dokka/roboquant-xchange.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The roboquant-xchange module contains the additional functionality to integrate

# Package org.roboquant.xchange

Use the XChange library to access most leading crypto exchange in the world.
Wrapper classes for the XChange library that access most leading crypto exchange in the world. There are wrapeprs for brokers, historic feeds and live feeeds.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.roboquant.strategies.EMAStrategy


fun main() {
val server = WebServer("test", "secret")
val server = WebServer("test", "secret", 8081)
val feed = RandomWalkFeed.lastYears(20)
feed.delay = 100L
val jobs = ParallelJobs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.roboquant.brokers.sim.execution

import org.roboquant.backtest.mutableSynchronisedListOf
import org.roboquant.brokers.Account
import org.roboquant.brokers.Position
import org.roboquant.brokers.Trade
Expand Down Expand Up @@ -49,7 +48,7 @@ class InternalAccount(var baseCurrency: Currency) {
/**
* The trades that have been executed
*/
var trades = mutableSynchronisedListOf<Trade>()
var trades = mutableListOf<Trade>()

/**
* Open orders
Expand All @@ -60,7 +59,7 @@ class InternalAccount(var baseCurrency: Currency) {
* Closed orders. It is private and the only way it gets filled is via the [updateOrder] when the order status is
* closed.
*/
private var closedOrders = mutableSynchronisedListOf<OrderState>()
private var closedOrders = mutableListOf<OrderState>()

/**
* Total cash balance hold in this account. This can be a single currency or multiple currencies.
Expand All @@ -86,8 +85,8 @@ class InternalAccount(var baseCurrency: Currency) {
internal fun removeClosedOrdersAndTrades() {
// Create new instances since clear() could impact previously returned
// accounts since they contain sub-lists of the closedOrders and trades.
closedOrders = mutableSynchronisedListOf()
trades = mutableSynchronisedListOf()
closedOrders = mutableListOf()
trades = mutableListOf()
}

/**
Expand All @@ -96,8 +95,8 @@ class InternalAccount(var baseCurrency: Currency) {
fun clear() {
// Create new instances since clear() could impact previously returned
// accounts since they contain sub-lists of the closedOrders and trades.
closedOrders = mutableSynchronisedListOf()
trades = mutableSynchronisedListOf()
closedOrders = mutableListOf()
trades = mutableListOf()

lastUpdate = Instant.MIN
openOrders.clear()
Expand Down Expand Up @@ -182,10 +181,9 @@ class InternalAccount(var baseCurrency: Currency) {
baseCurrency,
lastUpdate,
cash.clone(),
trades.subList(0, trades.size),
trades.toList(),
openOrders.values.toList(),
closedOrders.subList(0, closedOrders.size),
// closedOrders.toList(),
closedOrders.toList(),
portfolio.values.toList(),
buyingPower
)
Expand Down

0 comments on commit fef0adc

Please sign in to comment.