Heat the rapeseed oil and butter in a large saucepan. Add the onions and sugar and stir until well coated in the butter.
Reduce the heat and cook the onions for 10 minutes, stirring occasionally, until soft and just beginning to caramelise. Pour in the red wine, vinegar and port, add the rosemary and season with sea salt and black pepper. Simmer for 10 minutes until the onions are completely soft.
Remove from the heat, discard the rosemary sprigs and allow to cool.
Use immediately or seal in sterilised jars. The jam will keep in the fridge for 2 weeks.