How can i model a Power to Hydrogen model which sells excess electricity in Pypsa?

Hello,
I was trying to model a system which produces Hydrogen via electrolysis, from wind and solar generators. The capacity of the generators are fixed. The only Load is the Hydrogen demand. There is no electricity demand.

PyPSA Network
Components:

  • Bus: 2 - electricity,hydrogen
  • Carrier: 6
  • Generator: 3 - wind,solar,sales
  • Link: 1- electrolysis
  • Load: 1- hydrogen demand
  • Store: 1- hydrogen store
    Snapshots: 8760

I want the excess electricity produced in the system to be sold at the market price:

How do i model this sale of electricity. The only solution i could come up with after going through the pypsa documentation was to model a gnerator as shown below:

n.add(
    "Generator",
    "sales",
    bus="electricity",
    p_max_pu=0,
    p_min_pu=-1,
    p_nom=22,#MW random value which is higher than total generation capacities
    marginal_cost=ts.prices, #spot market price
    carrier='prices'
)

I got a negative objective function- which i assumed is due to the revenue obtained from the (generator)-sales of electricity.

a) How accurate is this way?
b) Is there any other way to model the above system?