From 9d016b0d44498a6b4cd9b3292745f8c49c7bdc23 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Tue, 4 Jan 2022 10:34:55 +0700 Subject: [PATCH] positions: fix calculateSizeFixedCashWith: correct sizing --- src/ATrade/RoboCom/Positions.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ATrade/RoboCom/Positions.hs b/src/ATrade/RoboCom/Positions.hs index 4c6bf23..7dd3542 100644 --- a/src/ATrade/RoboCom/Positions.hs +++ b/src/ATrade/RoboCom/Positions.hs @@ -184,7 +184,7 @@ calculateSizeFixedCashWith totalCash maxPositions cfg series _ = case bsBars $ series of (lastBar:_) -> let cashPerPosition = totalCash / fromIntegral maxPositions in - truncate (cashPerPosition / (fromIntegral $ ipLotSize . bsParams $ series)) + truncate (cashPerPosition / ((toDouble $ barClose lastBar) * (fromIntegral $ ipLotSize . bsParams $ series))) _ -> 0 -- | Helper function. Finds first element in list which satisfies predicate 'p' and if found, applies 'm' to it, leaving other elements intact.