import fund_stockquote import sys ticker = sys.argv[1] # test get_volume and get_average_volume print "get_price = ", fund_stockquote.get_price(ticker) print "get_volume = ", fund_stockquote.get_volume(ticker) print "get_ebitda = ", fund_stockquote.get_ebitd(ticker) print "get_average_volume = ", fund_stockquote.get_average_volume(ticker) print "get_todays_high = ", fund_stockquote.get_todays_high(ticker) print "get_todays_low = ", fund_stockquote.get_todays_low(ticker)
#analyze the result # envaluate yesterday's result pf_result_file = 'pf_result.txt' fpf = open(pf_result_file, 'w+') fh = open('trading_result.txt', 'r+') lines = fh.readlines() for line in lines: print line if(re.match( r'^#', line, re.M|re.I) or re.match( r'^\s+', line, re.M|re.I)): pass else: ticker, yes_price, yes_average = line.split() print 'ticker = ', ticker, '\n' print 'yes_price = ', yes_price, '\n' print 'yes_average = ', yes_average, '\n' if(float(fund_stockquote.get_price(ticker)) > float(yes_price)): fpf.write('%s predict good :)\n'%(ticker)) else: fpf.write('%s predict wrong :(\n'%(ticker)) fh.close() fpf.close() #-------------------------------------------- sorted_trading_value = sorted(old_strategy.earning_stock.iteritems(), key=operator.itemgetter(1)) sorted_buying_value = sorted(old_strategy.buying_stock.iteritems(), key=operator.itemgetter(1)) #print old_strategy.earning_stock #print sorted_value ts = datetime.date.today() history_choice = 'trading_%s'%(ts)
# envaluate yesterday's result pf_result_file = 'pf_result.txt' fpf = open(pf_result_file, 'w+') fh = open('trading_result.txt', 'r+') lines = fh.readlines() for line in lines: print line if (re.match(r'^#', line, re.M | re.I) or re.match(r'^\s+', line, re.M | re.I)): pass else: ticker, yes_price, yes_average = line.split() print 'ticker = ', ticker, '\n' print 'yes_price = ', yes_price, '\n' print 'yes_average = ', yes_average, '\n' if (float(fund_stockquote.get_price(ticker)) > float(yes_price)): fpf.write('%s predict good :)\n' % (ticker)) else: fpf.write('%s predict wrong :(\n' % (ticker)) fh.close() fpf.close() #-------------------------------------------- sorted_trading_value = sorted( old_strategy.earning_stock.iteritems(), key=operator.itemgetter(1)) sorted_buying_value = sorted(old_strategy.buying_stock.iteritems(), key=operator.itemgetter(1)) #print old_strategy.earning_stock #print sorted_value
import fund_stockquote ticker = "jst" # test get_volume and get_average_volume print "get_price = ", fund_stockquote.get_price(ticker) print "get_volume = ", fund_stockquote.get_volume(ticker) print "get_average_volume = ", fund_stockquote.get_average_volume(ticker) print "get_todays_high = ", fund_stockquote.get_todays_high(ticker) print "get_todays_low = ", fund_stockquote.get_todays_low(ticker)