经典理论 【量价趋势】 部分python代码

#1
xh=False #判断趋势线形成信号
#此处已经比对完毕 true false true
condition=(
            ((df['close']-df['preclose'])>=0.9*df['atr'])&
            (df['volume']>2*df['volume'].shift(1))&
            (df['preclose']<df['close'].shift(-1))&
            (df['close'].shift(-1)<df['close'])&
            (0.4*df['volume']<=df['volume'].shift(-1))&
            (df['volume'].shift(-1)<=0.6*df['volume'])
        )

# result=df[condition]
# if len(result)==0:
#     xh=True
#结果 是否有启动信号
#只取后30行
last_30_index=df.iloc[-30:].index
index_i=last_30_index[condition.loc[last_30_index]].tolist()
if len(index_i)==0:
    xh=True


#2
#df 切割后的df可行吗?
# 其中df为最后一个趋势起点
# index_i[-1] #最后一个启动点
result=[]
result_index=[] #谷点位置
for i in range(index_i[-1]+1,len(df)-1):
# for i in range(1,len(df)-1):
    a=df.iloc[i-1]
    b=df.iloc[i]
    c=df.iloc[i+1]
    if (a['low']>b['low'])and(b['low']<c['low']):
        result.append(b)
        result_index.append(i)
result_df=pd.DataFrame(result)
xh=False #判断趋势线形成信号
if len(result_df)>2:
    for i in range(0,len(result_df)-1):
        if result_df.iloc[i]['low']>result_df.iloc[i+1]['low']:
            xh=True
# 使用xh判断 是否趋势线形成


#3 没有循环判断
# 动态阻力线 支撑线 maxHigh minLow
# i行 即最后一个低点后到值 显示突破 目前没有动态创建 两个价格

# result_index[-1] 为后面最后一个谷底位置
resultx=[]
resultx_index=[]
zc=False
xh=False
for i in range(result_index[-1]+1,len(df)-1):
    maxHigh=df.iloc[i-10:i]['high'].max()
    minLow=df.iloc[i-10:i]['low'].min()
    for j in range(i,len(df)-1):
        #突破后阻力位转为支撑位  
        if (df.iloc[j]['close']>maxHigh) and (df.iloc[j]['volume']>=2*df.iloc[j-1]['volume']) and (df.iloc[j+1]['close']>maxHigh):
            resultx.append(df.iloc[j])
            result_index.append(j)
            zc=maxHigh
            for jj in range(j,len(df)):
                #此处只记录突破位置
                if zc:
                    if df.iloc[jj]['close']<zc:
                        xh=True
        #破线  趋势结束


# 4 没有循环判断
# 成交量异常  放大


# resultx_index[-1]开始循环是否出现下面的形态

for ii in range(resultx_index[-1]+1,len(df)-1):
    if df.iloc[ii]['volume']>2*df.iloc[ii-1]['volume']:
        #锤子
        if abs(df.iloc[ii]['close']-df.iloc[ii]['open'])*3<=(df.iloc[ii]['high']-df.iloc[ii]['low']) and (df.iloc[ii]['close']>df.iloc[ii]['low'])and (df.iloc[ii]['open']>df.iloc[ii]['low']):
            xh=True
        #黄昏星
        if (df.iloc[ii-1]['close']>df.iloc[ii-1]['open'])and(df.iloc[ii+1]['close']<df.iloc[ii+1]['open']) and(abs(df.iloc[ii]['close']-df.iloc[ii]['open'])*3<=(df.iloc[ii]['high']-df.iloc[ii]['low']))and(df.iloc[ii]['high']>df.iloc[ii]['open'])and(df.iloc[ii]['high']>df.iloc[ii]['close']):
            xh=True
        #吞没
        if (df.iloc[ii-1]['close']>df.iloc[ii-1]['open'])and(df.iloc[ii]['close']<df.iloc[ii]['open'])and(df.iloc[ii]['close']<df.iloc[ii-1]['open'])and(df.iloc[ii]['open']>df.iloc[ii-1]['close']):
            xh=True


#      趋势结束

发表在 None | 留下评论

Thinkphp 坑点 Join 和with 不可连用

Join 下如果使用模型关联 即使用with会导致生成的SQL语句奇怪,即会把关联的ID混用,非常非常奇怪!!!
做search查询直接用join 即可

【不要使用关联 和with 再不行就用子查询】

发表在 None | 留下评论

thinkcmf 补齐 service

Model数据 用于关联

Service 处理数据逻辑 方便复用

