def market_overview_init(request,tradetype,tradeframe): now = timezone.now() mov = MarketOverView(market_result = "", pub_date = now) mov.save() for tf in trade_frame_map(tradeframe): mdi = MarketDetailInfo(symbol_name = tradetype, timeframe = tf , obj_dir = get_prev_dir(request,tradetype,tf,'obj_dir'), sub_dir = get_prev_dir(request,tradetype,tf,'sub_dir'), market_overview = mov) mdi.save() return mov
def selected_overview_init(request,tp_obj): try: selected = MarketDetailInfo.objects.filter(market_overview = tp_obj.diff_s_overview, timeframe = tp_obj.tradeframe, exclude_reason = 'N') except MarketDetailInfo.DoesNotExist: return False tfm = trade_frame_map(tp_obj.tradeframe) for mdi in selected: for tf in tfm: try: mdi_new = MarketDetailInfo.objects.get(symbol_name = mdi.symbol_name, market_overview = tp_obj.diff_s_overview, timeframe = tf) except MarketDetailInfo.DoesNotExist: mdi_new=MarketDetailInfo(symbol_name = mdi.symbol_name, timeframe = tf, market_overview = tp_obj.diff_s_overview, obj_dir = 'N', sub_dir = 'N') mdi_new.save()
def diff_overview_init(request,tp_model,diff_flag): now = timezone.now() mov = MarketOverView(market_result = "", pub_date = now) mov.save() tf = trade_frame_map(tp_model.tradeframe) # 目前实现上主要是处理 6 个非美货币的交易 symbols = ['EURUSD','GBPUSD','CHFUSD','AUDUSD','CADUSD','JPYUSD'] for symbol in symbols: if diff_flag == 'b': tfm = tf[1] mov_save = tp_model.diff_s_overview if diff_flag == 's': tfm = tf[0] mov_save = mov mdi = MarketDetailInfo(symbol_name = symbol, timeframe = tfm , obj_dir = get_prev_dir(request,symbol,tfm,'obj_dir'), sub_dir = get_prev_dir(request,symbol,tfm,'sub_dir'), market_overview = mov_save) mdi.save() return mov