Automatically compute fixing date for a swap contract

Hello everyone.
I’m trying to model a swap contract on Strata and in the process of understanding if I can use the Strata class model for my purpose. I am able to create a swap contract with a fixed and floating leg, computing the accrual periods, but I’m having a hard time figuring how to compute the fixing date for the swap contract. Say I want it to be two days before the accrual period (which is of say 3 months). Is there a way with the Strata swap contract class model to return an array of fixing date given the accrual period size, the length of the contract, the calendar, etc.?


With Strata, you create a SwapTrade describing the trade, and then call resolve(refData) to get a ResolvedSwapTrade. The resolved trade has the dates resolved (using the holiday calendar data passed in). Thus you can access each payment period, and if you drill down you can find the fixing dates.
See also the last part of this page.

Thank you so much for your reply. I tried to dig a bit into the structures you suggested to use. I found that I can get a SwapTrade by using the .of() method of the class and passing the Swap object I already created that contains both the fixed and floating SwapLegs.
The problem I encountered is that to create the mentioned SwapTrade object that method also needs a TradeInfo object, which to be built it requires some parameters that (as it appears to me) are related to a single “trade” rather than to the entire Swap. Is that right? Should I create a TradeInfo object for each settlement? It doesn’t make much sense to me though…
Thank you.

TradeInfo refers to the details of the trade that took places between two counterparties. Thus there is a trade ID and a trade date/time. It is permitted to use TradeInfo.empty() which might better suit your use case.

Thank you very much. I managed to find that and compute the fixing dates but it seems I have something wrong in some of the computations I feed to my backend.
I show the code first:

    final Swap swap = Swap.of(strataSwapLegs);
    TradeInfo tradeInfo = TradeInfo.empty(); 
    SwapTrade swapTrade = SwapTrade.of(tradeInfo, swap); 
    ReferenceData refData = ReferenceData.standard(); 
    ResolvedSwapTrade resolved = swapTrade.resolve(refData);
    ResolvedSwap resolvedSwap = resolved.getProduct();

As you suggested I created a TradeInfo object which is empty. And that seem to work since I have no more info about the trade and just the one I already fed to the Swap object.
It seems, though, that refData created that way contains some data which is confusing to the resolved Swap. Is that the correct way to feed ReferenceData? Why would the TradeInfo need ReferenceData if all the data (that seem to be contained in ReferenceData) is already inside my Swap object?

Thank you very much!

The code above looks fine to me. ReferenceData contains the information about holidays that is necessary to resolve it. For example, to resolving a swap involves calculating and validating the schedule, ie. turning a start date, end date and frequency into a list of calculation periods.

Well, thank you very much. Then my issue is somewhere else to be sought. Anyway, managed to get fixing dates out so not gonna continue this topic. Thanks again for the very very helpful support.