| | |
| | | |
| | | |
| | | class MarketInfo: |
| | | def __init__(self, code, price, rate, buy1_price, buy1_volume, total_volume, total_bid_volume, total_ask_volume): |
| | | def __init__(self, code, price, rate, buy1_price, buy1_volume, total_volume, total_bid_volume, total_ask_volume, pre_close_price): |
| | | self.code = code |
| | | self.price = price |
| | | self.rate = rate |
| | |
| | | self.total_volume = total_volume |
| | | self.total_bid_volume = total_bid_volume |
| | | self.total_ask_volume = total_ask_volume |
| | | self.pre_close_price = pre_close_price |
| | | |
| | | |
| | | def set_market_info(data): |
| | | """ |
| | | 设置行情信息 |
| | | :param data: (代码, 最近的价格, 涨幅, 买1价, 买1量, 成交总量) |
| | | :param data: (代码, 最近的价格, 涨幅, 买1价, 买1量, 成交总量, 买入量, 卖出量, 昨日收盘价) |
| | | :return: |
| | | """ |
| | | async_log_util.info(logger_local_huaxin_l2_market, f"{data}") |
| | | __market_info_dict[data[0]] = MarketInfo(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]) |
| | | __market_info_dict[data[0]] = MarketInfo(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8]) |
| | | |
| | | |
| | | def get_market_info(code) -> MarketInfo: |
| | |
| | | r["marketInfo"] = {"code": cb_market.code, "name": r["securityName"], |
| | | "rate": f"{round(cb_market.rate * 100, 2)}%", |
| | | "price": cb_market.price, "lastVolume": cb_market.total_bid_volume // 100, |
| | | "buy1Money": output_util.money_desc(cb_market.buy1_price * cb_market.buy1_volume)} |
| | | "buy1Money": output_util.money_desc(cb_market.buy1_price * cb_market.buy1_volume),"preClosePrice":cb_market.pre_close_price} |
| | | if underlying_market: |
| | | if not gpcode_manager.CodesNameManager().get_code_name(underlying_market.code): |
| | | # 异步请求名称 |
| | |
| | | "price": underlying_market.price, |
| | | "lastVolume": underlying_market.total_bid_volume // 100, |
| | | "buy1Money": output_util.money_desc( |
| | | underlying_market.buy1_price * underlying_market.buy1_volume)} |
| | | underlying_market.buy1_price * underlying_market.buy1_volume), |
| | | "preClosePrice":underlying_market.pre_close_price} |
| | | |
| | | send_response({"code": 0, "data": results}, client_id, request_id) |
| | | elif type_ == "refresh_trade_data": |