コード例 #1
0
ファイル: stockmodel.py プロジェクト: aquarius23/aquarius23
def get_stock_modle(list, name, c_continue, c_break):
	manager = stockmanager.stockmanager()
	trainer = stockcrf.stockcrftrainer()
	run = stockcrfrun.stockcrfrun()
	flow = stockflow.stockflow()
	for index in list:
		index = index[0]
		print index
		e = manager.get_stock_index(index)
		size = len(e)
		if e == []:
			continue
		run.feed(e)
		rflow, rmiss = flow.read_flow(index)
		filter = cal_filter(rmiss)
		run.feed_flow(rflow)
		count  = 0
		for tag, feature in run.tag_feature():
			count = count + 1
			if count <= 30:
				continue
			if c_continue(count, size) == 1:
				continue
			if c_break(count, size) == 1:
				break
			if filter_skip(filter, count - 1) == 1:
				continue
			trainer.set_tag_feature(tag, feature)
	trainer.get_model(name)
	trainer.clear()
コード例 #2
0
ファイル: stockflow.py プロジェクト: aquarius23/aquarius23
	def update_flow(self, index):
		db = stockdb.stockdb()
		flow = self.__read_flow(index)
		size = len(flow)
		manager = stockmanager.stockmanager()
		days = manager.get_stock_index(index)
		for i, item in enumerate(days):
			if i < size:
				continue
			day = item[0].split('-')
			year = string.atoi(day[0])
			month = string.atoi(day[1])
			day = string.atoi(day[2])
			new = manager.get_stock_detailed(index, year, month, day)
			if new == []:
				print 'BUG(miss data): ' + str(year) + str(month) + str(day)
				parser = stockparser.stock_parser()
				detail = parser.get_detailed_exchange(index, year, month, day)
				if len(detail) > 0:
					db.write_data_day(index, detail, year, month, day)
					new = manager.get_stock_detailed(index, year, month, day)
					print 'Fixed OK!'
			record = []
			record.append(item[0])
			if new != []:
				sum, all, big, sl, sh, el, eh = self.cal_flow(new, item[1], item[2])
				record.append(str(sum))
				record.append(str(all))
				record.append(str(big))
				record.append(str(sl))
				record.append(str(sh))
				record.append(str(el))
				record.append(str(eh))
			flow.append(record)
		db.write_data_flow(index, flow)
コード例 #3
0
ファイル: stocksort.py プロジェクト: aquarius23/aquarius23
def get_vol():
    manager = stockmanager.stockmanager()
    list = manager.get_stock_list()
    result = []
    for stock in list:
        print stock
        e = manager.get_stock_index(stock)
        if e == []:
            continue
        if len(e) < stockconfig.FIG_MIX_CRF:
            continue
        sum = 0
        count = 0
        result_day = []
        result_day.append(str(stock))
        for day in e:
            volume = day[6]
            sum = sum + volume
            count = count + 1
        result_day.append(str(sum / count))
        result.append(result_day)
    result.sort(cmp=lambda x, y: cmp(x[1], y[1]))
    return result
コード例 #4
0
ファイル: test_sum.py プロジェクト: aquarius23/aquarius23

def __normalize(list):
    sum = 0
    ret = []
    for item in list:
        sum = sum + item
    for item in list:
        nor = 0
        if sum != 0:
            nor = (float(item) / float(sum)) * 100.0
        ret.append(nor)
    return ret


manager = stockmanager.stockmanager()
list = manager.get_stock_list()
result = []
for i in range(0, 41):
    result.append(0)
for index in list:
    print index
    e = manager.get_stock_index(index)
    if e == []:
        continue
    kline = manager.cal_kline(e)
    for item in kline:
        state = item[0]
        if state < -10:
            state = -10
        elif state > 10:
