First of all, your system will be subjected to front-running in both cases, since by the time the oracle price is updated in the blockchain, everybody already knows what the market price is.
So you may want to consider using an oracle to begin with.
As with regards to "average vs median", which is a general issue in mathematics and in finance (not specific to oracles):
Within the context of your question, the general goal of using a median is to mitigate the impact of spikes.
For example, suppose the samples are [10^1, 10^2, ..., 10^9, 10^30] (not necessarily in that order).
As you can see, the average here - greatly impacted by that "10^30" spike - is larger than 10^29.
The median, on the other hand, is 10^5 or 10^6 (or something in between, depending on how you choose handle an even number of samples).
Thus, using a median in this specific scenario can help mitigating the impact of that "unusual" spike.
More generally, use median when the number of samples is very small in comparison with the range of the samples.