def request_8102(addr): p8102 = mds_protocol.Protocol8102() p8102.is_pushed = mds_protocol.PUSH_TYPE_ONCE p8102.market_ids = global_market_infos.values() client = request_once.request_once(p8102)() try: client.connect(addr) except Exception as e: raise e else: stock_data_list = client.get_data().get(p8102.message_id, []) stock_data_list = [item.to_json() for item in stock_data_list] return stock_data_list
def request_8125(addr, market_name): p8125 = mds_protocol.Protocol8125() p8125.is_pushed = mds_protocol.PUSH_TYPE_ONCE p8125.market_id = global_market_infos[market_name] p8125.request_type = 0 client = request_once.request_once(p8125)() try: client.connect(addr) except Exception as e: raise e else: stock_data_list = client.get_data().get(p8125.message_id, []) stock_data_list = [item.to_json() for item in stock_data_list] return stock_data_list
def request_8113(addr, market_name, broker_no): protocol_8113 = mds_protocol.Protocol8113() protocol_8113.is_pushed = mds_protocol.PUSH_TYPE_ONCE protocol_8113.market_id = global_market_infos[market_name] protocol_8113.broker_no = broker_no client = request_once.request_once(protocol_8113)() try: client.connect(addr) except Exception as e: raise e else: stock_data_list = client.get_data().get(protocol_8113.message_id, []) stock_data_list = [item.to_json() for item in stock_data_list] return stock_data_list
def request_8104(addr, market_name, stock_id, period=1): p8104 = mds_protocol.Protocol8104() p8104.is_pushed = mds_protocol.PUSH_TYPE_ONCE p8104.market_id = global_market_infos[market_name] p8104.stock_id = stock_id p8104.period = period client = request_once.request_once(p8104)() try: client.connect(addr) except Exception as e: raise e else: stock_data_list = client.get_data().get(p8104.message_id, []) stock_data_list = [item.to_json() for item in stock_data_list] return stock_data_list
def request_8101(addr, market_name, stock_id): p8101 = mds_protocol.Protocol8101() p8101.is_pushed = mds_protocol.PUSH_TYPE_ONCE p8101.market_id = global_market_infos[market_name] p8101.stock_id = stock_id client = request_once.request_once(p8101)() try: client.connect(addr) except Exception as e: raise e else: stock_data_list = client.get_data().get(p8101.message_id, []) # Because this information is not returned under the message ID 8101, I make it myself. stock_data_list = [item.to_json() for item in stock_data_list] stock_info = {'market_name': market_name, 'stock_code': stock_id} for item in stock_data_list: item.update(stock_info) return stock_data_list