admin
2024-03-08 2aa160821ab9dbf069ffe86e7774be54866530eb
增加市场情绪前端展示
8个文件已修改
293 ■■■■ 已修改文件
kp_html/kp/codes_list.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
kp_html/kp/index23-05-04.html 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
kp_html/kp/js/code_list.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
kp_html/kp/js/http.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
kp_html/kp/js/page.js 188 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
kpl/kpl_api.py 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.py 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
network_delegate_manager.py 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
kp_html/kp/codes_list.html
@@ -66,8 +66,8 @@
                                        
                                        
                                        <div>
                                            剩<span :class="{'red':item.left_count <=4}">{{item.left_count}}</span>笔<span>{{item.left_money}}/封单{{item.buy1_money}}【比例:{{item.trade_progress_percent+'%'}}】</span>,已成大单
                                             {{item.big_num_count}}笔{{item.big_num_money}}&nbsp; 待成前大单{{item.not_deal_big_num_count[0]}}笔{{item.not_deal_big_num_money[0]}}&nbsp; 待成后大单{{item.not_deal_big_num_count[1]}}笔{{item.not_deal_big_num_money[1]}}
                                            剩<span :class="{'red':item.left_count <=4}">{{item.left_count}}</span>笔<span>{{item.left_money}}/封单<span :class="{'red':item.buy1_money_warning}">{{item.buy1_money}}</span>【比例:{{item.trade_progress_percent+'%'}}】</span>,已成大单
                                             {{item.big_num_count}}笔{{item.big_num_money}}&nbsp; 待成前大单{{item.not_deal_big_num_count[0]}}笔{{item.not_deal_big_num_money[0]}}&nbsp; 待成后大单{{item.not_deal_big_num_count[1]}}笔{{item.not_deal_big_num_money[1]}},涨停价:{{item.limit_up_price}}元
                                        </div>
                                    </div>
                                    
kp_html/kp/index23-05-04.html
@@ -12,6 +12,8 @@
        <script src="layui/layui.js"></script>
        <script src="js/kpl.js"></script>
        <script src="js/vconsole.min.js"></script>
        <script src="js/chart.js"></script>
        <script src="js/chartjs-plugin-datalabels.min.js"></script>
        <style>
        </style>
@@ -120,7 +122,7 @@
                                <tr>
                                    <td><span class="bold">板块</span></td>
                                    <td class="budinggundong">
                                        <div>
                                        <div class="scroll-y" style="height: 93px;;">
                                            <span v-for="(item,i) in kpl_code_info.plate"
                                                class="label-style">{{item[1]}}</span>
                                        </div>
@@ -138,7 +140,7 @@
                                <tr  v-if="yesterday_block_info">
                                    <td><span  class="bold">同原因昨日涨停</span></td>
                                    <td class="budinggundong">
                                        <div style="max-height: 100px;" class="scroll-y">
                                        <div style="height: 80px;" class="scroll-y">
                                            <span v-for="(item,i) in yesterday_block_info.data.yesterday"
                                                class="label-style" >{{item[1]}}({{item[0]}})(<span :class="{'red': item[2]>0,'green':item[2]<0,'white':item[2]==0}">{{item[2]}}%</span>)
                                                </span>
@@ -149,7 +151,7 @@
                                <tr  v-if="yesterday_block_info">
                                    <td><span  class="bold">同原因今日涨停</span></td>
                                    <td class="budinggundong">
                                        <div style="max-height: 90px;" class="scroll-y">
                                        <div style="height: 80px;" class="scroll-y">
                                            <span v-for="(item,i) in yesterday_block_info.data.current"
                                                class="label-style">{{item[1]}}({{item[0]}})</span>
                                        </div>
@@ -168,6 +170,11 @@
                                    @click="get_jingxuan_data(0)">精选流入</div>
                                <div class="child-title" :class="{'child-title-active':jingxuan_data_type==1}"
                                    @click="get_jingxuan_data(1)">精选流出</div>
                                <div class="child-title" :class="{'child-title-active':industry_data_type==0}"
                                    @click="get_industry_data(0)">行业流入</div>
                                <div class="child-title" :class="{'child-title-active':industry_data_type==1}"
                                    @click="get_industry_data(1)">行业流出</div>
                            </caption>
                            <thead>
