| | |
| | | # 报单状态 |
| | | import random |
| | | import threading |
| | | |
| | | from utils import tool |
| | | |
| | | TORA_TSTP_OST_Cached = '0' # 预埋 |
| | | TORA_TSTP_OST_Unknown = '1' # 未知 |
| | | TORA_TSTP_OST_Accepted = '2' # 交易所已接收 |
| | |
| | | if state == TORA_TSTP_OST_Cached or state == TORA_TSTP_OST_Unknown or state == TORA_TSTP_OST_Accepted or state == TORA_TSTP_OST_PartTraded: |
| | | return True |
| | | return False |
| | | |
| | | |
| | | # 是否已经撤单 |
| | | def is_canceled(state): |
| | | if state == TORA_TSTP_OST_AllCanceled or state == TORA_TSTP_OST_PartTradeCanceled: |
| | | return True |
| | | return False |
| | | |
| | | |
| | | # 是否已经成交 |
| | | def is_deal(state): |
| | | if state == TORA_TSTP_OST_PartTraded or state == TORA_TSTP_OST_AllTraded or state == TORA_TSTP_OST_PartTradeCanceled: |
| | | return True |
| | | return False |
| | | |
| | | |
| | | __order_ref_lock = threading.RLock() |
| | | __public_order_ref = int(tool.get_now_time_str().replace(":", "")) |
| | | |
| | | |
| | | # 创建订单引用 |
| | | def create_order_ref(): |
| | | __order_ref_lock.acquire() |
| | | try: |
| | | global __public_order_ref |
| | | __public_order_ref += random.randint(5, 20) |
| | | return __public_order_ref |
| | | finally: |
| | | __order_ref_lock.release() |