1234567891011121314151617181920212223242526272829303132333435363738 |
- from jqdatasdk import *
- from datetime import datetime as dt
- import pandas as pd
- import pymysql
- from sqlalchemy import create_engine
- import time
- auth('18616891214', 'Ea?*7f68nD.dafcW34d!')
- # fre = ['30m', '1d']
- engine_hlfx_pool = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/hlfx_pool?charset=utf8')
- stock_pool = pd.read_sql_query(
- 'select value from MA5_1d', engine_hlfx_pool)
- stock_pool = stock_pool.iloc[-2, 0].split(",")
- print(type(stock_pool), len(stock_pool),stock_pool)
- num_industry = get_industry(stock_pool)
- print(num_industry)
- results = []
- a = []
- for key in num_industry.values():
- for key2 in key.values():
- results.append(key2['industry_name'])
- results = pd.value_counts(results)
- print(results)
- results = results[0:3]
- results = list(results.index)
- print(results)
- for key,value in num_industry.items():
- for key2 in value.values():
- if key2['industry_name'] in results:
- a.append(key)
- print(set(a))
|