Administrator
2023-01-02 ed9e2367eea9baa6c8bea82e0f81c209ffb2a56f
tool.py
@@ -157,6 +157,17 @@
    return time_1 - time_2
# 交易时间加几s
def trade_time_add_second(time_str, second):
    ts = time_str.split(":")
    s_ = int(ts[0]) * 3600 + int(ts[1]) * 60 + int(ts[2])
    s = s_ + second
    # 是否在11:30:00
    if s >= 11 * 3600 + 30 * 60 > s_:
        s += 90 * 60
    return time_seconds_format(s)
def compute_buy1_real_time(time_):
    ts = time_.split(":")
    s = int(ts[0]) * 3600 + int(ts[1]) * 60 + int(ts[2])
@@ -164,8 +175,21 @@
    return time_seconds_format(s - 2 - cha)
# 全角转半角
def strQ2B(ustring):
    rstring = ""
    for uchar in ustring:
        inside_code = ord(uchar)
        if inside_code == 12288:  # 全角空格直接转换
            inside_code = 32
        elif 65281 <= inside_code <= 65374:  # 全角字符(除空格)根据关系转化
            inside_code -= 65248
        rstring += chr(inside_code)
    return rstring
if __name__ == "__main__":
    print(trade_time_sub("11:29:59", "13:00:00"))
    print(trade_time_sub("11:29:59", "14:00:00"))
    print(trade_time_sub("10:29:59", "11:29:59"))
    print(trade_time_sub("13:29:59", "14:29:59"))
    print(trade_time_add_second("11:29:59", 1))
    print(trade_time_add_second("11:29:59", 5))
    print(trade_time_add_second("10:29:59", 10))
    print(trade_time_add_second("13:29:59", 60))