Home > Backend Development > Python Tutorial > Teach you to use Python to quickly obtain industry sector stocks to assist value investment!

Teach you to use Python to quickly obtain industry sector stocks to assist value investment!

王林
Release: 2023-04-14 10:49:02
forward
1890 people have browsed it

Teach you to use Python to quickly obtain industry sector stocks to assist value investment!

1. Industry sectors

There is a big difference in definition between industry sectors and concept stocks.

Generally speaking, the concept sector has greater risks. It is short-term hyped based on a certain news, which is very unstable, so the risk is greater.

Industry sectors are classified according to stock industries, and often focus on In the long term, the stability is higher.

In terms of actual investment, In the short term, you can select stocks from concept stocks according to "market hot spots". In the medium and long term, it is recommended to select stocks according to "industry sectors" for investment.

2. Crawling related sectors and individual stock lists

Target target:

aHR0cDovL3N1bW1hcnkuanJqLmNvbS5jbi9oeWJrLw==

Teach you to use Python to quickly obtain industry sector stocks to assist value investment!

2-1 Section List

First, we use the "Toggle JavaScript" plug-in to discover that the industry sector data in the page comes from the following request results

//m.sbmmt.com/link/6e839dd93911f945cd02c9b15da23db0

Teach you to use Python to quickly obtain industry sector stocks to assist value investment!

The parameters are p and _dc is a variable parameter, p represents the page number (starting from 1), _dc represents the 13-digit timestamp, and other query parameters are fixed content

Then, we write code to obtain the response Data, use regular expressions to match the data of the industry list

...
self.ps_url = 'http://**/?q=cn|bk|17&n=hqa&c=l&o=pl,d&p={}050&_dc={}'
....
    def __get_timestramp(self):
        """
        获取13位的时间戳
        :return:
        """
        return int(round(time.time() * 1000))
...
    def get_plates_list(self, plate_keyword):
        """
        获取所有板块
        :return:
        """
        plates = []

        index = 0
        while True:
            url = self.ps_url.format(index + 1, self.__get_timestramp())
            # 解析数据
            resp = self.session.get(url, headers=self.headers).text
            match = re.compile(r'HqData:(.*?)};', re.S)
            result = json.loads(re.findall(match, resp)[0].strip().replace("n", ""))
            if not result:
                break

            # 根据关键字,过滤有效板块
            temp_plate_list = [item for item in result if plate_keyword in item[2]]
            index += 1

            for item in temp_plate_list:
                print(item)

                plates.append({
                    "name": item[2],
                    "plate_path": item[1],
                    "up_or_down": str(item[10]) + "%",
                    "top_stock": item[-6]
                })
        return plates
...

Copy after login

Finally, filter the sectors based on keywords, through the sector name, sector path PATH, sector increase or decrease, and the name of the stock with the largest contribution Reassemble into a list

Note: Through the analysis page, it is found that according to the sector path PATH, it can be assembled into an industry sector stock list page URL

For example , the industry sector PATH is 400128925, Then the page URL of the industry sector corresponding stock list is

//m.sbmmt.com/link /0cb5ebb1b34ec343dfe135db691e4a85

2-2 Industry stock list

Crawling the industry stock list is the same as the data display logic in the previous step, and the stock list data also comes from the following The result of the request

//m.sbmmt.com/link/f9995e4c8a1e54123c64427a572d7917##​

Among them, bk corresponds to Industry sector PATH, p represents the page number, _dc represents the 13-digit timestamp

...
# 个股
self.stock_url = '//m.sbmmt.com/link/f9995e4c8a1e54123c64427a572d7917'
....
    def get_stock_list(self, plate_path):
        """
        获取某一个板块下所有的个股信息
        包含:股票名称、最新价格、涨跌幅、市盈率
        :param plate_info:
        :return:
        """
        index = 0
        stocks = []
        while True:
            url = self.stock_url.format(plate_path, index + 1, self.__get_timestramp())
            resp = self.session.get(url, headers=self.headers).text
            match = re.compile(r'HqData:(.*?)};', re.S)
            result = json.loads(re.findall(match, resp)[0].strip().replace("n", ""))
            if not result:
                break
            index += 1

            for item in result:
                if item[-1] < 0:
                    continue
                stocks.append({
                    "stock_name": item[2],
                    "pe": item[-1],
                    "price": item[8],
                    "up_or_down": str(item[12]) + "%"
                })

        # 按pe降序排列
        stocks.sort(key=lambda x: x["pe"])

        return stocks
Copy after login

After matching the response results through regular expressions, the 4 keys of the stock name, PE price-earnings ratio, price, and increase and decrease are obtained Data

Finally, sort the individual stock list in ascending order by PE and return directly

3. Servitization

Of course, we can service this part of the logic for front-end use. In order to improve the user experience

For example, using

FastAPI you can quickly create two services: obtain a list of industry sectors based on keywords, and obtain a list of individual stocks based on sector paths

