优化成交挂牌价系数
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from goojia_utils import MAIN_MONGO_CLIENT, dateutils
|
||||
from goojia_utils import areautils
|
||||
from datetime import datetime, date
|
||||
import pandas as pd
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import logging
|
||||
|
||||
deal_price_conn = MAIN_MONGO_CLIENT.get_collection('fangjia', 'deal_price')
|
||||
district_sell_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'district_sell_stat')
|
||||
evaluate_ratio_conn = MAIN_MONGO_CLIENT.get_collection('business', 'evaluate_ratio')
|
||||
@@ -21,9 +23,10 @@ month = datetimeNow.month
|
||||
day = datetimeNow.day
|
||||
|
||||
|
||||
def sync():
|
||||
def sync(city):
|
||||
# 查询2年内成交价格
|
||||
dear_price_r = deal_price_conn.find({
|
||||
'city': city,
|
||||
'trade_date':
|
||||
{
|
||||
"$gte": datetime(ago_year, ago_month, ago_day, 0, 0),
|
||||
@@ -59,9 +62,10 @@ def sync():
|
||||
df1 = df1.astype(convert_dict)
|
||||
|
||||
year_month = int(dateutils.format_date(datetimeNow, fm='%Y%m'))
|
||||
two_year_ago_year_month = int(dateutils.format_date(datetimeTwoYearAgo, fm='%Y%m' ))
|
||||
two_year_ago_year_month = int(dateutils.format_date(datetimeTwoYearAgo, fm='%Y%m'))
|
||||
# 查询2年内挂牌价格
|
||||
district_stat_r = district_sell_stat_conn.find({
|
||||
'city': city,
|
||||
'date':
|
||||
{
|
||||
"$gte": two_year_ago_year_month,
|
||||
@@ -147,4 +151,8 @@ def sync():
|
||||
evaluate_ratio_conn.update_one(query, update, upsert=True)
|
||||
|
||||
|
||||
sync()
|
||||
if __name__ == "__main__":
|
||||
for city in areautils.get_all_cities():
|
||||
logging.info(f"开始计算{city}市估值系数")
|
||||
sync(city)
|
||||
logging.info(f"{city}市估值系数计算结束")
|
||||
|
||||
Reference in New Issue
Block a user