コード例 #1
0
ファイル: unit_test.py プロジェクト: yuanpengwu/stockRun
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)
コード例 #2
0
			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)
                        os.system('cp %s history/%s'%(email_file, history_choice))
			
                        f1 = open('trading_result.txt', 'w+')
                        for entry in sorted_buying_value:
				if(fund_stockquote.eps_threshold(entry[0]) > 0 and (g_changing_range < (float(fund_stockquote.get_todays_high(entry[0])) - float(fund_stockquote.get_todays_low(entry[0])))/float(fund_stockquote.get_price(entry[0]))) and (float(fund_stockquote.get_volume(entry[0])) > 1.5*float(fund_stockquote.get_average_volume(entry[0]))) and (fund_stockquote.get_volume(entry[0]) > 1000000)):
					print entry[0]
                                #	f1.write('%s %s %s'%(str(entry[0]), fund_stockquote.get_price(entry[0]), str(entry[-1])))
                                #	f1.write('\n')
			f1.write("# Above average curve and results | only work on bull market\n")
			#f1.write('\n')
                        # condition: (0.03 >= (float(fund_stockquote.get_todays_high(entry[0])) - float(fund_stockquote.get_todays_low(entry[0])))/float(fund_stockquote.get_price(entry[0]))) and float(fund_stockquote.get_ebitd(entry[0])) > 0.12)
			for entry in sorted_trading_value:
				 if(fund_stockquote.eps_threshold(entry[0]) > 0 and (((float(fund_stockquote.get_volume(entry[0])) > 1.5*float(fund_stockquote.get_average_volume(entry[0]))) and (g_changing_range < (float(fund_stockquote.get_todays_high(entry[0])) - float(fund_stockquote.get_price(entry[0])))/float(fund_stockquote.get_price(entry[0]))))) and (fund_stockquote.get_average_volume(entry[0]) > 1000000) and (float(fund_stockquote.get_ebitd(entry[0])) > 0.12)):
                                        print entry[0]
                                        f1.write('%s %s %s'%(str(entry[0]), fund_stockquote.get_price(entry[0]),str(entry[-1])))
                                        f1.write('\n')
                       # f1.write("# Above average curve and slowly getting up | only work on bull market\n")
			for entry in sorted_trading_value:
				 if(fund_stockquote.eps_threshold(entry[0]) > 0 and ((float(fund_stockquote.get_volume(entry[0])) > float(fund_stockquote.get_average_volume(entry[0]))) and (0.05 > (float(fund_stockquote.get_todays_high(entry[0])) - float(fund_stockquote.get_todays_low(entry[0])))/float(fund_stockquote.get_price(entry[0]))) and float(fund_stockquote.get_ebitd(entry[0])) > 0.17) and (fund_stockquote.get_volume(entry[0]) > 500000) and (float(fund_stockquote.get_ebitd(entry[0])) > 0.12)):
					print entry[0]
コード例 #3
0
                                         key=operator.itemgetter(1))
            #print old_strategy.earning_stock
            #print sorted_value

            ts = datetime.date.today()
            history_choice = 'trading_%s' % (ts)
            os.system('cp %s history/%s' % (email_file, history_choice))

            f1 = open('trading_result.txt', 'w+')
            for entry in sorted_buying_value:
                if (fund_stockquote.eps_threshold(entry[0]) > 0 and
                    (g_changing_range <
                     (float(fund_stockquote.get_todays_high(entry[0])) -
                      float(fund_stockquote.get_todays_low(entry[0]))) /
                     float(fund_stockquote.get_price(entry[0]))) and
                    (float(fund_stockquote.get_volume(entry[0])) > 1.5 *
                     float(fund_stockquote.get_average_volume(entry[0])))):
                    print entry[0]
                    f1.write('%s %s %s' %
                             (str(entry[0]), fund_stockquote.get_price(
                                 entry[0]), str(entry[-1])))
                    f1.write('\n')
            f1.write("# Average curve up and results\n")
            #f1.write('\n')
            for entry in sorted_trading_value:
                if (fund_stockquote.eps_threshold(entry[0]) > 0 and
                    (float(fund_stockquote.get_volume(entry[0])) >
                     1.5 * float(fund_stockquote.get_average_volume(entry[0])))
                        and
                    (g_changing_range <
                     (float(fund_stockquote.get_todays_high(entry[0])) -
コード例 #4
0
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)