refactored code to correctly merge market data with itself for close before and open after dates