Ejemplo n.º 1
0
from base.stock import getAStocks
from utils.timeutil import getLastWeekDay

if __name__ == '__main__':

    lastWeekDay = getLastWeekDay()

    fileName = str(lastWeekDay) + "-" + "stock.csv"

    print("getting %s stocks list"%lastWeekDay)

    stocks = getAStocks(lastWeekDay)

    print('saving %s stocks to: %s'%(lastWeekDay,fileName))
    stocks.to_csv(fileName,encoding='gbk', index=False)


Ejemplo n.º 2
0
Archivo: pe.py Proyecto: zzArche/quant
# coding=utf8
'''
筛选符合市盈率条件的股票
'''

from base.stock import getAStocks
from utils.timeutil import getLastWeekDay


def peFilter(stocks, peLimit):
    for code, stock in stocks.iterrows():
        pe = float(stock['peTTM'])
        if pe <= 0 or pe > peLimit:
            stocks.drop(code, inplace=True)
    return stocks


if __name__ == "__main__":
    stocks = getAStocks(getLastWeekDay())
    stocks = peFilter(stocks, 9)

    print("low pe stocks total has: %s" % len(stocks))

    for code, stock in stocks.iterrows():
        print(code, stock['name'], stock['peTTM'])
Ejemplo n.º 3
0
        for quarter in range(lastQuarter, 0, -1):  # 往期盈利数据

            print("query %s %s year %s quarter profit:" %
                  (code, currentYear - years, quarter))
            profit = getProfit(code, currentYear - years, quarter)

            if profit is not None:
                try:
                    oldProfit = float(profit['netProfit'])
                except Exception:
                    oldProfit = 0  # 未找到对应数据
            else:
                oldProfit = 0

            if oldProfit != 0:
                break

        print("%s current profit is: %s,old profit is: %s" %
              (code, currentProfit, oldProfit))

        if currentProfit <= oldProfit:
            stocks.drop(index, inplace=True)

    return stocks


if __name__ == "__main__":
    stocks = getAStocks('2020-03-23')

    growFilter(stocks, 5)
    pass