Exemplo n.º 1
0
    def _is_forex_trading_time(self, now: arrow.arrow.Arrow) -> bool:
        weekday = now.isoweekday()
        date = now.format('YYYY-MM-DD')

        if weekday <= 4:
            return True

        elif weekday == 5:
            if now < arrow.get(f'{date} 22:00'):
                return True

        elif weekday == 6:
            return False

        elif weekday == 7:
            if now >= arrow.get(f'{date} 21:00'):
                return True

        return False
Exemplo n.º 2
0
    def _is_A_shares_trading_time(self, now: arrow.arrow.Arrow) -> bool:
        weekday = now.isoweekday()
        date = now.format('YYYY-MM-DD')

        if self.env.sys_frequency == 'D':

            if weekday <= 5:
                return True

        else:

            if weekday <= 5:
                left_1 = arrow.get(f'{date} 09:30')
                right_1 = arrow.get(f'{date} 11:30')
                left_2 = arrow.get(f'{date} 13:00')
                right_2 = arrow.get(f'{date} 15:00')

                if left_1 < now < right_1 or left_2 < now < right_2:
                    return True

        return False