Market on close function

Not yet added to API but please review