bk_test.py 987 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. from jqdatasdk import *
  2. from datetime import datetime as dt
  3. import pandas as pd
  4. import pymysql
  5. from sqlalchemy import create_engine
  6. import time
  7. auth('18616891214', 'Ea?*7f68nD.dafcW34d!')
  8. # fre = ['30m', '1d']
  9. engine_hlfx_pool = create_engine('mysql+pymysql://root:r6kEwqWU9!v3@localhost:3307/hlfx_pool?charset=utf8')
  10. stock_pool = pd.read_sql_query(
  11. 'select value from MA5_1d', engine_hlfx_pool)
  12. stock_pool = stock_pool.iloc[-2, 0].split(",")
  13. print(type(stock_pool), len(stock_pool),stock_pool)
  14. num_industry = get_industry(stock_pool)
  15. print(num_industry)
  16. results = []
  17. a = []
  18. for key in num_industry.values():
  19. for key2 in key.values():
  20. results.append(key2['industry_name'])
  21. results = pd.value_counts(results)
  22. print(results)
  23. results = results[0:3]
  24. results = list(results.index)
  25. print(results)
  26. for key,value in num_industry.items():
  27. for key2 in value.values():
  28. if key2['industry_name'] in results:
  29. a.append(key)
  30. print(set(a))