Solver Rules & Logic

Overall aims:

  • Minimize net interest payments and transaction costs
  • Avoid speculation: Don't do anything that create unneeded FX risks (losses or gains from moving FX rates)
  • Avoid exceeding borrowing limits per bank

The 12 Corporate Treasury Guidelines

Same Currency-Netting

  • Example

    Surplus EUR on one account and overdraft EUR on another account.

  • 1

    Do transfer between same-currency accounts freely.

    Does not create FX risk.

  • 2

    Do transfer between same-currency accounts before performing any FX trades.

    Prioritizes cost-free liquidity over market transactions.

Structural Surpluses or Deficits

  • Example

    Accumulated a positive foreign currency balance (for example PLN) we don't need due consistent positive future cash flow in that currency.

  • 3

    Do not hold a surplus foreign currency balance just to earn a high interest rate.

    Maintains risk that the foreign currency decreases in value.

  • 4

    Do sell surplus foreign currency to cover structural deficits in other foreign currencies.

    Minimizes net exposure across the portfolio.

  • 5

    Or, do sell surplus foreign currency to repay debt in the home currency.

    Minimizes risk and reduces interest expense.

  • Example

    Accumulated a negative foreign currency balance (for example SEK) that we don't think we will cover by a positive future foreign currency cash flow.

  • 6

    Do not keep a foreign currency balance negative just because it is 'cheap funding.'

    Maintains risk that the foreign currency increases in value.

  • 7

    Do buy foreign currency using structural surpluses in other foreign currencies.

    Uses existing liquidity to neutralize risk.

  • 8

    Or, do buy foreign currency using home currency.

    Minimizes risk on foreign currencies.

Timing Mismatches Based on a Forecast

  • Example

    Borrowing in NOK but expect an incoming NOK payment in 5 days covering the borrowing. Have positive USD cash in the period, but expect an equivalently large payment in USD in 5 days. In reality, this is a very rare scenario.

  • 9

    Do not perform a spot trade to cover a temporary gap if you must reverse the trade later.

    Bets that the FX rate won't move; by the second transaction, the market may have moved against you.

  • 10

    Do use an FX Swap to bridge a forecasted gap, matching the swap duration to the cash flow.

    Covers the liquidity hole without creating a position exposed to moving FX rates.

  • Example

    Borrowing in NOK but expect an incoming NOK payment in 5 days covering the borrowing. Don't have 'timing mismatch' positive balances in other foreign currencies.

  • 11

    Do not use an FX swap between two foreign currencies unless there is a matching timing mismatch in both.

    Swapping two foreign currencies without matching offsets creates unnecessary secondary risk.

Carry Trade

  • Example

    Borrowing rate in DKK is 3%, deposit rate in PLN is 5%.

  • 12

    Do not trade to take advantage of interest rate differentials; trade only for actual operational needs.

    This is pure speculation; a small move in the FX rate can wipe out an entire year of interest earnings.

How the Solver Covers These Rules

Cost Minimization (Rules 1, 2, 4, 5, 7, 8)

The solver’s objective function minimises the total net financial cost: interest paid − interest earned + transaction costs + FX spreads + RCF costs + speculation penalties. This naturally drives the solver towards cost-optimal decisions.

Same-currency netting is always preferred because its variable cost (Variable_Cost_Same_CCY) is orders of magnitude lower than the FX spread (FX_Spread_Percentage). The solver will exhaust all same-currency netting opportunities before turning to FX trades.

Interest rates are modelled exactly per account, using Risk_Free_Rate + Borrowing_Margin for overdrafts and Risk_Free_Rate − Deposit_Margin for surpluses. This ensures the solver never moves money to a worse-rate account just to “balance” positions.

Example: Acc_Low earns 5% on deposits, Acc_High earns only 1%. Even though both are in the same currency, the solver correctly decides not to transfer surplus from Low to High, because it would destroy 4% of interest income.

Anti-Speculation & Dual-Sided Exemption (Rules 3, 6, 12)

Holding non-safe currency balances is penalised at Anti_Speculation_Penalty_Rate per day, applied to any “speculative” portion of the balance. The penalty applies to both sides: speculative surpluses (holding currency for yield) and speculative overdrafts (borrowing cheap currency). On the final day of the horizon, the penalty is multiplied by Terminal_Penalty_Multiplier to strongly discourage leaving open positions.