@@ -193,30 +200,21 @@
                            </tbody>
                        </table>
                        <table style="width: 520px;">
                        <table style="width: 520px;height: 180px;">
                            <caption class="table-name">
                                <div class="child-title" :class="{'child-title-active':industry_data_type==0}"
                                    @click="get_industry_data(0)">行业流入</div>
                                <div class="child-title" :class="{'child-title-active':industry_data_type==1}"
                                    @click="get_industry_data(1)">行业流出</div>
                                市场情绪
                            </caption>
                            <thead>
                            </thead>
                            <tbody>
                                <tr style="padding:0px;">
                                    <td style="padding:0px;">
                                        <div class="market-container">
                                            <div class="item" v-for="(item,index) in industry_datas">
                                                <span :class="{'green':item[4]==1}">{{item[1]}}</span>
                                                <span :class="{'green':item[4]==1}">{{money_desc(item[3])}}</span>
                                                <span class='delete'
                                                    :style="{'visibility':item[4]==1?'hidden':'visible' }"><img
                                                        src="images/delete.png"
                                                        v-on:click="forbidden_plate(item[1],0)"></span>
                                            </div>
                                        <canvas id="market_feeling_chart" width="100%" height="25"></canvas>
                                        <div style="padding-left: 10px;">
                                            <p> <span class="red"><span  class="red">涨停:【{{market_feeling_info.SJZT}}】家</span> &nbsp;&nbsp;&nbsp;&nbsp; <span  class="green">跌停:【{{market_feeling_info.SJDT}}】家</span> </p>
                                            <p> <span class="red">涨:【{{market_feeling_info.SZJS}}】家</span>  &nbsp;&nbsp;&nbsp;&nbsp;   <span  class="green">跌:【{{market_feeling_info.XDJS}}】家</span> </p>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
kp_html/kp/js/code_list.js
@@ -211,6 +211,17 @@
                                e.percent = 0;
                            }
                        });
                        result.data.delegates.forEach(function(e){
                            if(e.buy1_money.indexOf("万")&&parseFloat(e.buy1_money.substring(0,e.buy1_money.indexOf("万")))<2000){
                                //封单2000w以下提醒
                                e.buy1_money_warning =  1;
                            }else{
                                e.buy1_money_warning =  0;
                            }
                        });
                        app.delegated_buy_code_infos = result.data.delegates;
                        app.account_available_money = result.data.account_available_money;
                        app.reset_l2_height();
kp_html/kp/js/http.js
@@ -273,7 +273,11 @@
            result = JSON.parse(result);
            callback(result);
        });
    }
    },
    get_kpl_market_feelings:function(callback){
        var params={}
        http_util.http_request("/get_kpl_market_feelings", params, callback);
    },
    
    
    