<span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">from</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pydantic</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">import</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">BaseModel</span><br><br><span  style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 板块</span><br><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">class</span> <span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">Plate</span>(<span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">BaseModel</span>):<br>    <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">content</span>: <span  style="color: rgb(111, 66, 193); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">str</span>  <span  style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 关键字</span><br><br><br><span  style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 板块下的个股</span><br><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">class</span> <span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">PlateStock</span>(<span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">BaseModel</span>):<br>    <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plate_path</span>: <span  style="color: rgb(111, 66, 193); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">str</span>  <span  style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 板块路径</span><br><br><span  style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">#===========================================================</span><br><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">...</span><br><br><span  style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 获取板块列表</span><br><span  style="color: rgb(31, 127, 154); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">@</span><span  style="color: rgb(31, 127, 154); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">app</span>.<span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">post</span>(<span  style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">"/xag/plate_list"</span>)<br><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">async</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">def</span> <span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">get_plate_list</span>(<span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plate</span>: <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">Plate</span>):<br>    <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">PStock</span>()<br>    <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">try</span>:<br>        <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">result</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span>.<span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">get_plates_list</span>(<span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plate</span>.<span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">content</span>)<br>        <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">return</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">success</span>(<span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">data</span><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span><span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">result</span>, <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">message</span><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span><span  style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">"查询成功!"</span>)<br>    <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">except</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">Exception</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">as</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">e</span>:<br>        <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">return</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">fail</span>()<br>    <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">finally</span>:<br>        <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span>.<span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">teardown</span>()<br><br><br><span  style="color: rgb(106, 115, 125); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># 获取某一个板块下的所有股票列表</span><br><span  style="color: rgb(31, 127, 154); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">@</span><span  style="color: rgb(31, 127, 154); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">app</span>.<span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">post</span>(<span  style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">"/xag/plate_stock_list"</span>)<br><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">async</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">def</span> <span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">get_plate_list</span>(<span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plateStock</span>: <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">PlateStock</span>):<br>    <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">PStock</span>()<br>    <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">try</span>:<br>        <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">result</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span>.<span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">get_stock_list</span>(<span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plateStock</span>.<span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">plate_path</span>)<br>        <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">return</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">success</span>(<span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">data</span><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span><span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">result</span>, <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">message</span><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">=</span><span  style="color: rgb(102, 153, 0); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">"查询成功!"</span>)<br>    <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">except</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">Exception</span> <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">as</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">e</span>:<br>        <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">return</span> <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">fail</span>()<br>    <span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">finally</span>:<br>        <span  style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">pstock</span>.<span  style="color: rgb(0, 92, 197); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">teardown</span>()<br><span  style="color: rgb(215, 58, 73); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">...</span><br><br>
Copy after login

The front end takes

Uniapp as an example, using the uni-table component to display the industry sector list and individual stock list

Part of the code is as follows:

//个股列表 platestock.vue
...
<view >
                <uni-forms ref="baseForm" :modelValue="baseFormData" :rules="rules">
                    <uni-forms-item label="关键字" required name="content">
                        <uni-easyinput v-model="baseFormData.content" placeholder="板块关键字" />
                    </uni-forms-item>
                </uni-forms>
                <button type="primary" @click="submit('baseForm')">提交</button>

                <!-- 结果区域 -->
                <view  v-show="result.length>0">
                    <uni-table ref="table" border stripe emptyText="暂无数据">
                        <uni-tr >
                            <uni-th align="center"  width="100%">板块</uni-th>
                            <uni-th align="center"  width="100%">涨跌幅</uni-th>
                            <uni-th align="center"  width="100%">强势股</uni-th>
                        </uni-tr>
                        <uni-tr  v-for="(item, index) in result" :key="index" @row-click="rowclick(item)">
                            <uni-td  align="center">{{ item.name }}</uni-td>
                            <uni-td align="center" >{{ item.up_or_down }}</uni-td>
                            <uni-td align="center" >{{ item.top_stock }}</uni-td>
                        </uni-tr>
                    </uni-table>
                </view>
            </view>
...
methods: {
            //表单提交数据
            submit(ref) {
                this.$refs[ref].validate().then(res => {
                    this.$http('xag/plate_list', this.baseFormData, {
                        hideLoading: false,
                        hideMsg: false,
                        method: 'POST'
                    }).then(res => {
                        console.log("内容:", res.data)
                        if (res.data && res.data.length > 0) {
                            this.$tip.success("查询成功!")
                            this.result = res.data
                        } else {
                            this.$tip.success("查询结果为空,请换一个关键字查询!")
                        }
                    }).catch(err => {
                        console.log("产生异常,异常信息:", err)
                    })

                }).catch(err => {
                    console.log('err', err);
                })
            }
...
Copy after login

After the final deployment of the project , you can select appropriate stocks for investment based on the sector names on the front-end page

Teach you to use Python to quickly obtain industry sector stocks to assist value investment!

4. To summarize

Since industry sectors are more suitable for medium and long-term investment, we only need to filter out a sector based on a certain keyword, and then in the list of stocks under the sector, we can very intuitively see the stocks with lower price-to-earning ratios for investment.

The above is the detailed content of Teach you to use Python to quickly obtain industry sector stocks to assist value investment!. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:51cto.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template