Beispiel #1
0
    def test_for_indicator(self, symbol):

        geode_client = GeodeClient()

        latest_days = geode_client.query_stock_days_latest(symbol, 30)

        print IndicatorUtils.MA(latest_days, 5, 0)
Beispiel #2
0
    def test_for_week_ma_match(self, symbol):

        geode_client = GeodeClient()

        hist_symbols_days = {}
        hist_symbols_weeks = {}

        latest_days = geode_client.query_stock_days_latest(symbol, 300)
        latest_weeks = geode_client.query_stock_weeks_latest(symbol, 300)

        #       stock_today = SinaStockUtils.get_sina_stock_day(symbol)[0]

        stock_today = latest_days[0]
        print 'stub_stock_day = ' + stock_today.id

        #       print json.encode(stock_today)

        hist_symbols_days[symbol] = latest_days
        hist_symbols_weeks[symbol] = latest_weeks
        #       print json.encode(latest_weeks[0:50])

        model_test = ModelBase(hist_symbols_days, hist_symbols_weeks,
                               stock_today.day)

        print model_test.match(stock_today)
Beispiel #3
0
    def test_for_symbol_incubator(self, symbol):

        geode_client = GeodeClient()

        hist_symbols_days = {}

        latest_days = geode_client.query_stock_days_latest(symbol, 30)

        stock_today = SinaStockUtils.get_sina_stock_day(symbol)[0]

        hist_symbols_days[symbol] = latest_days

        model_test = StockIncubator(hist_symbols_days)
Beispiel #4
0
    def test_for_symbol_today_match(self, symbol):

        geode_client = GeodeClient()

        hist_symbols_days = {}

        latest_days = geode_client.query_stock_days_latest(symbol, 300)

        #       stock_today = SinaStockUtils.get_sina_stock_day(symbol)[0]

        stock_today = latest_days[0]

        #       print json.encode(stock_today)

        hist_symbols_days[symbol] = latest_days

        model_test = ModelCover(hist_symbols_days, stock_today.day)

        print model_test.match(stock_today)
Beispiel #5
0
class BackTest:
    def __init__(self):
        self.geode_client = GeodeClient()
        self.redis_client = RedisClient()
        self.symbols = self.geode_client.query_all_stock_symbols()
        self.test_days = 1

    def import_stocks_days(self):
        symbols = self.geode_client.query_all_stock_symbols()
        finish_cnt = 0
        for symbol in symbols:
            finish_cnt += 1
            if finish_cnt < 1400:
                continue
            stock_days = self.geode_client.query_stock_days_latest(
                symbol, 10000)
            for i in range(len(stock_days) - 1):
                stock_days[i].last_close = stock_days[i + 1].close
#	    print json.encode(stock_days)
#	    break
            self.geode_client.add_batch_stock_days(stock_days)

            print symbol + ':' + str(finish_cnt)

    def latest_resistance_price(self, symbol):

        try:

            hist_symbols_days = {}

            latest_days = self.geode_client.query_stock_days_latest(
                symbol, 1000)

            #            stock_today = SinaStockUtils.get_sina_stock_day(symbol)[0]

            stock_today = latest_days[1]
            print TimeUtils.timestamp2datestring(stock_today.day)

            latest_resistance = BaseStockUtils.latest_resistance_price(
                latest_days, stock_today)

            if latest_resistance is not None and len(latest_resistance) > 0:
                print latest_resistance[0]
                return latest_resistance[0]

        except Exception, e:
            print e
            traceback.print_exc()
        return None
Beispiel #6
0
 def __init__(self):
     self.stock_list_url = 'http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page={0}&num={1}&sort=changepercent&asc=0&node={2}&symbol=&_s_r_a=page'
     self.size = 80
     self.geode_client = GeodeClient()
Beispiel #7
0
 def __init__(self):
     self.geode_client = GeodeClient()
     self.redis_client = RedisClient()
     self.symbols = self.geode_client.query_all_stock_symbols()
     self.test_days = 1