Controller 处理请求调用Service

V 模版

Controller调用Service使用注入

Service 分页

#此处使用注入,方便测试 里面可以直接调用
public function index(UserService $userService)
{
    $page = $this->request->get('page', 1);
    
    // 只调用Service,不干别的
    $data = $userService->getList($page);
    
    $this->assign('data', $data);
    return $this->fetch();
}

service

 public function getList(int $page, int $limit=100): array
    {
        // 分页查询:paginate() 是 TP6 核心方法,CMF6 完全兼容
        /** @var Paginator $paginate */
        $paginate = User::where('status', 1)
            ->order('id', 'desc')
            ->paginate([
                'list_rows' => $limit,
                'page' => $page,
            ]);

        // 格式化返回(适配前端/模板)
        return [
            'total' => $paginate->total(), // 总条数
            'list' => $paginate->items(),   // 当前页数据
            'page' => $paginate->currentPage(), // 当前页
            'limit' => $paginate->listRows(),   // 每页条数
            'pages' => $paginate->lastPage(),   // 总页数
        ];
    }



#或者简单点 不要花里胡哨

public function getList(int $page, int $limit=100)
{
    // 就这一句是分页核心
    return User::where('status',1)->order('id desc')->paginate($limit);
}
发表在 None | 留下评论

thinkcmf thinkphp6 原生JSON

code 的值 1 为success 值0为error

{
    "code": 0,
    "msg": "保存成功",
    "url": "/user/index",
    "data": {
        "name": "test"
    }
}

return $this->success(‘操作成功’, ”, $data);

文字、 URL 、数据;

发表在 None | 留下评论

acme.sh 添加SSL

首先LNMP下的SSL添加有问题 不如直接使用acme.sh反正也是用他的

安装:

curl https://get.acme.sh | sh -s email=your@email.com
#需要设置你的邮箱
source ~/.bashrc

acme.sh -v
#查看安装情况

使用letsencrypt

acme.sh --set-default-ca --server letsencrypt

修改你的nginx的conf

设置:.well-know (lnmp 里面的需要修改) 请注释掉之前的/.well-known/然后插入新的

location ^~ /.well-known/acme-challenge/ {
            allow all;
            default_type text/plain;
            root /home/wwwroot/quant.comic.org.cn;
        }

然后 lnmp nginx restart 实现nginx重启

acme.sh --issue -d abc.cn -w /home/wwwroot/abc.cn

安装好了会显示地址:

[Sun Apr 12 04:54:22 PM CST 2026] Your cert is in: /root/.acme.sh/abc.cn_ecc/abc.cn.cer
[Sun Apr 12 04:54:22 PM CST 2026] Your cert key is in: /root/.acme.sh/abc.cn_ecc/abc.cn.key
[Sun Apr 12 04:54:22 PM CST 2026] The intermediate CA cert is in: /root/.acme.sh/abc.cn_ecc/ca.cer
[Sun Apr 12 04:54:22 PM CST 2026] And the full-chain cert is in: /root/.acme.sh/abc.cn_ecc/fullchain.cer

#其中abc.cn是你的证书文件位置 在root的.acme.sh下面

nginx下创建ssl目录

mkdir /usr/local/nginx/conf/ssl

一键移动证书到NGINX

acme.sh --install-cert -d abc.cn \
--key-file /usr/local/nginx/conf/ssl/abc.cn.key \
--fullchain-file /usr/local/nginx/conf/ssl/abc.cn.crt \
--reloadcmd "nginx -t && service nginx reload"

重新配置conf 在lnmp的域名下配置

server
{
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name abc.cn;

    root  /home/wwwroot/abc.cn/public;
    index index.html index.htm index.php default.html default.htm default.php;

    # SSL 证书位置
    ssl_certificate /usr/local/nginx/conf/ssl/abc.cn.crt;
    ssl_certificate_key /usr/local/nginx/conf/ssl/abc.cn.key;

    include rewrite/thinkphp.conf;
    include enable-php-pathinfo.conf;

    location ~ .*\.(gif|jpg|jpeg,png,bmp,swf)$
    {
        expires      30d;
    }

    location ~ .*\.(js,css)?$
    {
        expires      12h;
    }

    location ~ /\.
    {
        deny all;
    }

    access_log  /home/wwwlogs/abc.cn.log;
}

配置443端口

ufw allow 443

查看443 端口

netstat -lntp | grep 443

腾讯云 阿里云的话可能要在云服务器配置中打开443 端口

发表在 None | 留下评论