Dual-Sided Exemption: Not all non-safe balances are speculative. The solver looks ahead at the forecast to determine what’s genuinely needed:

Pre-Funding Exemption (Long Side): If the forecast shows a future deficit, holding surplus today to cover it is exempt. The exempt amount equals the maximum future deficit for that currency.

Structural Deficit Exemption (Short Side): If the forecast shows a future surplus (e.g., incoming payment), running an overdraft today is exempt. The exempt amount equals the maximum future surplus.

Swap Transparency: Active FX Swaps are “undone” before assessing speculation. Since swaps are temporary and self-reversing, their cash flows don’t change the structural assessment — only permanent positions are evaluated.

“Safe” Currencies (marked Is_Safe) are completely exempt from speculation penalties. Typically the base currency (DKK) and hub currencies (EUR) are safe.

Example — Penalised: The solver buys 10M SEK with no future SEK payment expected. The SEK position is speculative — penalised daily, and heavily penalised on the last day.

Example — Exempt: The solver buys 10M NOK on Day 0 because a 15M NOK payment is due on Day 5. The 10M NOK position is pre-funding a known deficit — fully exempt from penalty.

Wash Trade Protection (Rule 9)

A sliding window constraint prevents the solver from moving money in one direction between two accounts and then reversing it within Wash_Trade_Window_Days days. This applies to all movement types: FX Spots, FX Swap legs, and same-currency transfers.

How it works: For every pair of accounts (A, B), if any movement A→B occurs on day t, then all movements B→A are blocked on days [t, t + window]. The reverse also applies: B→A on day t blocks A→B for the same window.

Swap Exception: A swap’s own reversal leg is excluded from the window check. If a swap sends PLN→EUR on Day 0 and reverses EUR→PLN on Day 11, the far leg is not blocked by the near leg — they are part of the same trade.

Example — Blocked: With a 4-day window: the solver sells 5M SEK→DKK on Day 0. It cannot buy SEK back (DKK→SEK) until Day 5 at the earliest. This prevents pointless round-tripping that wastes transaction costs.

Example — Allowed: Sell SEK→DKK on Day 0, then buy SEK (DKK→SEK) on Day 7. The 4-day window has passed, so a new trade in the reverse direction is permitted.

FX Swaps & Overlapping Trade Ban (Rule 10)

FX Swaps bridge short-term timing mismatches by temporarily exchanging one currency for another and reversing on a future date. The solver models this with a Near Leg (Day t) and a Far Leg (Day t+k), where k is the swap tenor in days.

Forward Points: Swap economics include interest rate differentials (CIRP). If you swap from a high-rate currency to a low-rate currency, you earn forward points. The solver accounts for this as (rate_destination − rate_source) × tenor/360.

Overlapping Trade Ban: While an FX Swap is active between two accounts (A ⇔ B), no new FX Spots or new FX Swaps can be initiated between those same accounts. This prevents the solver from layering contradictory positions on the same currency pair.

Configurable Limits: Swaps are subject to Max_Swap_Start_Day (latest day a swap can originate) and Max_Swap_Tenor_Days (maximum duration).

Example — Blocked: A PLN⇔EUR swap is active from Day 0 to Day 11. On Day 5, the solver cannot execute a new PLN→EUR spot or start a new PLN⇔EUR swap — it must wait until the existing swap settles.

Example — Allowed: A PLN⇔EUR swap is active from Day 0 to Day 5. On Day 6 (after settlement), a new EUR→PLN spot is allowed because no swap is active anymore.

RCF Integration & Funding

Revolving Credit Facilities (RCFs) are fully integrated as an alternative funding source. The solver can draw from RCFs to cover deficits, and the cost is modelled as Risk_Free_Rate + Interest_Margin on utilisations plus a Commitment_Fee on the total facility limit (paid regardless of usage).

Constraints: RCF draws are subject to a Limit Amount (maximum outstanding at any time) and Max Utilisations (maximum number of active tranches simultaneously). The solver automatically rolls over maturing RCF tranches when beneficial.

