Mariner Backtesting - md.stat

An interface to the fundamentals for the current symbol.

Sample:

 md..beta
Attributes:
Name Type Special Information
atr float NaN Average True Range (aka Average Trading Range), over 10 days based on an underlying 250 days of TR (True Range). You can use TA Lib to create alternative timeframes.
avol float NaN Average Volume over 21 days, or whatever smaller number of days is actually available. You can use TA Lib to create alternative timeframes.
beta float NaN Beta, computed over a 249 day time period (250 bars) by default, or as short as 20 days (21 bars) if more aren't available, or NaN if only fewer are available. You can use TA Lib to create alternative timeframes.
dividend_amount float 0.0 The dividend ammount in dollars applied to the stock price.
dividend_comment string None The dividend comment, this may provide more details on the type of dividend.
dividend_percent float 0.0 The dividend percent ratio. (dividend / prev_close).
exchange string None Primary exchange exchange details
lot_size integer 100 Number of shares per lot
prev_close float 0 The adjusted closing price from previous day
prev_symbol string None The previous days symbol. If there was a symbol name change, you can see what it was prior. If the name is the same, then the prev_symbol will match the current.
split_ratio float 1 The ratio of the stock split that was applied to the price. Only available in GP.
unadjusted_prev_close float 0 The unadjusted closing price from previous day
Methods:

None

Remarks:
  • stat following attributes get updated at the start of each day.
Working Example:
 from cloudquant.interfaces import Strategy


class OnStartStat(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 self.symbol

        print '\nin on_start()\n\t%s\n' % service.time_to_string(service.system_time, '%H:%M:%S.%f')
        print 'md.stat\n'

        print ' md.stat.atr -   ', md.stat.atr
        print ' md.stat.avol    -   ', md.stat.avol
        print ' md.stat.beta    -   ', md.stat.beta
        print ' md.stat.dividend_amount -   ', md.stat.dividend_amount
        print ' md.stat.dividend_comment    -   ', md.stat.dividend_comment
        print ' md.stat.dividend_percent    -   ', md.stat.dividend_percent
        print ' md.stat.exchange    -   ', md.stat.exchange
        print ' md.stat.lot_size    -   ', md.stat.lot_size
        print ' md.stat.prev_close  -   ', md.stat.prev_close

        service.terminate()

Console

2016-01-04
SPY

in on_start()
    04:00:00.000000

md.stat

    md.stat.atr -   2.47490000725
    md.stat.avol    -   139914776
    md.stat.beta    -   0.0
    md.stat.exchange    -   P
    md.stat.lot_size    -   100
    md.stat.prev_close  -   203.869995117