Time Frame Bars Question

Dustin_LangDustin_Lang Posts: 25
edited March 2017 in FAQs

How are higher time frame bars accessed (i.e. 5 minute, 15 minute, etc.)?

Comments

  • shayneshayne Posts: 70
    edited August 2016
    bar_05 = md.bar.minute( start=-100, bar_size=5 )
    bar_15 = md.bar.minute( start=-100, bar_size=15 )
    
    
    from cloudquant.interfaces import Strategy
    import itertools
    
    class ServiceWriteFile(Strategy):
        @staticmethod
        def in_symbol_universe(symbol, md, service):
            return symbol == 'JNJ'
    
        def print_highs(self, service, bar):
            for time, high in itertools.izip(bar.timestamp,bar.high):
                print( '{}\t{:.2f}'.format(service.time_to_string(time, '%H:%M:%S.%f'), high) )
    
        def on_start(self, md, order, service, account):
            print( service.time_to_string( service.system_time ) )
    
            print( '\n\n1 minute bars\n' )
            self.print_highs( service, bar = md.bar.minute(start=-100) )
    
            print( '\n\n5 minute bars\n' )
            self.print_highs( service, bar = md.bar.minute(start=-100, bar_size=5) )
    
            print( '\n\n15 minute bars\n' )
            self.print_highs( service, bar = md.bar.minute(start=-100, bar_size=15) )
    
            service.terminate()
    
    
    2016-02-16 15:59:59.676000
    
    
    1 minute bars
    
    14:19:00.000000 102.17
    14:20:00.000000 102.20
    14:21:00.000000 102.19
    14:22:00.000000 102.27
    14:23:00.000000 102.29
    14:24:00.000000 102.28
    14:25:00.000000 102.32
    14:26:00.000000 102.32
    14:27:00.000000 102.23
    14:28:00.000000 102.25
    14:29:00.000000 102.30
    14:30:00.000000 102.32
    14:31:00.000000 102.31
    14:32:00.000000 102.32
    14:33:00.000000 102.35
    14:34:00.000000 102.30
    14:35:00.000000 102.33
    14:36:00.000000 102.32
    14:37:00.000000 102.31
    14:38:00.000000 102.28
    14:39:00.000000 102.27
    14:40:00.000000 102.29
    14:41:00.000000 102.31
    14:42:00.000000 102.31
    14:43:00.000000 102.32
    14:44:00.000000 102.36
    14:45:00.000000 102.34
    14:46:00.000000 102.33
    14:47:00.000000 102.32
    14:48:00.000000 102.31
    14:49:00.000000 102.24
    14:50:00.000000 102.20
    14:51:00.000000 102.20
    14:52:00.000000 102.20
    14:53:00.000000 102.17
    14:54:00.000000 102.15
    14:55:00.000000 102.17
    14:56:00.000000 102.14
    14:57:00.000000 102.10
    14:58:00.000000 102.08
    14:59:00.000000 102.10
    15:00:00.000000 102.13
    15:01:00.000000 102.16
    15:02:00.000000 102.16
    15:03:00.000000 102.17
    15:04:00.000000 102.18
    15:05:00.000000 102.11
    15:06:00.000000 102.12
    15:07:00.000000 102.08
    15:08:00.000000 102.06
    15:09:00.000000 102.07
    15:10:00.000000 102.13
    15:11:00.000000 102.10
    15:12:00.000000 102.09
    15:13:00.000000 102.15
    15:14:00.000000 102.18
    15:15:00.000000 102.20
    15:16:00.000000 102.19
    15:17:00.000000 102.20
    15:18:00.000000 102.16
    15:19:00.000000 102.14
    15:20:00.000000 102.11
    15:21:00.000000 102.16
    15:22:00.000000 102.16
    15:23:00.000000 102.17
    15:24:00.000000 102.16
    15:25:00.000000 102.23
    15:26:00.000000 102.27
    15:27:00.000000 102.30
    15:28:00.000000 102.31
    15:29:00.000000 102.35
    15:30:00.000000 102.34
    15:31:00.000000 102.33
    15:32:00.000000 102.34
    15:33:00.000000 102.32
    15:34:00.000000 102.30
    15:35:00.000000 102.24
    15:36:00.000000 102.26
    15:37:00.000000 102.28
    15:38:00.000000 102.27
    15:39:00.000000 102.24
    15:40:00.000000 102.21
    15:41:00.000000 102.25
    15:42:00.000000 102.29
    15:43:00.000000 102.26
    15:44:00.000000 102.25
    15:45:00.000000 102.24
    15:46:00.000000 102.20
    15:47:00.000000 102.21
    15:48:00.000000 102.21
    15:49:00.000000 102.21
    15:50:00.000000 102.20
    15:51:00.000000 102.20
    15:52:00.000000 102.19
    15:53:00.000000 102.21
    15:54:00.000000 102.22
    15:55:00.000000 102.28
    15:56:00.000000 102.26
    15:57:00.000000 102.28
    15:58:00.000000 102.31
    
    
    5 minute bars
    
    09:30:00.000000 102.80
    09:35:00.000000 102.73
    09:40:00.000000 102.99
    09:45:00.000000 103.04
    09:50:00.000000 103.05
    09:55:00.000000 103.00
    10:00:00.000000 102.58
    10:05:00.000000 102.46
    10:10:00.000000 102.25
    10:15:00.000000 102.25
    10:20:00.000000 102.18
    10:25:00.000000 102.00
    10:30:00.000000 101.84
    10:35:00.000000 101.89
    10:40:00.000000 102.05
    10:45:00.000000 102.05
    10:50:00.000000 102.05
    10:55:00.000000 102.00
    11:00:00.000000 102.00
    11:05:00.000000 101.88
    11:10:00.000000 101.92
    11:15:00.000000 101.98
    11:20:00.000000 102.00
    11:25:00.000000 101.99
    11:30:00.000000 102.01
    11:35:00.000000 102.01
    11:40:00.000000 101.99
    11:45:00.000000 102.01
    11:50:00.000000 102.16
    11:55:00.000000 102.15
    12:00:00.000000 102.28
    12:05:00.000000 102.23
    12:10:00.000000 102.07
    12:15:00.000000 102.10
    12:20:00.000000 102.08
    12:25:00.000000 102.09
    12:30:00.000000 102.20
    12:35:00.000000 102.23
    12:40:00.000000 102.12
    12:45:00.000000 102.23
    12:50:00.000000 102.31
    12:55:00.000000 102.39
    13:00:00.000000 102.48
    13:05:00.000000 102.50
    13:10:00.000000 102.55
    13:15:00.000000 102.48
    13:20:00.000000 102.41
    13:25:00.000000 102.31
    13:30:00.000000 102.26
    13:35:00.000000 102.23
    13:40:00.000000 102.20
    13:45:00.000000 102.23
    13:50:00.000000 102.18
    13:55:00.000000 102.17
    14:00:00.000000 102.35
    14:05:00.000000 102.39
    14:10:00.000000 102.40
    14:15:00.000000 102.18
    14:20:00.000000 102.29
    14:25:00.000000 102.32
    14:30:00.000000 102.35
    14:35:00.000000 102.33
    14:40:00.000000 102.36
    14:45:00.000000 102.34
    14:50:00.000000 102.20
    14:55:00.000000 102.17
    15:00:00.000000 102.18
    15:05:00.000000 102.12
    15:10:00.000000 102.18
    15:15:00.000000 102.20
    15:20:00.000000 102.17
    15:25:00.000000 102.35
    15:30:00.000000 102.34
    15:35:00.000000 102.28
    15:40:00.000000 102.29
    15:45:00.000000 102.24
    15:50:00.000000 102.22
    
    
    15 minute bars
    
    09:30:00.000000 102.99
    09:45:00.000000 103.05
    10:00:00.000000 102.58
    10:15:00.000000 102.25
    10:30:00.000000 102.05
    10:45:00.000000 102.05
    11:00:00.000000 102.00
    11:15:00.000000 102.00
    11:30:00.000000 102.01
    11:45:00.000000 102.16
    12:00:00.000000 102.28
    12:15:00.000000 102.10
    12:30:00.000000 102.23
    12:45:00.000000 102.39
    13:00:00.000000 102.55
    13:15:00.000000 102.48
    13:30:00.000000 102.26
    13:45:00.000000 102.23
    14:00:00.000000 102.40
    14:15:00.000000 102.32
    14:30:00.000000 102.36
    14:45:00.000000 102.34
    15:00:00.000000 102.18
    15:15:00.000000 102.35
    15:30:00.000000 102.34
    
    
Sign In or Register to comment.