Onshore firm swings to profit as prices rise