python6.4项目:股票提醒系统


import tushare
import time
def getdata(share):
data=tushare.get_realtime_quotes(share.code)
share.name=data.loc[0][0]
share.price=float(data.loc[0][3])
share.high=data.loc[0][4]
share.low=data.loc[0][5]
share.volumn=data.loc[0][8]
share.amount=data.loc[0][9]
share.pre_open=data.loc[0][1]
share.pre_close=data.loc[0][2]
share.time1=data.loc[0][30]

share.describe="股票名:"+share.name,"当前价格:"+str(share.price)
return share
class share():
def __init__(self,code,buy,sale):
self.name=""
self.price=""
self.high=""
self.low=""
self.volumn=""
self.amount=""
self.pre_open=""
self.pre_close=""
self.time1=""
self.describe=""
self.code=code
self.buy=buy
self.sale=sale
def main(sharelist):
for share in sharelist:

sss=getdata(share)
print(sss.describe)
if sss.price<=sss.buy:
print("到达买点,赶紧买!")
elif sss.price>=sss.sale:
print("到达卖点,有货赶紧卖!")
else:
print("别买也别买,等机会!")
while 1==1:
share1=share("002938",28.20,29.30)
share2=share("601988",3.5,3.8)
share3=share("000591",3.2,3.5)
list1=[share1,share2,share3]
print("........")
main(list1)
time.sleep(10)

 

猜你喜欢

转载自www.cnblogs.com/lma0702/p/11111916.html