| | |
| | | import multiprocessing |
| | | import queue |
| | | import time |
| | | |
| | | from l2.cancel_buy_strategy import LCancelRateManager |
| | | |
| | | __queue = queue.Queue() |
| | | |
| | | |
| | | def add_data(msg): |
| | | time.sleep(1) |
| | | start_time = time.time() |
| | | __queue.put({"msg": msg}) |
| | | end_time = time.time() |
| | | if end_time - start_time > 0.002: |
| | | print("加入日志耗时") |
| | | |
| | | |
| | | def test_process_1(pipe): |
| | | while True: |
| | | for i in range(10): |
| | | pipe.send_bytes(f"hello world:{i}".encode("utf-8")) |
| | | time.sleep(1) |
| | | |
| | | |
| | | def test_process_2(pipe): |
| | | while True: |
| | | results = pipe.recv_bytes() |
| | | if results: |
| | | print("接受到内容:", results) |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | q: queue.Queue = queue.Queue() |
| | | while True: |
| | | try: |
| | | temp = q.get(timeout=10) |
| | | except: |
| | | time.sleep(0.02) |
| | | finally: |
| | | pass |
| | | left_money_w = -3900 |
| | | for w in [-3900, -3600, -3300,-3000, -2700, -2400,-2100,-900,3900,3900,4200,4500]: |
| | | if w > 0: |
| | | rate = ((w + 300) // 900) * 2 |
| | | else: |
| | | rate = ((w + 599) // 900) * 2 |
| | | if rate < -10: |
| | | rate = -10 |
| | | if rate > 10: |
| | | rate = 10 |
| | | print(w, rate) |