def price_stream_alert(): """ Function for streaming the price """ w = SGXDataExtract() w.process_all_data() #make this to excel table for easier #group together price_limit_reach_watchlist = [ ['OV8', 0.83, 'greater'], ['OV8', 0.78, 'lower'], ['P13', 0.19, 'lower'], ['O23', 1.65, 'lower'], ['C2PU', 2.20, 'lower'], ['U96', 4.55, 'lower'], ['BS6', 1.46, 'greater'], ['U96', 4.42, 'lower'], ['BN4', 9.60, 'greater'], ['S05', 0.9, 'greater'], ['N4E', 0.355, 'greater'], ['BS6', 1.35, 'lower'], ['U96', 4.35, 'lower'], ['T12', 0.341, 'lower'], ['BS6', 1.39, 'lower'], ['AGS', 0.85, 'greater'], ['N4E', 0.33, 'lower'], ['B2F', 3.65, 'greater'], ['S63', 3.48, 'lower'], ['AGS', 0.819, 'greater'], ['B2F', 3.4, 'lower'], ['J69U', 2.02, 'lower'], ['S63', 3.75, 'lower'], ['C22', 1.1, 'lower'], ] w.set_stock_to_watchlist(price_limit_reach_watchlist, watchlist_type='curr_price') api_key_path = r'C:\Users\356039\Desktop\running bat\pushbullet_api\key.txt' with open(api_key_path, 'r') as f: apiKey = f.read() p = PushBullet(apiKey) ## for price set alert w.scan_price_limit_alert() if len(w.price_limit_alerts_df) > 0: p.pushNote('all', 'Price alert', w.price_limit_alerts_df.to_string(), recipient_type="random1") print 'completed'
def price_stream_alert(): """ Function for streaming the price """ w = SGXDataExtract() w.process_all_data() # make this to excel table for easier # group together price_limit_reach_watchlist = [ ["OV8", 0.83, "greater"], ["OV8", 0.78, "lower"], ["P13", 0.19, "lower"], ["O23", 1.65, "lower"], ["C2PU", 2.20, "lower"], ["U96", 4.55, "lower"], ["BS6", 1.46, "greater"], ["U96", 4.42, "lower"], ["BN4", 9.60, "greater"], ["S05", 0.9, "greater"], ["N4E", 0.355, "greater"], ["BS6", 1.35, "lower"], ["U96", 4.35, "lower"], ["T12", 0.341, "lower"], ["BS6", 1.39, "lower"], ["AGS", 0.85, "greater"], ["N4E", 0.33, "lower"], ["B2F", 3.65, "greater"], ["S63", 3.48, "lower"], ["AGS", 0.819, "greater"], ["B2F", 3.4, "lower"], ["J69U", 2.02, "lower"], ["S63", 3.75, "lower"], ["C22", 1.1, "lower"], ] w.set_stock_to_watchlist(price_limit_reach_watchlist, watchlist_type="curr_price") api_key_path = r"C:\Users\356039\Desktop\running bat\pushbullet_api\key.txt" with open(api_key_path, "r") as f: apiKey = f.read() p = PushBullet(apiKey) ## for price set alert w.scan_price_limit_alert() if len(w.price_limit_alerts_df) > 0: p.pushNote("all", "Price alert", w.price_limit_alerts_df.to_string(), recipient_type="random1") print "completed"
def shortsell_notification(self): """ Use for alerts on shortsell information. Identify top ten short sell plus target stock short sell information. """ ## get the current price df so can combined with the shortsell info self.process_all_data() merged_shortsell_df = pandas.merge( self.shortsell_info_df, self.sgx_curr_price_df, left_on="Security", right_on="CompanyName" ) ## add in additional columns merged_shortsell_df["shortsell_vol_per"] = ( merged_shortsell_df["Short Sale Volume"] / merged_shortsell_df["DailyVolume"] ) merged_shortsell_df["ranked_percent_vol_shortsell"] = merged_shortsell_df["shortsell_vol_per"].rank( method="min", ascending=False ) top_shortsell_df = merged_shortsell_df[merged_shortsell_df["ranked_shortsell"].isin(range(1, 16))] top_shortsell_df = top_shortsell_df.sort(columns="ranked_shortsell", ascending=True) top_shortsell_df = top_shortsell_df[["Security", "Short Sale Volume", "shortsell_lastdate"]] shortsell_top15_shtver = top_shortsell_df.to_string() api_key_path = r"C:\Users\356039\Desktop\running bat\pushbullet_api\key.txt" with open(api_key_path, "r") as f: apiKey = f.read() p = PushBullet(apiKey) if shortsell_top15_shtver: p.pushNote("all", "Shortsell top10", shortsell_top15_shtver, recipient_type="random1") ## display for target watchlist tar_watchlist_shortsell_df = merged_shortsell_df[ merged_shortsell_df["Security"].isin(self.companyname_watchlist) ] tar_watchlist_shortsell_df = tar_watchlist_shortsell_df[ ["Security", "Short Sale Volume", "ranked_shortsell", "shortsell_vol_per", "ranked_percent_vol_shortsell"] ] tar_watchlist_shortsell_df = tar_watchlist_shortsell_df[ tar_watchlist_shortsell_df["ranked_shortsell"].isin(range(1, 100)) ] tar_watchlist_shortsell_df = tar_watchlist_shortsell_df.sort(columns="ranked_shortsell", ascending=True) tar_watchlist_shortsell_shtver = tar_watchlist_shortsell_df.to_string() if tar_watchlist_shortsell_shtver: p.pushNote("all", "Shortsell targetwatchlist", tar_watchlist_shortsell_shtver, recipient_type="random1")
def retrieve_and_notify(self): """ Send notification of the required data. Required pushbullet account. """ self.process_all_data() self.joined_relevent_sgx_data() print 'list of company going ex date in 7 days' self.get_company_going_ex_date(7) #make this to user defined target. #cannot remove as depend on scheduling # hence self.announce_watchlist will not take effect. #get from excel ## target_stock_list = ['E28','564','C2PU','S6NU','P07', 'SV3U', ## '573','544','P40U', ## 'P13','S19','P07','E02', 'BN4','BS6','U96','J69U','S05', 'AGS', ## 'N4E','AJBU','T8JU','O23','T12', ## 'OV8','500', 'SV3U'] print 'target announcmenet' self.filter_key_announcement(self.announce_watchlist) from pyPushBullet.pushbullet import PushBullet api_key_path = r'C:\Users\356039\Desktop\running bat\pushbullet_api\key.txt' with open(api_key_path, 'r') as f: apiKey = f.read() p = PushBullet(apiKey) # to send all- change the recipent_type to arbitiary text p.pushNote('all', 'Ex Date Info', self.div_ex_date_shtver, recipient_type="random1") if self.filtered_announ_shtver: p.pushNote('all', 'Announcement Info', self.filtered_announ_shtver, recipient_type="random1") ## for price set alert self.retrieve_curr_price_df() self.scan_price_limit_alert() if len(self.price_limit_alerts_df) > 0: p.pushNote('all', 'Price alert', self.price_limit_alerts_df.to_string(), recipient_type="random1")
def shortsell_notification(self): """ Use for alerts on shortsell information. Identify top ten short sell plus target stock short sell information. """ ## get the current price df so can combined with the shortsell info self.process_all_data() merged_shortsell_df = pandas.merge(self.shortsell_info_df, self.sgx_curr_price_df, left_on='Security', right_on='CompanyName') ## add in additional columns merged_shortsell_df['shortsell_vol_per'] = merged_shortsell_df[ 'Short Sale Volume'] / merged_shortsell_df['DailyVolume'] merged_shortsell_df[ 'ranked_percent_vol_shortsell'] = merged_shortsell_df[ 'shortsell_vol_per'].rank(method='min', ascending=False) top_shortsell_df = merged_shortsell_df[ merged_shortsell_df['ranked_shortsell'].isin(range(1, 16))] top_shortsell_df = top_shortsell_df.sort(columns='ranked_shortsell', ascending=True) top_shortsell_df = top_shortsell_df[[ 'Security', 'Short Sale Volume', 'shortsell_lastdate' ]] shortsell_top15_shtver = top_shortsell_df.to_string() api_key_path = r'C:\Users\356039\Desktop\running bat\pushbullet_api\key.txt' with open(api_key_path, 'r') as f: apiKey = f.read() p = PushBullet(apiKey) if shortsell_top15_shtver: p.pushNote('all', 'Shortsell top10', shortsell_top15_shtver, recipient_type="random1") ## display for target watchlist tar_watchlist_shortsell_df = merged_shortsell_df[ merged_shortsell_df['Security'].isin(self.companyname_watchlist)] tar_watchlist_shortsell_df = tar_watchlist_shortsell_df[[ 'Security', 'Short Sale Volume', 'ranked_shortsell', 'shortsell_vol_per', 'ranked_percent_vol_shortsell' ]] tar_watchlist_shortsell_df = tar_watchlist_shortsell_df[ tar_watchlist_shortsell_df['ranked_shortsell'].isin(range(1, 100))] tar_watchlist_shortsell_df = tar_watchlist_shortsell_df.sort( columns='ranked_shortsell', ascending=True) tar_watchlist_shortsell_shtver = tar_watchlist_shortsell_df.to_string() if tar_watchlist_shortsell_shtver: p.pushNote('all', 'Shortsell targetwatchlist', tar_watchlist_shortsell_shtver, recipient_type="random1")
def retrieve_and_notify(self): """ Send notification of the required data. Required pushbullet account. """ self.process_all_data() self.joined_relevent_sgx_data() print "list of company going ex date in 7 days" self.get_company_going_ex_date(7) # make this to user defined target. # cannot remove as depend on scheduling # hence self.announce_watchlist will not take effect. # get from excel ## target_stock_list = ['E28','564','C2PU','S6NU','P07', 'SV3U', ## '573','544','P40U', ## 'P13','S19','P07','E02', 'BN4','BS6','U96','J69U','S05', 'AGS', ## 'N4E','AJBU','T8JU','O23','T12', ## 'OV8','500', 'SV3U'] print "target announcmenet" self.filter_key_announcement(self.announce_watchlist) from pyPushBullet.pushbullet import PushBullet api_key_path = r"C:\Users\356039\Desktop\running bat\pushbullet_api\key.txt" with open(api_key_path, "r") as f: apiKey = f.read() p = PushBullet(apiKey) # to send all- change the recipent_type to arbitiary text p.pushNote("all", "Ex Date Info", self.div_ex_date_shtver, recipient_type="random1") if self.filtered_announ_shtver: p.pushNote("all", "Announcement Info", self.filtered_announ_shtver, recipient_type="random1") ## for price set alert self.retrieve_curr_price_df() self.scan_price_limit_alert() if len(self.price_limit_alerts_df) > 0: p.pushNote("all", "Price alert", self.price_limit_alerts_df.to_string(), recipient_type="random1")