Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AdoNunes committed Aug 6, 2024
2 parents 36db3d8 + a24b120 commit 86837ab
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DiscordAlertsTrader/alerts_trader.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def confirm_and_send(self, order, pars, order_funct):
return None, None, order, None

if ord_resp is None:
raise("Something wrong with order response")
return None, None, order, None

str_msg = f"Sent order {order['action']} {order['Qty']} {order['Symbol']} @{order['price']}"
print(Back.GREEN + str_msg)
Expand Down
3 changes: 2 additions & 1 deletion DiscordAlertsTrader/brokerages/ibkr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ def get_quotes(self, symbols:list):
con_id = self.get_con_id(symbol)
print(con_id)
contract = Contract(conId=con_id)
self.ib.sleep(0.1)
contract = self.ib.qualifyContracts(contract)[0]
self.ib.sleep(0.1)
quote = self.ib.reqTickers(contract)
Expand Down Expand Up @@ -445,7 +446,7 @@ def _convert_option_to_ibkr(self, ticker):

date = year + month + date
right = (option_part[6])
strike = int(option_part[7:])
strike = float(option_part[7:])

return Option(symbol=symb, lastTradeDateOrContractMonth=date, \
strike=strike, right=right, \
Expand Down
2 changes: 2 additions & 0 deletions DiscordAlertsTrader/config_example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ webhook_name = DAlertsTrader
# if notify_alerts_to_discord = True, optionally, specify the channel id for sending alert as a user
# not implemented yet
send_alerts_to_chan =
# channel where to read commands, can be !close long !close short !close all. Leave 0 to disable
commands_channel = 0

[order_configs]
# make the order based on actual price, not the alerted, can be true or false. If False
Expand Down
5 changes: 3 additions & 2 deletions DiscordAlertsTrader/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def fit_table_elms(Widget_element):
]
layout += gl.trigger_alerts_layout()
print(3)
window = sg.Window(f'Discord Alerts Trader - with broker {bksession.name}', layout,size=(100, 800), # force_toplevel=True,
bk_name = "None" if bksession is None else bksession.name
window = sg.Window(f'Discord Alerts Trader - with broker {bk_name}', layout,size=(100, 800), # force_toplevel=True,
auto_size_text=True, resizable=True)
print(4)
def mprint_queue(queue_item_list, subscribed_author=False):
Expand Down Expand Up @@ -331,7 +332,7 @@ def run_gui():
if '_portfolio_' in event:
pix = values['_portfolio_'][0]
dt, hdr = gg.get_portf_data(port_exc, **values)
if len(dt):
if len(dt) and len(dt) > pix:
qty = dt[pix][hdr.index('filledQty')]
else:
qty = ""
Expand Down
2 changes: 1 addition & 1 deletion DiscordAlertsTrader/message_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def parse_trade_alert(msg, asset=None):
match = re.search(pattern, msg, re.IGNORECASE)
strike_date = True
if match is None:
pattern = r'\b(BTO|STC|STO|BTC)\b\s*(\d+)?\s*([A-Z]+)\s*(\d{1,2}\/\d{1,2}(?:\/\d{2,4})?)?\s*(\d+[.\d+]*[CP]?)?\s@*[$]*[ ]*(\d+(?:[,.]\d+)?|\.\d+)'
pattern = r'\b(BTO|STC|STO|BTC)\b\s*(\d+)?\s*([A-Z]+)\s*(\d{1,2}\/\d{1,2}(?:\/\d{2,4})?)?\s*(\d+[.\d+]*[CP]?)?\s*@*[$]*[ ]*(\d+(?:[,.]\d+)?|\.\d+)'
match = re.search(pattern, msg, re.IGNORECASE)
strike_date = False
if match:
Expand Down
7 changes: 7 additions & 0 deletions DiscordAlertsTrader/server_alert_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ def tradeproelite_formatting(message_):
message.author.name = 'enhancedmarket'
message.author.discriminator = '0'
return message

if message_.author.name == 'Alertsify':
message = MessageCopy(message_)
message.author.name = message.embeds[0].author.name
message.content = message.embeds[0].description
message.author.discriminator = '0'
return message

return message_

Expand Down

0 comments on commit 86837ab

Please sign in to comment.