Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -34,4 +34,5 @@ data = {
|
||||
access_token = "1e5f9aaeb90b091bc79652b52800cad2f1dee1ac0990149252511965f6d1c12a"
|
||||
# 发送消息至群
|
||||
msg = requests.post(url='https://oapi.dingtalk.com/robot/send?access_token=' + access_token, json=data).json()
|
||||
msg = requests.post(url='https://oapi.dingtalk.com/robot/send?access_token=45ac47a34dc5491535d77d643512244a85d91d7e74676e9c42446dc06357326e', json=data).json()
|
||||
print(msg)
|
||||
@@ -50,10 +50,12 @@ def stock_gmm(last_day_str,last_month_str):
|
||||
for i, row in ts_detail.iterrows():
|
||||
res.append(row)
|
||||
stock_res = pd.DataFrame(res)
|
||||
stock_res.to_excel('E:\\工作文件\\avm_output\\airflow_scaled_df.xlsx', encoding='utf-8', index=False)
|
||||
stock_all_newest = stock_all[stock_all.trade_date == stock_all.trade_date.max()]
|
||||
stock_all_newest = stock_all_newest[['ts_code', 'turnover_rate', 'close', 'amount', 'pe', 'pe_ttm', 'total_mv', 'pct_chg']]
|
||||
X = stock_res[['0', '1', '2', '3', '4', '5', '6']]
|
||||
gmm_df = gmm_trade(stock_res, X)
|
||||
gmm_df.to_excel('E:\\工作文件\\avm_output\\airflow_gmm_df.xlsx', encoding='utf-8', index=False)
|
||||
gmm_group_df = gmm_df.groupby(['ts_code', 'rating'])['stock_name'].count().reset_index()
|
||||
gmm_group_df.rename(columns={'stock_name': 'count'}, inplace=True)
|
||||
gmm_df = gmm_df.merge(gmm_group_df, how='left', on=['ts_code', 'rating'])
|
||||
@@ -75,21 +77,24 @@ def stock_gmm(last_day_str,last_month_str):
|
||||
|
||||
def stock_select(i):
|
||||
last_day = today+relativedelta(days=-i)
|
||||
last_month = last_day+relativedelta(months=-2)
|
||||
last_month = last_day+relativedelta(days=-15)
|
||||
last_day_str = last_day.strftime('%Y%m%d')
|
||||
if last_day_str in trade_dates:
|
||||
return last_day_str
|
||||
if int(last_day_str)<20250101:
|
||||
return last_day_str
|
||||
last_day_str = '20260325'
|
||||
# if last_day_str in trade_dates:
|
||||
# return last_day_str
|
||||
# if int(last_day_str)<20200101:
|
||||
# return last_day_str
|
||||
last_month_str = last_month.strftime('%Y%m%d')
|
||||
last_month_str = '20260304'
|
||||
stock_all_newest,select_block,slecct_df=stock_gmm(last_day_str,last_month_str)
|
||||
db_stock = slecct_df[['ts_code', 'stock_name', 'open', 'close', 'high', 'low',
|
||||
'vol', 'amount', 'pre_close', 'change', 'pct_chg', 'turnover_rate',
|
||||
'turnover_rate_f', 'volume_ratio', 'pe', 'pe_ttm', 'pb', 'ps_ttm', 'ps',
|
||||
'total_share', 'float_share', 'free_share', 'total_mv', 'circ_mv']].copy()
|
||||
db_stock['trade_date'] = last_day_str
|
||||
db_stock['ts_code'] = db_stock['ts_code'].apply(lambda x: x[0:6])
|
||||
db_stock.to_sql("mu_stocks_new",con=engine, index=False, if_exists="append")
|
||||
print(select_block)
|
||||
# db_stock['ts_code'] = db_stock['ts_code'].apply(lambda x: x[0:6])
|
||||
# db_stock.to_sql("mu_stocks_new",con=engine, index=False, if_exists="append")
|
||||
return last_day_str
|
||||
if __name__ == '__main__':
|
||||
stock_select(0)
|
||||
@@ -1,6 +1,11 @@
|
||||
"""
|
||||
写字楼基准价
|
||||
"""
|
||||
import math
|
||||
from datetime import datetime
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
# 第一步:计算有样本写字楼的基准价
|
||||
# 取近一年,最近100个样本的中位值
|
||||
# 第二步:计算无样本写字楼的基准价
|
||||
@@ -10,13 +15,8 @@
|
||||
#
|
||||
# 第五步:本身没有等级和类型的写字楼
|
||||
# 最近10个有样本写字楼的基准价的平均值
|
||||
from goojia_utils import ElasticSearchClient, dateutils, MAIN_MONGO_CLIENT, commutils
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
from goojia_utils import ElasticSearchClient, dateutils, MAIN_MONGO_CLIENT
|
||||
from pymongo import UpdateOne
|
||||
import math
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
es = ElasticSearchClient(host='192.168.0.206')
|
||||
seaweed_df = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
"""
|
||||
写字楼基准价
|
||||
"""
|
||||
import math
|
||||
from datetime import datetime
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
# 第一步:计算有样本写字楼的基准价
|
||||
# 取近一年,最近100个样本的中位值
|
||||
# 第二步:计算无样本写字楼的基准价
|
||||
@@ -10,13 +15,8 @@
|
||||
#
|
||||
# 第五步:本身没有等级和类型的写字楼
|
||||
# 最近10个有样本写字楼的基准价的平均值
|
||||
from goojia_utils import ElasticSearchClient, dateutils, MAIN_MONGO_CLIENT, commutils
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
from goojia_utils import ElasticSearchClient, dateutils, MAIN_MONGO_CLIENT
|
||||
from pymongo import UpdateOne
|
||||
import math
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
es = ElasticSearchClient(host='192.168.0.206')
|
||||
seaweed_df = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||
@@ -110,9 +110,10 @@ def calcByOffice(city, district, office_name):
|
||||
avg_prices = [doc["avg_price"] for doc in avg_price_ret]
|
||||
# 计算平均值
|
||||
average_price = np.mean(avg_prices) if len(avg_prices) > 0 else 0
|
||||
new_avg_price = None
|
||||
if average_price > 0:
|
||||
new_avg_price = int(average_price)
|
||||
else:
|
||||
elif "avg_price" in sample.columns:
|
||||
# 取样本的平均值
|
||||
new_avg_price = int(sample['avg_price'].mean())
|
||||
if pd.notna(new_avg_price):
|
||||
|
||||
Reference in New Issue
Block a user