Product: Gainium DCA bot (also affects the Combo bot — shared DCA engine)
Area: Safety-order volume → “Required changed based on” (dcaVolumeRequiredChangeRef)
Severity: Functional — the UI offers an option the engine silently ignores (falls back to another mode)
Summary
When DCA volume is set to “Required change” mode, the “Required changed based on” dropdown offers three values: Take Profit, Average price, and Breakeven. The engine only implements two of them. Breakeven is never handled and silently falls into the Take-Profit branch — so Breakeven == Take Profit. Selecting Breakeven has no effect on safety-order sizing.
Expected behavior
When Breakeven is selected, each safety order should be sized to deploy the maximum available DCA volume (the “Max volume per DCA” field, dcaVolumeMaxValue) in order to pull the average entry as close to the current price (i.e. break-even) as that cap allows.
In this mode the “Required change” field is meaningless — there is no target %, only the volume capped by “Max volume per DCA”. The “Required change” field should therefore be hidden/ignored when Breakeven is selected.
(Rationale: an average exactly equal to the current price would require infinite volume, so “Breakeven” is best defined as the finite approximation — deploy as much volume as the cap permits.)
Actual behavior
- The
DcaVolumeRequiredChangeRefenum only containstpandavg— there is nobreakevenvalue. - The volume calculation branches only on
avg; everything else (includingbreakevenandtp) falls into theelsebranch, which sizes the order so the take-profit price reaches the required-change %. So Breakeven inherits the exact TP sizing. - The order-form preview uses the same two-way branch, so the preview shows the same wrong (TP) sizes.
- A strict config validator would also reject
breakeven, since the value isn’t part of the enum.
Steps to reproduce
- Create a DCA bot; set DCA volume based on → Required change.
- Set Required changed based on → Breakeven.
- Set Required change and Max volume per DCA to any values.
- Check the order preview / backtest: the safety-order sizes are identical to Take Profit. Max volume per DCA is not used as the target, and Required change still drives the size exactly as in TP mode.
Root cause
The third dropdown value (breakeven) is not represented in the data model (enum), the engine, the preview, or the validator. There is no dedicated calculation branch for Breakeven, so it defaults to the Take-Profit formula.
Suggested fix
- Add the enum value
breakeven = 'breakeven'toDcaVolumeRequiredChangeRef(both the backtester types and the frontend types). - Engine branch: when
breakeven, set the order size to Max volume per DCA (dcaVolumeMaxValue); if no cap is set, fall back to the base order size. Skip the percentage formula and the quote conversion (the cap is already expressed in the order-size unit). - Preview: apply the same branch in the order-preview code so the preview matches the engine.
- Validator: accept
breakevenas a valid value. - UI: hide the “Required change” field when Breakeven is selected; add a tooltip on “Required changed based on” explaining all three modes.
Net effect
Breakeven becomes a genuine third mode (“deploy max allowed volume to get closest to break-even”), and the now-redundant “Required change” field is no longer required in that mode.
