anchor.diff:          Real: SymbolAmountMap;
           Basis: SymbolAmountMap;
       }
  +
  +    [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
  +    module RealAndBasisAmounts =
  +
  +        let addAccountBalanceBalances (amounts : RealAndBasisAmounts) (accountBalance : AccountBalance) : RealAndBasisAmounts =
  +            let realBalances = List.fold SymbolAmountMap.add amounts.Real accountBalance.Balance
  +            let basisBalances =
  +                match accountBalance.Basis with
  +                | Some basis -> List.fold SymbolAmountMap.add amounts.Basis basis
  +                | None       -> amounts.Basis
  +            { amounts with Real = realBalances; Basis = basisBalances }
  +
  +        let toSortedAmountLists (amounts : RealAndBasisAmounts) : Amount List * (Amount List Option) =
  +            let real = SymbolAmountMap.toSortedAmountList amounts.Real
  +            let basis = 
  +                match Map.isEmpty amounts.Basis with
  +                | true  -> None
  +                | false -> Some <| SymbolAmountMap.toSortedAmountList amounts.Basis
  +            real, basis
   
       type AccountRealAndBasisAmountsMap = Map<Account, RealAndBasisAmounts>
   
  
positive.code:     let calculateParentAccountBalances (accountBalances : AccountBalance List) : AccountBalance list =
          let addBalancesForParentAccount (accountBalance : AccountBalance) (parentAccountBalances : AccountRealAndBasisAmountsMap) (account : Account) =
              let updatedParentAmounts =
                  match Map.tryFind account parentAccountBalances with
                  | Some parentAccountAmounts ->
                      let realBalances = List.fold SymbolAmountMap.add parentAccountAmounts.Real accountBalance.Balance
                      let basisBalances =
                          match accountBalance.Basis with
                          | Some basis -> List.fold SymbolAmountMap.add parentAccountAmounts.Basis basis
                          | None       -> parentAccountAmounts.Basis
                      { parentAccountAmounts with Real = realBalances; Basis = basisBalances }
                  | None ->
                      let balances = List.fold SymbolAmountMap.add Map.empty accountBalance.Balance
                      let basisBalances =
                          match accountBalance.Basis with
                          | Some basis -> List.fold SymbolAmountMap.add Map.empty basis
                          | None       -> Map.empty
                      { Real = balances; Basis = basisBalances; }
              Map.add account updatedParentAmounts parentAccountBalances
  
          let buildParentAccountAmounts (parentAccountBalances : AccountRealAndBasisAmountsMap) (accountBalance: AccountBalance) =
  
negative.code:         |> List.fold buildParentAccountAmounts Map.empty
          |> Map.toSeq
          |> Seq.map (fun (account, amounts) ->
              let real, basis = RealAndBasisAmounts.toSortedAmountLists amounts
              {
                  Account = account;
                  Balance = real;
  