| | |
| | | # 查询此仓 |
| | | code = data.get("code") |
| | | if code: |
| | | results = huaxin_trade_record_manager.PositionManager().list_by_day(tool.get_now_date_str("%Y%m%d"), code) |
| | | results = huaxin_trade_record_manager.PositionManager().list_by_day(tool.get_now_date_str("%Y%m%d"), |
| | | code) |
| | | else: |
| | | results = huaxin_trade_record_manager.PositionManager().get_from_cache() |
| | | if constant.backtest_mode_info: |
| | |
| | | position_dict = backtest_trade.position_dict |
| | | for p in position_dict: |
| | | translation = position_dict[p] |
| | | underlying_code = p["SecurityID"] |
| | | p["buy_list"] = [{"price": str(translation['TradePrice']), |
| | | "tradeTime": l2_huaxin_util.convert_time(translation['OrderTime']), "volume": 10}] |
| | | underlying_code = translation["SecurityID"] |
| | | translation["buy_list"] = [{"price": str(translation['TradePrice']), |
| | | "tradeTime": l2_huaxin_util.convert_time(translation['OrderTime']), |
| | | "volume": 10}] |
| | | cb_code = target_codes_manager.get_cb_code(underlying_code) |
| | | underlying_market = code_market_manager.get_market_info(underlying_code) |
| | | results.append( |
| | | {"securityID": cb_code, "securityName": gpcode_manager.CodesNameManager().get_code_name(cb_code), |
| | | "buy_list": p["buy_list"], "sell_list": [], "currentPosition": 10, "id": cb_code}) |
| | | {"securityID": cb_code, |
| | | "securityName": gpcode_manager.CodesNameManager().get_code_name(cb_code), |
| | | "buy_list": translation["buy_list"], "sell_list": [], "currentPosition": 10, "id": cb_code}) |
| | | |
| | | for r in results: |
| | | cb_code = r["securityID"] |
| | |
| | | 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): |
| | |
| | | # 获取买点与卖点 |
| | | if "buy_list" not in r: |
| | | buys = huaxin_trade_record_manager.DealRecordManager().list_buy_by_code_cache(cb_code) |
| | | r["buy_list"] = [{"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": x["volume"]} for x in |
| | | r["buy_list"] = [{"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": x["volume"]} for |
| | | x in |
| | | buys] |
| | | if "sell_list" not in r: |
| | | sells = huaxin_trade_record_manager.DealRecordManager().list_sell_by_code_cache(cb_code) |
| | | r["sell_list"] = [{"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": x["volume"]} for x |
| | | r["sell_list"] = [{"price": str(x["price"]), "tradeTime": x["tradeTime"], "volume": x["volume"]} for |
| | | x |
| | | in |
| | | sells] |
| | | send_response({"code": 0, "data": results}, client_id, request_id) |