Running a complex query for every date in a range
I would use select distinct on instead of window function, then just join the days.

select 
    distinct on (date, client_id) date, 
    id 
from orders
inner join generate_series('2015-07-18'::date, '2015-07-19'::date, '1 day') date
  on start_date &lt;= date and (end_date is null or date &lt;= end_date)
order by date, client_id, order_type desc


http://sqlfiddle.com/#!15/5a420/16/0

I can elaborate more if something is not clear.