def ccbc_percent_when_hz500_down_5_percent(): ccbc = stock.load_stock('601939.ss') hz500 = stock.load_stock('000300.ss') for i in xrange(len(hz500)-1): if (hz500[i+1]['open'] - hz500[i]['close']) * 100 / hz500[i]['open'] < -5: for v in ccbc: if hz500[i]['date'] == v['date']: print hz500[i]['close'], hz500[i+1]['open'] print "%.2f" % ((v['close'] - v['open']) * 100 / v['open'])
def rebabilitate_forward(code, market): stocks = stock.load_stock(code+'.'+market) rights_offering = rightsoffering.load(code) for s in stocks: rate = 1.00 for r in rights_offering: if s['date'] <= r['date']: rate = rate * (1 + r['dividend']) s['open'] = s['open'] * rate s['close'] = s['close'] * rate s['high'] = s['high'] * rate s['low'] = s['low'] * rate return stocks
def agv_when(data): code = '000001' market = 'ss' szzs = stock.load_stock(code+'.'+market) date = [] for ss in szzs: if ss['open'] < 2760 and ss['open'] > 2650: date.append(ss['date']) price = 0.00 count = 0 for d in data: if d['date'] in date: count += 1 avg = (d['close'] + d['open']) / 2 price += avg return price/count
def average_price(code): stocks = stock.load_stock(code) return code, average_price_in_data(stocks)
def days_price_low_than(code, price): stocks = stock.load_stock(code) return days_price_low_than_in_data(price, stocks)
def lowest_price(code): stocks = stock.load_stock(code) lowest_price_in_data(stocks)
count = 0 for d in data: if d['date'] in date: count += 1 avg = (d['close'] + d['open']) / 2 price += avg return price/count if __name__ == '__main__': code = '000623' market = 'sz' stocks = stock.load_stock(code+'.'+market) days = 4 for i in range(10 * days): percent = -i print '%.2f%% -- %.2f%%' % (percent, tomorrow_up_when_how_many_is_down_today(stocks, percent,days)) stocks = rebabilitate_forward(code, market) for i in range(10 * days): percent = -i print '%.2f%% -- %.2f%%' % (percent, tomorrow_up_when_how_many_is_down_today(stocks, percent,days)) sys.exit(0) code = '601939'
for v in ccbc: if hz500[i]['date'] == v['date']: print hz500[i]['close'], hz500[i + 1]['open'] print "%.2f" % ((v['close'] - v['open']) * 100 / v['open']) if __name__ == '__main__': ccbc_percent_when_hz500_down_5_percent() sys.exit(0) stocks = rebabilitate_forward('000623', 'sz') print lowest_price_in_data(stocks)['low'] print highest_price_in_data(stocks)['high'] r = days_price_low_than_in_data(15.77, stocks) print r[:2] #for i in r[2]: # print i.date() print average_price_in_data(stocks) print 'xxxxxxxxxxxxxxxxxxxx' stocks = stock.load_stock('000623.sz') print lowest_price_in_data(stocks)['low'] print highest_price_in_data(stocks)['high'] r = days_price_low_than_in_data(15.77, stocks) print r[:2] print average_price_in_data(stocks) # print lowest_price('601939.ss') # print average_price('601939.ss') # print lowest_price('000623.sz') # print average_price('000623.sz') # print days_price_low_than('600039.ss', 4.43)