コード例 #5
0
import sys
sys.path.insert(0, '.')
from stockmanager import stockmanager
s = stockmanager()
s.get_near_high52()
コード例 #6
0
ファイル: stockemu.py プロジェクト: 547872495/aquarius23
class stockemu():
	score = stockscore.stockscore()
	manager = stockmanager.stockmanager()
	score.reset()
	macd = []
	kdj = []
	boll = []
	ma = []
	volume_ma = []
	price_range_low = []
	price_range_high = []
	volume_range_low = []
	volume_range_high = []
	closeprice_range_low = []
	closeprice_range_high = []
	kline = []
	exchange = []
	size = 0
	current_index = 0

	def reset(self):
		self.score.reset()

	def fix_index(self, adjust):
		if adjust > 0:
			adjust = 0
		index = self.current_index + adjust
		if index < 0:
			index = 0
		return index

	def run(self):
		index = 0
		for item in self.exchange:
			current = item[2]#close price
			if self.filter(index) == 1:
				self.score.update(current, index, self.closeprice_range_low, self.ma, self.closeprice_range_high)
			index = index + 1

	def feed(self, exchange):
		self.size = len(exchange)
		self.exchange = exchange
		self.macd = self.manager.cal_macd(exchange)
		self.kdj = self.manager.cal_kdj(exchange)
		self.boll = self.manager.cal_boll(exchange)
		self.ma = self.manager.cal_ma(exchange)
		self.volume_ma = self.manager.cal_volume_ma(exchange)
		self.price_range_low, self.price_range_high = self.manager.cal_price_range(exchange)
		self.volume_range_low, self.volume_range_high = self.manager.cal_volume_range(exchange)
		self.closeprice_range_low, self.closeprice_range_high = self.manager.cal_closeprice_range(exchange)
		self.kline = self.manager.cal_kline(exchange)

	def filter(self, index):
		self.current_index = index
		if self.filter_macd(self.exchange, index, self.macd) != 1:
			return 0
		if self.filter_kdj(self.exchange, index, self.kdj) != 1:
			return 0
		if self.filter_boll(self.exchange, index, self.boll) != 1:
			return 0
		if self.filter_ma(self.exchange, index, self.ma) != 1:
			return 0
		if self.filter_volume_ma(self.exchange, index, self.volume_ma) != 1:
			return 0
		if self.filter_price_range(self.exchange, index, self.price_range_low, self.price_range_high) != 1:
			return 0
		if self.filter_volume_range(self.exchange, index, self.volume_range_low, self.volume_range_high) != 1:
			return 0
		if self.filter_closeprice_range(self.exchange, index, self.closeprice_range_low, self.closeprice_range_high) != 1:
			return 0
		if self.filter_kline(self.exchange, index, self.kline) != 1:
			return 0
		if self.filter_exchange(index, self.exchange) != 1:
			return 0
		return 1

	def filter_macd(self, exchange, index, macd):
		return 1

	def filter_kdj(self, exchange, index, kdj):
		return 1

	def filter_boll(self, exchange, index, boll):
		return 1

	def filter_ma(self, exchange, index, ma):
		return 1

	def filter_volume_ma(self, exchange, index, volume_ma):
		return 1

	def filter_price_range(self, exchange, index, low, high):
		return 1

	def filter_volume_range(self, exchange, index, low, high):
		return 1

	def filter_closeprice_range(self, exchange, index, low, high):
		return 1

	def filter_kline(self, exchange, index, kline):
		return 1

	def filter_exchange(self, index, exchange):
		return 1

	def get_low(self):
		return self.score.get_low()

	def get_middle(self):
		return self.score.get_middle()

	def get_high(self):
		return self.score.get_high()
コード例 #7
0
ファイル: test_rule.py プロジェクト: 547872495/aquarius23
    def filter_kdj(self, exchange, index, kdj):
        if kdj[index][2] > 0:
            return 0
        adj1 = self.fix_index(-1)
        if kdj[adj1][2] > kdj[index][2]:
            return 0
        return 1

    def filter_macd(self, exchange, index, macd):
        return 1

    def filter_boll(self, exchange, index, macd):
        return 1


manager = stockmanager.stockmanager()
list = manager.get_stock_list()
list = ['600015', '600030', '600036', '600050', '600029']
for index in list:
    print index
    e = manager.get_stock_index(index)
    if e == []:
        continue
    emu = myemu()
    emu.feed(e)
    emu.run()
x = emu.get_middle()
for i in x:
    print '----------------------'
    for j in i:
        print j