strSql="SELECT SUM(sell_price-buy_price) FROM view_match_news_stock WHERE TO_DAYS(%s)=TO_DAYS(news_time) AND newsUptrendMan=1 AND buy_price > 0.0 AND sell_price>0.0"%pretime
printstrSql
print(strSql)
cur.execute(strSql)
conn.commit()
result=cur.fetchall()
...
...
@@ -51,34 +49,34 @@ def stat_calcprofit(ndays):
ifprofitisNone:
profit=0
printprofit
print(profit)
strSql="SELECT COUNT(DISTINCT(news_id)) FROM view_match_news_stock WHERE TO_DAYS(%s)=TO_DAYS(news_time) AND newsUptrendMan=1 AND buy_price > 0.0 AND sell_price>0.0"%pretime
printstrSql
print(strSql)
cur.execute(strSql)
conn.commit()
result=cur.fetchall()
numNews=list(result)[0][0]
printnumNews
print(numNews)
strSql="SELECT COUNT(DISTINCT(stock_code)) FROM view_match_news_stock WHERE TO_DAYS(%s)=TO_DAYS(news_time) AND newsUptrendMan=1 AND buy_price > 0.0 AND sell_price>0.0"%pretime
printstrSql
print(strSql)
cur.execute(strSql)
conn.commit()
result=cur.fetchall()
numStock=list(result)[0][0]
printnumStock
print(numStock)
now=time.localtime()
str_time=time.strftime('%Y-%m-%d',now)
sqlCount="SELECT COUNT(*) FROM tbl_stats WHERE DATE_FORMAT(create_datetime, \"%Y-%m-%d\")=DATE_FORMAT(\""+str(str_time)+"\", \"%Y-%m-%d\")"
printsqlCount
print(sqlCount)
#判断是否已存在
cur.execute(sqlCount)
conn.commit()
result=cur.fetchall()
numCount=list(result)[0][0]+0
printnumCount
print(numCount)
# print "matchid:" + str(matchid)
# print "sellprice: " + str(sellprice)
...
...
@@ -89,10 +87,10 @@ def stat_calcprofit(ndays):
else:
strSql="update tbl_stats set profit=\""+str(profit)+"\",num_news=\""+str(numNews)+"\",num_stocks=\""+str(numStock)+\
"\" WHERE DATE_FORMAT(create_datetime, \"%Y-%m-%d\")=DATE_FORMAT(\""+str(str_time)+"\", \"%Y-%m-%d\")"
"select * from tbl_match where news_fk_id in (select id from tbl_news where TO_DAYS(news_time)=TO_DAYS(%s) and newsUptrendMan=1) and buy_price is not null"%pretime)