Mariner Backtesting - Market Data - md

The Mariner md Object for Market Data

Market (md - Market Data) Overview:

The Market object (referred to as md in the system interfaces) is market data. It's comprised of attributes and sub objects:

Data Attributes:

Sample - Access data attribute

 md.market_open_time
Name Type Information
market_close_time muts Timestamp marking when the market closed.
market_open_time muts Timestamp marking when the market opened.
symbol string The symbol for the event
Methods:
  • None
Objects:
Name Type Information
L1 Level1 A snapshot of the current market state (Level 1 Data).
L2 Level2 Stubbed out in backtesting. Available in forward and live trading.
bar Bar A snapshot of past market data
book Book Stubbed out in backtesting. Available in forward and live trading.
news News An interface to News data. News attributes get updated at the start of each day.
stat Stat An interface to the fundamentals for the current symbol. Stat following attributes get updated at the start of each day.
Working Example:
 from cloudquant.interfaces import Strategy

class MarketObject(Strategy):

    @classmethod
    def on_strategy_start(cls, md, service, account):
        print service.time_to_string(service.system_time, '%Y-%m-%d')

    @classmethod
    def is_symbol_qualified(cls, symbol, md, service, account):
        return symbol == 'SPY'

    def on_start( self, md, order, service, account ):
        print 'object - md\n'

        print ' md.market_close_time\t\t%s\t%s' % (md.market_close_time, service.time_to_string(md.market_close_time, '%H:%M:%S.%f') )
        print ' md.market_open_time\t\t%s\t%s' % (md.market_open_time,  service.time_to_string(md.market_open_time, '%H:%M:%S.%f') )
        print ' md.symbol   -   ', md.symbol

        service.terminate()

Console

2016-11-11
object - md

    md.market_close_time        1478898000000000    16:00:00.000000
    md.market_open_time     1478874600000000    09:30:00.000000
    md.symbol   -   SPY