There is a functional support in the standard to get the End date filled on trade agreements. For that reason, I never considered a x++ script myself.
You can create a new trade agreement journal; retrieve active price agreements with a correction function; edit details and then update by posing the journal.