Refer to the bond pricer API to learn about the different things you can do. Here is an example to calculate the accruedInterest function. Similar you can call other functions. Hope it helps.
TkNeo’s response is a great place to start. Feel free to ask if you can’t find something. (I’d recommend starting by setting up a FixedCouponBond object to see what data it needs, and then examining the DiscountingFixedCouponBondProductPricer API to see what methods can be invoked.
Note that Strata uses decimal prices for bonds in the trade model, pricers and market data, thus a price of 99.32% is represented in Strata by 0.9932. Perhaps if you divide the clean price by 100 you will get closer?
I managed to make it work a couple of days ago but I was ‘in the zone’ and wanted to finish what I started that’s why my post only comes today…
Strata calculates the price/yield of a single bond!
I was expecting it to do it for the whole lot (par 100) (coupon above was already divided by par)
In order to get the right yield all I had to do was to divide the clean price by the par value (initialPrice in my code), then multiply the resulting yield with the par (duh)
yield: 1.9824303513080652
and back to clean 141.50500000000002
Great that you succeeded. And yes, DiscountingFixedCouponBondProductPricer is pricing one bond, while DiscountingFixedCouponBondTradePricer prices the whole trade (but exposes less methods).
Several pricing methods are involved in DiscountingFixedCouponBondProductPricer and DiscountingFixedCouponBondTradePricer. For example, dirtyPriceFromCurves in DiscountingFixedCouponBondProductPricer computes the bond price using a calibrated discounting curve, whereas the price is computed from yield to maturity by dirtyPriceFromYield in DiscountingFixedCouponBondProductPricer.