| | |
| | | """ |
| | | import ctypes |
| | | import decimal |
| | | import math |
| | | import random |
| | | import threading |
| | | import time |
| | |
| | | def time_sub_as_ms(time_str_1, time_str_2): |
| | | time_1 = get_time_as_second(time_str_1[:8]) |
| | | time_2 = get_time_as_second(time_str_2[:8]) |
| | | return (time_1 - time_2) * 1000 + (int(time_str_1[9:]) - int(time_str_2[9:])) if len(time_str_1)>8 and len(time_str_2)>8 else 0 |
| | | return (time_1 - time_2) * 1000 + (int(time_str_1[9:]) - int(time_str_2[9:])) if len(time_str_1) > 8 and len( |
| | | time_str_2) > 8 else 0 |
| | | |
| | | |
| | | # 交易时间加几s |
| | |
| | | if s >= 11 * 3600 + 30 * 60 > s_: |
| | | s += 90 * 60 |
| | | return time_seconds_format(s) |
| | | |
| | | |
| | | def is_sh_code(code): |
| | | return code.find('60') == 0 or code.find('11') == 0 or code.find('68') == 0 |
| | | |
| | | |
| | | def is_sz_code(code): |
| | | return code.find('00') == 0 or code.find('12') == 0 or code.find('30') == 0 |
| | | |
| | | |
| | | def compute_buy1_real_time(time_): |
| | |
| | | except: |
| | | pass |
| | | return None |
| | | |
| | | |
| | | def get_limit_up_rate(code): |
| | | # 获取涨停倍数 |
| | | if code.find("00") == 0 or code.find("60") == 0: |
| | | return 1.1 |
| | | else: |
| | | return 1.2 |
| | | |
| | | |
| | | def get_limit_down_rate(code): |
| | | # 获取涨停倍数 |
| | | if code.find("00") == 0 or code.find("60") == 0: |
| | | return 0.9 |
| | | else: |
| | | return 0.8 |
| | | |
| | | |
| | | def get_limit_up_price_by_preprice(code, price): |
| | | if price is None: |
| | | return None |
| | | return to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{get_limit_up_rate(code)}")) |
| | | |
| | | |
| | | def get_limit_down_price_by_preprice(code, price): |
| | | if price is None: |
| | | return None |
| | | return to_price(decimal.Decimal(str(price)) * decimal.Decimal(f"{get_limit_down_rate(code)}")) |
| | | |
| | | |
| | | # 获取买入价格笼子的最高价 |
| | | def get_buy_max_price(price): |
| | | price1 = price * (1 + 0.02) |
| | | price1 = math.ceil(price1 * 100) / 100 |
| | | price2 = price + 0.1 |
| | | return min(price1, price2) |