protected double SparseWorldRemap(double coord)
{
long ticks = (long)coord;
long whole_days = ticks / TimeSpan.TicksPerDay;
long ticks_in_last_day = ticks % TimeSpan.TicksPerDay;
long full_weeks = whole_days / 7;
long days_in_last_week = whole_days % 7;
if (days_in_last_week >= 5)
{
days_in_last_week = 5;
ticks_in_last_day = 0;
}
if (ticks_in_last_day < startTradingTime_) ticks_in_last_day = startTradingTime_;
else if (ticks_in_last_day > endTradingTime_) ticks_in_last_day = endTradingTime_;
ticks_in_last_day -= startTradingTime_;
long whole_working_days = (full_weeks * 5 + days_in_last_week);
long working_ticks = whole_working_days * tradingTimeSpan_;
long new_ticks = working_ticks + ticks_in_last_day;
return (double)new_ticks;
}