实时量化选股-tushare利用

量化选股的常用python模块,介绍tushare使用中,总结的一些短代码

import tushare as ts

symbols = ts.get_stock_basics()

st = ts.get_st_classified()

lv_price_1 = 50

def isSt(stockID):

    for sti in st.code:

        if sti == stockID:

            return True

    return False

for inx in range(len(symbols)):

    symbol = symbols.index[inx]

    df = ts.get_k_data(symbol, ktype='60', start=start_day)

1,过滤停牌

xn = len(df.index)-1

if type(df) != type(None) and xn >= 0 and df.ix[xn]['date'] != endToday:              

      continue

2,过滤高价股

if type(df) != type(None) and xn >= 0 and df.ix[xn]['close'] > lv_price_1 ):

                continue

3,过滤PE

pe = symbols.ix[inx]['pe']

        if pe < 20:

        continue

4,过滤ST

if isSt(symbol):

            continue

更多见开源项目 https://gitee.com/yquant/YKQuantPublisher

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,452评论 0 10
  • "use strict";function _classCallCheck(e,t){if(!(e instanc...
    久些阅读 2,059评论 0 2
  • { "Unterminated string literal.": "未终止的字符串文本。", "Identifi...
    一粒沙随风飘摇阅读 10,794评论 0 3
  • 题记: 我原以为距离与时间的逃离可以忘掉一切,没想到我可以逃离一个人,逃离一座城,却逃离不了那刻骨铭心的回忆。 翻...
    我行走带风阅读 584评论 0 0
  • 果然如二人所料,接下来的日子里,那个叫做提仔的愣头青果然没少给李朝凤找麻烦,不管是出工也好放风也好,有事没事都...
    潇湘楚裔阅读 394评论 0 0