Esempio n. 1
0
def stockPriceAlert(stockNum,priceAlert,type=-1):
    print stockNum,priceAlert,type
    priceAlert = float(priceAlert)
    type = int(type)
    stockName,nowPrice,yesterdayPrice,maxPrice,minPrice,changeRate = stockDetail(stockNum)
    #print stockName,nowPrice,yesterdayPrice,maxPrice,minPrice,changeRate
    msg = ''
    if (type == -1)  and (priceAlert >= float(nowPrice)):
        msg = stockNum + ' fall bellow ' + str(priceAlert) + ',Now:' + str(nowPrice)
    elif (type == 1) and (priceAlert <= float(nowPrice)):
        msg = stockNum + ' goes over ' + str(priceAlert) + ',Now:' + str(nowPrice)
    if msg != '':
        print msg
        smsHandle.sendSMS(msg)
        #stockPriceAlert(stockNum,priceAlert*(1-1/100.0),-1)
        
        threads=[]
        t = MyThread(stockPriceAlert,(stockNum,priceAlert*(1-1/100.0),-1),stockPriceAlert.__name__)
        threads.append(t)
        t = MyThread(stockPriceAlert,(stockNum,priceAlert*(1+1/100.0),1),stockPriceAlert.__name__)
        threads.append(t)
        for i in threads:
            i.start()
    else:
        sleep(5)
        stockPriceAlert(stockNum,priceAlert,type)
Esempio n. 2
0
def getNowOptionsExpectGains(stockNum):
    
    dic = getOptionDetails(stockNum)
    for agreementName in dic:
        print agreementName
        optionExpectGains(stockNum,agreementName,dic[agreementName]['AVGPrice'])
        sleep(5)
Esempio n. 3
0
def stockPriceMonitor(stockNum,AVGPrice,rate=0.01):
    AVGPrice = float(AVGPrice)
    rate = float(rate)
    stockName,nowPrice,yesterdayPrice,maxPrice,minPrice,changeRate = stockDetail(stockNum)
    nowPrice = float(nowPrice)
    #print stockName,nowPrice,yesterdayPrice,maxPrice,minPrice,changeRate
    change = (nowPrice - AVGPrice)/AVGPrice
    msg = ''
    if abs(change) >= rate:
        msg = stockNum + ' change:' + str(int(change*10000)/100.0) + '% | ' + str(AVGPrice) + ' -> ' + str(nowPrice)
    if msg != '':
            print msg
            smsHandle.sendSMS(msg)
            stockPriceMonitor(stockNum,float(nowPrice))
    else:
        sleep(5)
        stockPriceMonitor(stockNum,float(AVGPrice))
Esempio n. 4
0
    sData = BeautifulSoup.BeautifulSoup(data)
    
    lists = sData.find('article',{})
    firstDiv = lists.div
    print firstDiv
    sys.exit()
    userName = firstDiv.a.contents[0]
    content = replaceSign(firstDiv.a.nextSibling,0)
    time = replaceSign(firstDiv.find('span',{'class':'info'}).contents[0])
    
    if time <= dateToday():
        #sms.SMS().sendSMS(content)
        to='*****@*****.**'
        subj= 'New message from ' + userName + ' in weibo'
        text = content
        if text not in sended:
            try:
                myEmail.sendmessage(server,subj,text,to)
                sended.append(text)
            except Exception,e:
                print e
    sleep(10)
    weiboFollowing(id)

if __name__ == '__main__':
    try:
        if sys.argv[1] != '':
            weiboFollowing(sys.argv[1])
    except:
        print "usage: weibo.py id \nNow following __moka__(the author's love)"
        weiboFollowing(1843543427)
Esempio n. 5
0
    lists = sData.find('article', {})
    firstDiv = lists.div
    print firstDiv
    sys.exit()
    userName = firstDiv.a.contents[0]
    content = replaceSign(firstDiv.a.nextSibling, 0)
    time = replaceSign(firstDiv.find('span', {'class': 'info'}).contents[0])

    if time <= dateToday():
        #sms.SMS().sendSMS(content)
        to = '*****@*****.**'
        subj = 'New message from ' + userName + ' in weibo'
        text = content
        if text not in sended:
            try:
                myEmail.sendmessage(server, subj, text, to)
                sended.append(text)
            except Exception, e:
                print e
    sleep(10)
    weiboFollowing(id)


if __name__ == '__main__':
    try:
        if sys.argv[1] != '':
            weiboFollowing(sys.argv[1])
    except:
        print "usage: weibo.py id \nNow following __moka__(the author's love)"
        weiboFollowing(1843543427)