Introduced the concept of combinedBalance holding the balance of all accounts #359
No reviewers
Labels
No labels
blocked
breaking
bug
dependencies
duplicate
enhancement
good first issue
help wanted
question
tech debt
testing
wontfix
No milestone
No project
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set.
Reference
scion/arbitrader!359
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bankroll"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Storing this as a single
BigDecimalis going to be difficult to maintain over time. I'd suggest storing aBigDecimalon eachExchangewith that exchange's last known balance, then when you need the combined value go through and add them together.(I'm sure there's a fancy way to add the BigDecimals together as part of the stream operation but it's not coming to me.)
This way each time we query for a balance it simply replaces the old value instead of applying a change to the combined value. It should be less likely to become inaccurate due to rounding errors and stuff like that over time.
And actually it occurs to me as I'm writing this that we already have an
ExchangeBalanceCachethat would be a perfect home for the "add them all together" method because it should already have all the last known balances for all the exchanges in it.@ -413,1 +413,4 @@exchangeService.updateCombinedBalance(profit);LOGGER.info("Profit calculation: ${} - ${} = ${} | Current bankroll: ${}",updatedBalance,If we're going to call the variable
combinedBalancethe comments and log messages should probably refer to it by that name as well.@ -102,3 +102,4 @@BigDecimal combinedBalance, BigDecimal exitTarget,boolean isForceExitPosition, boolean isActivePositionExpired) {final String exitSpreadString = String.format("Exit spread: %s\nExit spread target %s\n", spread.getOut(), exitTarget);I detect that this code is problematic. According to the Bad practice (BAD_PRACTICE), FS: Format string should use %n rather than n (VA_FORMAT_STRING_USES_NEWLINE).
This format string includes a newline character (\n). In format strings, it is generally preferable to use %n, which will produce the platform-specific line separator.
I will close this PR for now. Maybe I will come back to this topic in the future.