diff --git a/PriceSystem/fix/__pycache__/price_fix.cpython-36.pyc b/PriceSystem/fix/__pycache__/price_fix.cpython-36.pyc index d611383..52801d0 100644 Binary files a/PriceSystem/fix/__pycache__/price_fix.cpython-36.pyc and b/PriceSystem/fix/__pycache__/price_fix.cpython-36.pyc differ diff --git a/PriceSystem/fix/price_fix.py b/PriceSystem/fix/price_fix.py index 9a680bd..0a8abbf 100644 --- a/PriceSystem/fix/price_fix.py +++ b/PriceSystem/fix/price_fix.py @@ -14,7 +14,7 @@ from pandas import DataFrame,Series from numpy import row_stack,column_stack from dateutil.parser import parse import pandas -# import matplotlib.pyplot as plt +import matplotlib.pyplot as plt import numpy as np import numpy import collections @@ -39,12 +39,12 @@ estype='普通住宅' #dt=client.fangjia.district_stat #dt=client.fangjia.district_stat_all_0426 dt = stat = fangjia.get_collection("fangjia", "district_stat", config.get_district_stat_host(), config.get_district_stat_port()) -def price_list(ct,rl,lk): +def price_list(ct,rl,lk,weekend): #query = {'city':ct,'region':rl,'district_name':lk} - query = {'city':ct,'region':rl ,'district_name': lk } + query = {'city':ct,'region':rl ,'district_name': lk ,'weekend':{'$lt':weekend}} fields={'_id':1,'calc_value':1,'weekend':1,'block':1,'level':1,'avg_price':1,'credit':1} @@ -74,11 +74,11 @@ def price_list(ct,rl,lk): else: return pd.DataFrame() -''' + def plot1(x,y): - z1 = np.polyfit(x, y,3) + z1 = np.polyfit(x, y,1) # 生成多项式对象 p1 = np.poly1d(z1) pp1=p1(x) @@ -90,8 +90,7 @@ def plot1(x,y): plt.plot(x,pp1,color='b',linestyle='-',marker='.',label=u"拟合曲线") # 把拟合的曲线在这里画出来 plt.legend(loc='upper left') - plt.show() -''' + def line_regre(x,y,num): @@ -123,17 +122,19 @@ estype='普通住宅' def compare(dd1,name,credit,calc_value): #print('dd1=',dd1) y=list(dd1[name].dropna()) - #print('y=',y) + print('y=',y,'[]'*36) kk=len(y) if kk>2: #kk1=kk-1 - kk1=kk-1 + kk1=kk y1=y[:kk1] - x1=list(range(kk1)) + #x1=list(range(kk1)) ##print('y1=',y1) #plot1(list(range(kk)) ,y) + + fo=y1[-1] - fo=line_regre(x1,y1,1) + #fo=line_regre(x1,y1,1) ratio=(calc_value-fo)/fo print('ratio=',ratio) @@ -145,28 +146,32 @@ def compare(dd1,name,credit,calc_value): print('fo=',fo,name) #if credit>=0.75 and(ratio>0.95 and ratio<1.05): + + if ratio==0: + + randm=1+random.uniform(-0.02,0.02) + return int(calc_value*randm),1 + if abs(ratio)<=0.05: ##print('cccccc') return calc_value,1 - - #elif ratio>0.85 and ratio<1.05: - print('ratio',ratio) - ##print('ddddddddddddd') - return calc_value,1 - + else: ##print('eeeeeeeeeeeeee') print('y[-1]=',y[-1]) def ccp(nihe,znew,ratio): - rr0=abs((nihe-znew)/min(nihe,znew)) + #rr0=abs((nihe-znew)/min(nihe,znew)) print('nihe=',nihe) print('znew=',znew) - - print('rr0=',rr0) + if ratio>0.05: + return int(znew*1.05) + else: + return int(znew*0.95) ############################## + """ if rr0<=0.07: #print('kkkkkkkkk') if ratio>0.05: @@ -177,13 +182,16 @@ def compare(dd1,name,credit,calc_value): #print('pppp') #print(ratio) - + print('xo'*20) if ratio>0.05: #print('lgggg') - return int(nihe*1.05) + + #return int(nihe*1.05) + return int(znew*1.05) else: - return int(nihe*0.95) - + return int(znew*0.95) + """ + ############################### foe=ccp(fo,y[-1],ratio) @@ -242,8 +250,8 @@ def out_price(ct,rl,lk,calc): -def out_price(ct,rl,lk,calc): - dd=price_list(ct,rl,lk) +def out_price(ct,rl,lk,calc,weekend): + dd=price_list(ct,rl,lk,weekend) #print('dd=',dd) if dd.shape[0]>0: @@ -267,8 +275,8 @@ def out_price(ct,rl,lk,calc): #pp=out_price(ct,rl,lk) -def update(ct,rl,lk,calc): - dd= out_price(ct,rl,lk,calc) +def update(ct,rl,lk,calc,weekend): + dd= out_price(ct,rl,lk,calc,weekend) if len(dd)>0: return dd[0] else: diff --git a/PriceSystem/sell_price/zhuge0118A.py b/PriceSystem/sell_price/zhuge0118A.py index a459bde..e8d2fe3 100644 --- a/PriceSystem/sell_price/zhuge0118A.py +++ b/PriceSystem/sell_price/zhuge0118A.py @@ -33,21 +33,15 @@ import time # import yesterday -def front_step_time(day): - now = datetime.datetime.now() +def front_step_time(weekend,day): + #now = datetime.datetime.now() + now=weekend front = now - datetime.timedelta(days=day) d1 = front.strftime('%Y%m%d') return int(d1) -# 提取房源的数据时间上限,如从20170301之后的数据 -some_district_information_time = front_step_time(360) -# 提周边小区均价的数据时间上限,如从20170801之后的数据 -zhoubian_xiaoqu_time = front_step_time(200) - -# 第三方均价的数据时间上限,如从201703之后的数据 -dsfjujia_time = front_step_time(200) // 100 ############################################################ ############################################################ @@ -67,7 +61,20 @@ value_type = pandas.Series([1, 2, 3, 4, 5, 6, 7], # 1:指导价 2:自身样本 3:第三方 4:交易数据 5:周边楼盘, 6:推导 -def commonprice(ct, rl, p): +def commonprice(ct, rl, p,weekend): + + + + # 提取房源的数据时间上限,如从20170301之后的数据 + some_district_information_time = front_step_time(weekend,360) + + # 提周边小区均价的数据时间上限,如从20170801之后的数据 + zhoubian_xiaoqu_time = front_step_time(weekend,200) + + # 第三方均价的数据时间上限,如从201703之后的数据 + dsfjujia_time = front_step_time(weekend,200) // 100 + + def add_block(ppd): if 'block' not in ppd.columns: ppd['block'] = '没有' @@ -555,7 +562,7 @@ def commonprice(ct, rl, p): dd = neighbor(location['lng2'].iloc[0], location['lat2'].iloc[0], 5, ct, rl, p) #print(time.time()-t1,'t1'*10) - # print('dd=',dd,'dd'*20) + #print('dd=',dd,'dd'*20) if dd.shape[0] >= factor: # ####print('$'*50) # dd1=neighbor(location['lng2'][0],location['lat2'][0],5) @@ -576,19 +583,19 @@ def commonprice(ct, rl, p): # svr_time=time.time() other1 = svr(dd1, lk) # ####print(time.time()-svr_time,'svr'*10) - # ####print('other1=',other1) + #print('other1=',other1) return other1, dd1.shape[0] else: # t3=time.time() dd2 = neighbor(location['lng2'].iloc[0], location['lat2'].iloc[0], 20, ct, rl, p) # ####print(time.time()-t3,'t3'*10) - #####print('dd2.shape', dd2.shape[0], '@' * 60) + print('dd2.shape', dd2 ,'@' * 60) if dd2.shape[0] >= factor: #####print('$' * 50) #svr_time = time.time() other1 = svr(dd2, lk) #####print(time.time() - svr_time, 'e' * 10) - # ####print('other1=',other1) + #print('other1=',other1) return other1, dd2.shape[0] else: @@ -1219,9 +1226,9 @@ def commonprice(ct, rl, p): return -2,float('%.2f' % credit['0.85']), value_type['第三方'], sample_size def map_time_price(junjia,dglg,ppd3): - day_15=front_step_time(15) - day_30=front_step_time(30) - day_60=front_step_time(60) + day_15=front_step_time(weekend,15) + day_30=front_step_time(weekend,30) + day_60=front_step_time(weekend,60) price_15= consider_time_ss1(junjia,dglg,ppd3,day_15) price_30= consider_time_ss1(junjia,dglg,ppd3,day_30) price_60= consider_time_ss1(junjia,dglg,ppd3,day_60) @@ -1593,7 +1600,7 @@ def out_put_price(ct, rl, lk, weekend): #####print('p=', p) #t1=time.time() - mm = commonprice(ct, rl, p) + mm = commonprice(ct, rl, p,weekend) #print('mmjisuantime=',time.time()-t1,'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy') #####print('mm=',mm) c_date = datetime.datetime.utcnow() @@ -1620,24 +1627,24 @@ def out_put_price(ct, rl, lk, weekend): # ####print(time.time()-t1,'*'*20) - # ####print('last_sunday_price',last_sunday_price) + print('last_sunday_price=',last_sunday_price) # ####print('mm[0]',mm[0]) - def make_up(): + def make_up(avg,last_sunday_price): if type(last_sunday_price) != str and last_sunday_price != None and mm[0] != None and type(mm[0]) != str: - make_up = 10000 * (mm[0] - last_sunday_price) / last_sunday_price + make_up = 10000 * (avg - last_sunday_price) / last_sunday_price return make_up else: return 0 - make_up = int(make_up()) + #####print('make_up',make_up,'*'*20) #####print('credic',mm[1]) - def avg_compare(ct,rl,lk,mm): - avg=fix.price_fix.update(ct,rl,lk,int(mm[0])) + def avg_compare(ct,rl,lk,mm,weekend): + avg=fix.price_fix.update(ct,rl,lk,int(mm[0]),weekend) #print('nihe=',avg) #print('mm[0]',mm[0]) if avg>0: @@ -1645,7 +1652,8 @@ def out_put_price(ct, rl, lk, weekend): else: return int(mm[0]) #s1=time.time() - avg=avg_compare(ct,rl,lk,mm) + avg=avg_compare(ct,rl,lk,mm,weekend) + make_up = int(make_up(avg,last_sunday_price)) #print('s1_time=',time.time()-s1) #avg=mm[0] print('mm=',mm) diff --git a/PriceSystem/test.py b/PriceSystem/test.py index dbfc837..d1072e5 100644 --- a/PriceSystem/test.py +++ b/PriceSystem/test.py @@ -14,20 +14,20 @@ def get_weekend(tt): pacific = pytz.timezone('Asia/Shanghai') return pacific.localize(bb) -weekend = get_weekend('20180510') +weekend = get_weekend('20180429') s = time.time() -ct='太原' -rl='万柏林' -lk='大唐世家玉河苑' +ct='上海' +rl='长宁' +lk='石林别墅' ''' -ct='太原' +ct='太原'长宁石林别墅 rl='万柏林' -lk='下元重机宿舍' +lk='下元重机宿舍'上海徐汇大大沽路100号小区 ''' #杨浦凤城四村闵行上海康城厦门同安大唐世家二期青岛市北东方小区合肥庐阳海亮红玺台青岛市北东方小区