Administrator
2023-03-23 96dc1a4cc38b588f39387b5a85b9677100e357f1
juejin.py
@@ -536,6 +536,12 @@
        keys = redis.keys("juejin_listen_code-*")
        return len(keys)
    @classmethod
    def get_previous_trading_date(cls, date):
        account_id, s_id, token = getAccountInfo()
        gmapi.set_token(token)
        return gmapi.get_previous_trading_date("SHSE", date)
def trade(code, volume):
    account_id, s_id, token = getAccountInfo()
@@ -578,10 +584,15 @@
# 获取近90天的最大量与最近的量
# 获取最近一次涨停/涨停下一个交易日的最大值
def get_volumn(code) -> object:
    datas = JueJinManager.get_history_tick_n(code, 60, "open,high,low,close,volume,pre_close,bob")
def get_volumns_by_code(code, count=60) -> object:
    datas = JueJinManager.get_history_tick_n(code, count, "open,high,low,close,volume,pre_close,bob")
    # 计算
    datas.sort(key=lambda x: x["bob"], reverse=True)
    return datas
# 解析最大量
def parse_max_volume(datas):
    max_volume = 0
    for i in range(len(datas)):
        # 查询涨停
@@ -595,8 +606,40 @@
            next_volume = 0
            if i > 0:
                next_volume = datas[i - 1]["volume"]
            return (max(volume, next_volume), max(volume, next_volume))
            volume = max(volume, next_volume)
            return (volume, volume)
    return (max_volume, max_volume)
# 是否有涨停
def is_have_limit_up(datas):
    for i in range(len(datas)):
        item = datas[i]
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
        if abs(limit_up_price - item["close"]) < 0.01:
            return True
    return False
# 首板涨停溢价率
def get_limit_up_money_percent(datas):
    datas.sort(key=lambda x: x["bob"])
    first_rate_list = []
    for i in range(0, len(datas)):
        item = datas[i]
        limit_up_price = float(gpcode_manager.get_limit_up_price_by_preprice(item["pre_close"]))
        if abs(limit_up_price - item["close"]) < 0.001 and abs(
                limit_up_price - datas[i - 1]["close"]) >= 0.001 and 0 < i < len(datas) - 1:
            # 首板涨停
            rate = (datas[i + 1]["high"] - datas[i + 1]["pre_close"]) / datas[i + 1]["pre_close"]
            first_rate_list.append(rate)
    if not first_rate_list:
        return 1
    count = 0
    for rate in first_rate_list:
        if rate >= 0.01:
            count += 1
    return count / len(first_rate_list)
# 根据涨幅高低分配交易窗口
@@ -611,4 +654,6 @@
if __name__ == '__main__':
    print(get_volumn("002291"))
    datas=(get_volumns_by_code("603083", 150))
    print(datas)
    print(get_limit_up_money_percent(datas))