def getStockInfoFromMsg(targetStockMsg): tempStockNumber = int(filter(str.isdigit, targetStockMsg)) #取得要查詢的目標股票號碼 tempAskString = "系統接收到使用者請求對股票資訊的查詢 股票查詢代碼為" + str( tempStockNumber) + NEWLINE #Debug Log紀錄 stock = Stock(str(tempStockNumber)) #擷取特定股價相關資訊 tempMovingAverageString = "計算五日均價與持續天數" + str( stock.moving_average(5)) + NEWLINE tempMovingAverageValueString = "計算五日均量與持續天數" + str( stock.moving_average_value(5)) + NEWLINE tempMovingAverageBiasRatio = "計算五日、十日乖離值與持續天數" + str( stock.moving_average_bias_ratio(5, 10)) + NEWLINE return tempAskString + tempMovingAverageString + tempMovingAverageValueString + tempMovingAverageBiasRatio + STOCKRIGHT
from grs import Stock stock = Stock('2454') #get the price for Stock number 2618 print stock.moving_average(5) print stock.moving_average_value(5) print stock.moving_average_bias_ratio(5, 10) stock = Stock('2454', 12) stock.out_putfile('2454.csv')
def getgrsdata(): stock = Stock('2618') print stock.moving_average(5)