Settlement: RCF draws settle into designated Is_RCF_Settlement_Account accounts. The solver chooses between RCF drawdowns and FX trades purely based on which minimises total cost.

Example: On Day 3, a 215M DKK RCF tranche matures. The solver repays it and immediately re-draws 542M DKK at the same rate, rolling the facility to cover the upcoming cash needs. This is cheaper than selling foreign currency and paying FX spreads.

Example: The solver needs 50M EUR. It compares: (a) draw from the DKK RCF at 4.85% and convert DKK→EUR, vs. (b) leave the EUR overdraft at 3.9%. If the RCF route’s interest + FX spread exceeds the overdraft cost, it chooses the overdraft.

Overdraft Funding Restrictions (Rule 11)

The solver is explicitly banned from opening FX Spots or FX Swaps if the source account is in overdraft, unless the source currency is “safe” (e.g., DKK or EUR). This prevents the solver from funding speculative FX trades by deepening an overdraft in a volatile currency.

How it works: For each FX trade, the solver checks if the source account has a negative balance on that day. If it does, the trade is blocked. Technically, this is enforced by constraining the overdraft component (neg_bal) to be zero whenever a trade binary is active: neg_bal ≤ M × (1 − trade_binary).

Safe Currency Exemption: DKK and EUR (or any currency marked Is_Safe) are exempt. It is acceptable for the solver to run a DKK overdraft to fund a DKK→SEK spot, because DKK is the home currency with no FX risk.

Example — Blocked: Danske Bank-PLN has a -2M PLN balance. The solver cannot initiate a PLN→EUR swap from this account because it would be funding FX exposure with borrowed PLN, creating double risk (FX + interest).

Example — Allowed: Danske Bank-DKK has a -50M DKK balance. The solver can still initiate DKK→SEK spot because DKK is the base currency — the overdraft is funded at the known RCF/bank rate with no FX risk.

Structural Account Restrictions

Non-hub accounts (those with currencies not marked Is_Safe) are constrained to be either strict Receivers or strict Senders of FX Spots over the entire horizon. The solver creates a binary variable per account that locks its FX direction for all days.

Why: Without this rule, the solver could use non-hub accounts as intermediary hubs — buying FX into PLN from one currency and selling it to another. This creates unnecessary FX exposure and transaction costs that a senior treasurer would never approve.

Hub Exemption: Safe-currency accounts (DKK, EUR) are exempt because they naturally act as liquidity concentrators — they receive from some accounts and distribute to others.

Example — Blocked: Danske Bank-PLN receives a DKK→PLN spot (FX In). The same account cannot also execute a PLN→SEK spot (FX Out) at any point in the horizon. PLN must remain a “Receiver” of FX for the entire period.

Example — Allowed: Danske Bank-DKK receives SEK→DKK and also sends DKK→NOK. DKK is a safe hub currency, so it can act as a concentrator freely.

Structural Balance Gate (Pre-Funding Protection)

Prevents “buy-and-swap” patterns where foreign currency is purchased solely to route it through a swap for profit, rather than to cover a genuine operational need. The gate uses the baseline forecast (before any solver decisions) to determine whether a non-safe currency has genuine structural surplus:

FX Spot Outflows: Blocked entirely if the minimum future baseline balance for the currency (from day t to the end of the horizon) is negative. If the currency is forecasted to go into deficit at any point in the future, no permanent FX outflows are allowed — the solver should hold the balance to cover the coming deficit, not sell it.

FX Swap Near Legs: Unlike spots, swaps are temporary and self-reversing. A swap is exempt from the gate if the baseline balance stays non-negative during the active days of the swap tenure (from near leg up to, but not including, the far leg). This means a genuine temporary surplus can be deployed via a short-term swap. However, the swap volume is capped at the minimum baseline balance during the active tenure — you can only swap what you genuinely have, preventing a trivially positive baseline (e.g. +1 unit) from unlocking a full-size swap.

Example — Blocked: PLN baseline is always negative (-300K to -3M). The solver cannot buy PLN via spot and immediately route it through a PLN→EUR swap, because the baseline never supports outflows.

Example — Allowed: PLN has a genuine +5M surplus for 7 days before turning negative. A 5-day swap deploying up to 5M PLN is allowed because the baseline stays positive during the entire swap tenure.