We have investigated the effects of temperature, pressure and metal composition on the metal-silicate partitioning of V, Cr, Ni, Co, Mn, Nb, W, Ga, P and Si in order to refine the 'deep magma ocean' model of core formation. Interactions in the liquid metal were accounted for by using metallurgical data while temperature effects were calculated using free energy data for liquid metals and liquid oxides. This approach enabled us to separate pressure effects from those of the other two variables. Mantle concentrations of the refractory elements can be well-matched by single-stage core segregation at 3750K and a pressure of 40 GPa. The calculated temperature is, however, 800 degrees above the peridotite liquidus at 40 GPa, and is therefore physically implausible. The base of the magma ocean, at which metal would pond during accretion must be saturated in crystals and should, therefore lie close to the liquidus. We find that dynamic accretion models, in which pressure increased as the earth grew, do not improve the match to the peridotite liquidus so long as the oxygen fugacity is fixed by the current Fe content of the mantle. If, however, we force temperature to lie on the peridotite liquidus as the earth grew, the mantle concentrations of refractory elements can be matched provided oxygen fugacity increased during accretion. To illustrate this we use accretionary models in which, as the earth grew, the base of the magma ocean was at half the mantle depth and applied gradual or step-changes in oxygen fugacity. If we apply a 2 log unit increase in oxygen fugacity, the siderophile element contents of the mantle are matched, the Si content of the core is about 5 weight per cent and the average core segregation temperature is 2800K, within the experimental range. Oxidation during accretion is an important component of heterogeneous accretion models, but the mechanisms proposed are generally untestable. Here we propose that an increase in oxidation state is a natural consequence of the size of the earth. Magnesium silicate perovskite is the principal phase in the earth's lower mantle. This phase forces the disproportionation of ferrous iron into ferric iron plus metal. When perovskite started to grow at the base of the magma ocean, dissolution and reprecipitation acted as an `oxygen pump' injecting oxidized ferric iron into the upper mantle. As the earth continued to grow, infalling metal was oxidized by the ferric iron into ferrous iron, raising the iron content of the magma ocean and the oxygen fugacity of metal-silicate equilibration. This process did not occur to any great extent on Mars because of the limited stability of perovskite in the smaller planet.