kp_html/kp/js/page.js
@@ -12,8 +12,9 @@
var app;
$(function() {
    function _resize() {
        var code_info_height = 440
        var code_info_height = 440
        console.log("总高", $(window).height())
        var bottom_height = $(window).height() - code_info_height - 140;
        console.log("底部高", bottom_height)
@@ -74,6 +75,14 @@
    }, 3000, 10000);
    setInterval(function() {
        if (is_trade_time() || true) {
            app.get_kpl_market_feelings();
        }
    }, 3000, 3000);
@@ -90,7 +99,7 @@
                    order: 0
                },
                // 代码的开盘啦涨停原因
                kpl_limit_up_reason:'',
                kpl_limit_up_reason: '',
                default_score_data: {
                    volume: {
                        "score": 0,
@@ -233,14 +242,16 @@
                        ["板块2", "0.5%", '']
                    ]
                },
                yesterday_block_info:{
                    reason:"测试",
                    data:{
                        yesterday:[["000333","美的集团"]],
                        current:[]
                yesterday_block_info: {
                    reason: "测试",
                    data: {
                        yesterday: [
                            ["000333", "美的集团"]
                        ],
                        current: []
                    }
                },
                },
                initiative_buy_codes: [{
                    "name": "美的集团",
                    "code": "000333",
@@ -283,7 +294,9 @@
                    open_limit_up_count: 10,
                    limit_up_codes: [
                        //(代码,名称,涨停状态(0-无状态 1-涨停 2-炸板),龙几,首板,分值,涨停时间,原因,相同原因代码数量,自由流通,之前的板块)
                        ["000333", "美的集团", 1, "龙1", "首板", "200", "10:00:00", "一季度增长", "1", "12.02亿",'12亿', '','']
                        ["000333", "美的集团", 1, "龙1", "首板", "200", "10:00:00", "一季度增长", "1", "12.02亿",
                            '12亿', '', ''
                        ]
                    ]
                },
                //选中代码信息
@@ -356,10 +369,12 @@
                    first: '',
                    second: ''
                },
                industry_data_type: 0,
                industry_data_type: -1,
                jingxuan_data_type: 0,
                // 选股宝涨停原因
                xgb_limit_up_reasons:null,
                xgb_limit_up_reasons: null,
                // 市场情绪
                market_feeling_info: {}
            },
            watch: {
                want_codes: function() {
@@ -386,16 +401,24 @@
                },
                //获取行业数据
                get_industry_data: function(type) {
                    if (type < 0) {
                        return;
                    }
                    app.industry_data_type = type;
                    app.jingxuan_data_type = -1;
                    http_util.get_market_data(app.industry_data_type, function(result) {
                        result = JSON.parse(result);
                        if (result.code == 0) {
                            app.industry_datas = result.data;
                            app.jingxuan_datas = result.data;
                        }
                    });
                },
                get_jingxuan_data: function(type) {
                    if (type < 0) {
                        return;
                    }
                    app.jingxuan_data_type = type;
                    app.industry_data_type = -1;
                    if (type == 0) {
                        type = 2;
                    } else {
@@ -428,7 +451,7 @@
                                    order: res.data.trade_data.trade_state.order
                                }
                            } else {
                                res.data.trade_data= {
                                res.data.trade_data = {
                                    order: false
                                };
                                app.trade_data = res.data.trade_data
@@ -459,14 +482,14 @@
                        if (res.code == 0) {
                            app.first_info = res.data
                            var temps = new Array();
                            app.first_info.limit_up_reason_statistic.forEach(function(d){
                                if(d[0]==app.kpl_limit_up_reason){
                            app.first_info.limit_up_reason_statistic.forEach(function(d) {
                                if (d[0] == app.kpl_limit_up_reason) {
                                    current_limit_up_reason = d;
                                }else{
                                } else {
                                    temps.push(d);
                                }
                            });
                            if(current_limit_up_reason){
                            if (current_limit_up_reason) {
                                temps.unshift(current_limit_up_reason);
                            }
                            app.first_info.limit_up_reason_statistic = temps;
@@ -527,8 +550,10 @@
                    if (app.choose_code.first != app.first_info.limit_up_codes[index][0]) {
                        app.choose_code.first = app.first_info.limit_up_codes[index][0];
                        app.code = app.first_info.limit_up_codes[index][0];
                        app.code_name = app.code + "("+ app.first_info.limit_up_codes[index][1]+")";
                        app.get_score_data(app.first_info.limit_up_codes[index][0], app.first_info.limit_up_codes[index][1]);
                        app.code_name = app.code + "(" + app.first_info.limit_up_codes[index][1] +
                            ")";
                        app.get_score_data(app.first_info.limit_up_codes[index][0], app.first_info
                            .limit_up_codes[index][1]);
                        app.get_plate_info(app.first_info.limit_up_codes[index][0]);
                        app.get_last_trade_day_reasons(app.first_info.limit_up_codes[index][0]);
                    }
@@ -573,7 +598,8 @@
                                }
                            });
                        app.get_last_trade_day_reasons(app.choose_code_info.code_list_info[index].code_info[0]);
                        app.get_last_trade_day_reasons(app.choose_code_info.code_list_info[index]
                            .code_info[0]);
                    }
                },
                //删除二级代码
@@ -609,53 +635,57 @@
                    app.origin_code = code;
                    app.code = code;
                    app.code_name = code;
                    app.first_info.limit_up_codes.forEach(function(e){
                        if(e[0] == code){
                    app.first_info.limit_up_codes.forEach(function(e) {
                        if (e[0] == code) {
                            app.code_name = e[1] + " " + e[0];
                        }
                    });
                    http_util.get_xgb_limit_up_reasons(code,function(res){
                        console.log("选股宝请求结果:",res);
                    http_util.get_xgb_limit_up_reasons(code, function(res) {
                        console.log("选股宝请求结果:", res);
                        res = JSON.parse(res)
                        if(res.code==0){
                        if (res.code == 0) {
                            app.xgb_limit_up_reasons = res.data;
                            console.log(app.xgb_limit_up_reasons.reasons)
                        }else{
                        } else {
                            app.xgb_limit_up_reasons = null;
                        }
                    });
                    //请求板块
                    setTimeout(function(){
                        http_util.get_kpl_block_info(code,function(res){
                    setTimeout(function() {
                        http_util.get_kpl_block_info(code, function(res) {
                            res = JSON.parse(res)
                            console.log("板块请求结果:",res);
                            if(res.code==0){
                            console.log("板块请求结果:", res);
                            if (res.code == 0) {
                                app.kpl_code_info = res.data;
                                // 设置当日涨停原因
                                app.kpl_limit_up_reason = app.kpl_code_info.today[0][0];
                                app.kpl_limit_up_reason = app.kpl_code_info.today[0]
                                    [0];
                                // 将当前涨停原因置顶
                                var limit_up_reason_statistic =  app.first_info.limit_up_reason_statistic;
                                var limit_up_reason_statistic = app.first_info
                                    .limit_up_reason_statistic;
                                var current_limit_up_reason;
                                if(limit_up_reason_statistic){
                                if (limit_up_reason_statistic) {
                                    var temps = new Array();
                                    limit_up_reason_statistic.forEach(function(d){
                                        if(d[0]==app.kpl_limit_up_reason){
                                    limit_up_reason_statistic.forEach(function(d) {
                                        if (d[0] == app
                                            .kpl_limit_up_reason) {
                                            current_limit_up_reason = d;
                                        }else{
                                        } else {
                                            temps.push(d);
                                        }
                                    });
                                    if(current_limit_up_reason){
                                    if (current_limit_up_reason) {
                                        temps.unshift(current_limit_up_reason);
                                    }
                                    app.first_info.limit_up_reason_statistic = temps;
                                    app.first_info.limit_up_reason_statistic =
                                        temps;
                                }
                            }
                        });
                        app.get_last_trade_day_reasons(code);
                    },10);
                    }, 10);
                    //init_data();
                },
                show_want_codes: function(plate) {
@@ -686,17 +716,79 @@
                            }
                        });
                },
                get_last_trade_day_reasons:function(code){
                    http_util.get_last_trade_day_reasons(code,function(res){
                get_last_trade_day_reasons: function(code) {
                    http_util.get_last_trade_day_reasons(code, function(res) {
                        res = JSON.parse(res);
                        console.log("板块今日表现:",res)
                        if(res.code == 0){
                        console.log("板块今日表现:", res)
                        if (res.code == 0) {
                            app.yesterday_block_info = res.data;
                        }else{
                        } else {
                            app.yesterday_block_info = null;
                        }
                    });
                },
                get_kpl_market_feelings: function() {
                    http_util.get_kpl_market_feelings(function(res) {
                        console.log(res);
                        res = JSON.parse(res);
                        if (res.code == 0) {
                            app.market_feeling_info = res.data;
                            labels = [];
                            values = [];
                            colors = [];
                            res.data.map.forEach(function(e) {
                                labels.push(e[0]);
                                values.push(e[1]);
                                colors.push(e[2]);
                            });
                            console.log(colors);
                            if (!app.market_feeling_chart) {
                                app.market_feeling_chart = new Chart($(
                                    "#market_feeling_chart"), {
                                    type: 'bar',
                                    data: {
                                        labels: labels,
                                        datasets: [{
                                            label: '市场情绪',
                                            data: values,
                                            backgroundColor: colors,
                                        }]
                                    },
                                    itemStyle: {
                                    },
                                    options: {
                                        plugins: {
                                            legend: {
                                                display: false // 隐藏图例
                                            },
                                        },
                                        scales: {
                                            y: {
                                                display: true
                                            },
                                            x: {
                                                grid: {
                                                    display: false,
                                                }
                                            },
                                        }
                                    }
                                });
                            } else {
                                app.market_feeling_chart.data.labels = labels;
                                app.market_feeling_chart.data.datasets[0].data = values;
                                app.market_feeling_chart.data.datasets[0].backgroundColor =
                                    colors;
                                app.market_feeling_chart.update();
                            }
                        }
                    });
                }
            }
        });
kpl/kpl_api.py
@@ -173,6 +173,16 @@
    return json.dumps({"errcode": 0, "list": fresults})
# 数据格式:
# SJZT:实际涨停  SJDT:实际跌停 SZJS:涨数量 ZT:涨停 DT:跌停  XDJS:跌数量  sign:人气概述
def getMarketFelling():
    result = __base_request("https://apphwhq.longhuvip.com/w1/api/index.php",
                            f"a=ZhangFuDetail&apiv=w35&c=HomeDingPan&PhoneOSNew=1&DeviceID=d6f20ce9-fa08-31c9-a493-536ebb8e9774&VerSion=5.13.0.0&")
    data = result.text
    data = json.loads(data)
    return data["info"]
def test_l2():
    code = "600981"
    count = 0
@@ -187,6 +197,4 @@
if __name__ == '__main__':
    result = get_jingxuan_block("600753")
    result = json.loads(result)
    print(result["ListJX"])
    print(getMarketFelling())
main.py
@@ -117,6 +117,9 @@
        threading.Thread(target=lambda: ths_util.add_code_to_zixuan(code), daemon=True).start()
class SecondWindowBridgeClass(BaseBridgeClass):
    @pyqtSlot(str)
    def set_target_code(self, code):
network_delegate_manager.py
@@ -31,6 +31,10 @@
        elif url.startswith("/get_xgb_limit_up_reasons"):
            return cls.__get_xgb_limit_up_reasons(url)
        elif url.startswith("/get_kpl_market_feelings"):
            return cls.__get_kpl_market_feelings()
        return None, False
    @classmethod
@@ -240,9 +244,32 @@
        return response_data, True
    @classmethod
    def __get_kpl_market_feelings(cls):
        market_feelings = kpl_api.getMarketFelling()
        ps = [('涨停', market_feelings['ZT'], 'red')]
        ps.append(('>%7', int(market_feelings['8']) + int(market_feelings['9']) + int(
            market_feelings['10']), 'red'))
        ps.append(('7~5%', int(market_feelings['6']) + int(market_feelings['7']), 'red'))
        ps.append(('5~2%', int(market_feelings['3']) + int(market_feelings['4']) + int(market_feelings['5']), 'red'))
        ps.append(('2~0%', int(market_feelings['2']) + int(market_feelings['1']), 'red'))
        ps.append(('平', int(market_feelings['0']), 'gray'))
        ps.append(('0~2%', int(market_feelings['-1']) + int(market_feelings['-2']), 'green'))
        ps.append(
            ('2~5%', int(market_feelings['-3']) + int(market_feelings['-4']) + int(market_feelings['-5']), 'green'))
        ps.append(('5~7%', int(market_feelings['-6']) + int(market_feelings['-7']), 'green'))
        ps.append(
            ('7%<', int(market_feelings['-8']) + int(market_feelings['-9']) + int(market_feelings['-10']), 'green'))
        ps.append(('跌停', market_feelings['DT'], 'green'))
        fdata = {"map": ps, "SJZT": market_feelings['SJZT'], "SJDT": market_feelings['SJDT'],
                 "SZJS": market_feelings['SZJS'], "XDJS": market_feelings['XDJS'], "sign": market_feelings['sign']}
        # 获取市场情绪
        return json.dumps(
                {"code": 0, "data": fdata}), True
if __name__ == "__main__":
    codes = ["002523", "603095"]
    datas = LocalKanPanNetworkDelegate.get_codes_limit_rate(codes)
    datas = LocalKanPanNetworkDelegate.get_codes_limit_rate(codes)
    datas = LocalKanPanNetworkDelegate.get_kpl_market_feelings(codes)
    print(datas)