fromfunctionimport*importtimeimportwarningswarnings.filterwarnings#pd.set_option#pd.set_optionfromlark_bot_msgimportLarkBotMsgclassAutoLarkBot:status_map={"0":"等待触发","1":"已触发","2":"已手动终止","3":"系统止盈","4":"系统止损","5":"等待终止结算"}url="webhook-url"@classmethoddefnotify_modify_position:"""database:pmsfunction:notifylarkbotwhenmodifypositionchange."""_,dbc,_=list.values)sql=f"SELECT*FROM`wp_fin_strg_trade_value`where`id_strg_indicator`=1008orderby`create_time`desclimit1;"ret_type_df=pd.read_sqllast_time=ret_type_df.iloc[0]["create_time"]whileTrue:last_time_format=last_time.strftimesql=f"SELECT*FROM`wp_fin_strg_trade_value`WHERE`create_time`>"{last_time_format}"AND`id_strg_indicator`=1008"sql+=f"orderbycreate_timedesc;"ret_df=pd.read_sqliflen>0:forindex,rowinret_df.iterrows:sql=f"SELECTvalue,create_timeFROM`wp_fin_strg_trade_value`"sql+=f"WHERE`id_strg_indicator`=1009"sql+=f"AND`id_strg`={row["id_strg"]}"sql+=f"AND`id_ticker`={row["id_ticker"]}"sql+=f"AND`id_position`={row["id_position"]}"sql+=f"AND`create_time`>="{last_time_format}""sql+=f"orderby`create_time`desclimit1;"ret_comment_df=pd.read_sqlret_id_strg_df=pd.read_sqlid_author=ret_id_strg_df.iloc[0]["id_author"]ret_id_author_df=pd.read_sqlret_institute_df=pd.read_sqlret_id_ticker_df=pd.read_sqltitle=f"调仓通知:{ret_id_author_df.iloc[0]["name"]}-{ret_id_ticker_df.iloc[0]["fullname"]}-{row["value"]}"content=""if1==len:#larkbotnotifycontent.content+=f"策略名称:{ret_id_strg_df.iloc[0]["strg_name"]}"content+=" "content+=f"经纪商:{ret_institute_df.iloc[0]["name"]}"content+=" "content+=f"调仓说明:{ret_comment_df.iloc[0]["value"]}"content+=" "if""==content:#调仓类型和调仓说明未同步LarkBotMsg.md_msg",at_all=True)else:LarkBotMsg.md_msglast_time=ret_df.iloc[0]["create_time"]time.sleep@classmethoddefnotify_stock_recommendation_change:"""database:www_rshfunction:notifylarkbotwhenstockrecommendationchange."""_,dbc,_=list.values)sql=f"SELECT*FROM`wp_fin_author_recommend`"sql+=f"orderbycreate_timedesclimit1;"ret_df=pd.read_sqllast_time=ret_df.iloc[0]["create_time"]whileTrue:last_time_format=last_time.strftimesql=f"SELECT*FROM`wp_fin_author_recommend`WHERE`create_time`>"{last_time_format}""sql+=f"orderbycreate_timedesc;"ret_df=pd.read_sqliflen>0:forindex,rowinret_df.iterrows:title=f"股票推荐更新:{row["author_name"]}-{row["stock_name"]}"content=cls.__get_stock_author_recommendcontent+=" "LarkBotMsg.md_msglast_time=ret_df.iloc[0]["create_time"]time.sleep@classmethoddef__get_stock_author_recommend:content=f"类型:{row_data["position_type"]}单]})"content+=" "content+=f"买入价:{row_data["order_price"]}"content+=" "content+=f"目标价:{row_data["target_price"]}"content+=" "ifpd.isnull:content+=f"总天数:0天"else:content+=f"总天数:{str)}天"content+=" "content+=f"推荐说明:{row_data["start_reason"]}"ifrow_data["end_reason"]isnotNone:content+=" "content+=f"终止说明:{row_data["end_reason"]}"returncontentif__name__=="__main__":if2==len:ifsys.argv=="stock_rec":printAutoLarkBot.notify_stock_recommendation_changeelifsys.argv=="modify_pos":printAutoLarkBot.notify_modify_positionelse:print)
文章为作者独立观点,不代表股票配资公司观点