| | |
| | | # 是否为测试 |
| | | import platform |
| | | |
| | | TEST = False |
| | | TEST = True |
| | | # 是否允许交易 |
| | | TRADE_ENABLE = True |
| | | |
| | |
| | | tmep_order_detail_queue_dict[code] = queue.Queue() |
| | | tag = l2_data_transaction_protocol.get_mmap_tag_name_for_l2_order(code) |
| | | with contextlib.closing( |
| | | mmap.mmap(-1, 1000 * 100, tagname=tag, |
| | | mmap.mmap(-1, 1000 * 100, tag, |
| | | access=mmap.ACCESS_WRITE)) as _mmap: |
| | | while True: |
| | | # print("order task") |
| | |
| | | t = threading.Thread(target=lambda: __test(pipe_strage), daemon=True) |
| | | t.start() |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | upload_data("000798", "trading_order_canceled", 30997688, new_sk=True) |
| | | def test(): |
| | | # upload_data("000798", "trading_order_canceled", 30997688, new_sk=True) |
| | | code = "000333" |
| | | tag = l2_data_transaction_protocol.get_mmap_tag_name_for_l2_order(code) |
| | | with contextlib.closing( |
| | | mmap.mmap(-1, 1000 * 100, tag, |
| | | access=mmap.ACCESS_WRITE)) as _mmap: |
| | | pass |
| | |
| | | |
| | | # @unittest.skip("跳过此单元测试") |
| | | def test_trade(self): |
| | | code = "600292" |
| | | code = "002527" |
| | | clear_trade_data(code) |
| | | l2.l2_data_util.load_l2_data(code) |
| | | total_datas = deepcopy(l2.l2_data_util.local_today_datas[code]) |
| | |
| | | import multiprocessing |
| | | import time |
| | | |
| | | from huaxin_client import l2_data_manager |
| | | |
| | | |
| | | def run_process_1(pipe): |
| | | with contextlib.closing(mmap.mmap(-1, 1000 * 100, tagname='l2-000333', access=mmap.ACCESS_WRITE)) as m: |
| | | tag = 'l2-000333' |
| | | with contextlib.closing(mmap.mmap(-1, 1000 * 100, tagname=tag, access=mmap.ACCESS_WRITE)) as m: |
| | | for i in range(1, 10001): |
| | | start = time.time() |
| | | m.seek(0) |
| | |
| | | print(len(s), s) |
| | | time.sleep(1) |
| | | |
| | | |
| | | if __name__ == '__main__': |
| | | l2_data_manager.test() |
| | | pass |
| | | |
| | | |
| | | if __name__ == '__main__1': |
| | | p1, p2 = multiprocessing.Pipe() |
| | | serverProcess = multiprocessing.Process(target=run_process_1, args=(p1,)) |
| | | jueJinProcess = multiprocessing.Process(target=run_process_2, args=(p2,)) |
| | |
| | | def process_l2_order(code, request_id): |
| | | # 读取共享内存中的数据 |
| | | with contextlib.closing( |
| | | mmap.mmap(-1, 1000 * 100, tagname=l2_data_transaction_protocol.get_mmap_tag_name_for_l2_order(code), |
| | | mmap.mmap(-1, 1000 * 100, l2_data_transaction_protocol.get_mmap_tag_name_for_l2_order(code), |
| | | access=mmap.ACCESS_READ)) as m: |
| | | s = m.read(1000 * 100) |
| | | s = s.decode('utf-8').replace('\x00', '') |