def loads(dic): equity = Equity() for k, v in dic.items(): setattr(equity, k, BaseEntity.fix_na(v)) BaseEntity.parse_for_entity(BaseEntity.parse_float, equity, [ 'openPrice', 'highPrice', 'lowPrice', 'lastPrice', 'priceChange', 'volume' ]) BaseEntity.parse_for_entity(BaseEntity.parse_date, equity, ['tradeTime']) return equity
def loads(dic): option = Option() for k, v in dic.items(): setattr(option, k, BaseEntity.fix_na(v)) BaseEntity.parse_for_entity(BaseEntity.parse_float, option, ['strikePrice', 'askPrice', 'bidPrice', 'openPrice', 'highPrice', 'lowPrice', 'lastPrice', 'priceChange', 'theoretical', 'delta', 'gamma', 'rho', 'theta', 'vega', 'openInterest', 'volume']) BaseEntity.parse_for_entity(BaseEntity.parse_date, option, ['tradeTime', 'expirationDate', 'date', 'bidDate']) if option.volatility is not None: option.volatility = BaseEntity.parse_float(option.volatility.replace('%', '')) # else: # print option return option
def loads(dic): vix = VIX() for k, v in dic.items(): setattr(vix, k, BaseEntity.fix_na(v)) BaseEntity.parse_for_entity(BaseEntity.parse_float, vix, [ 'lastPrice', 'priceChange', 'openPrice', 'highPrice', 'lowPrice', 'previousPrice', 'volume', 'dailyLastPrice', 'dailyPriceChange', 'dailyOpenPrice', 'dailyHighPrice', 'dailyLowPrice', 'dailyPreviousPrice', 'dailyVolume' ]) BaseEntity.parse_for_entity(BaseEntity.parse_date, vix, ['dailyDate1dAgo']) return vix