@@ -89,13 +89,27 @@ async def make_tweet_embed(
89
89
# Ensure the tickers are unique
90
90
symbols = get_clean_symbols (tickers , hashtags )[:24 ]
91
91
92
- e = make_embed (symbols , url , text , profile_pic , images , e_title , media_types )
92
+ # Check for difference
93
+ if symbols != tickers + hashtags :
94
+ logger .debug (
95
+ f"Removed following symbols: { set (tickers + hashtags ) - set (symbols )} "
96
+ )
97
+
98
+ e = make_embed (
99
+ symbols = symbols ,
100
+ url = url ,
101
+ text = text ,
102
+ profile_pic = profile_pic ,
103
+ images = images ,
104
+ e_title = e_title ,
105
+ media_types = media_types ,
106
+ )
93
107
94
108
# Max 25 fields
95
109
if symbols :
96
- logger .debug ("Adding financials to tweet embed... " )
110
+ logger .debug (f "Adding financials for symbols: { symbols } " )
97
111
e , category , base_symbols = await add_financials (
98
- e , symbols , tickers , text , user_name , bot
112
+ e = e , symbols = symbols , tickers = tickers , text = text , user = user_name , bot = bot
99
113
)
100
114
101
115
return e , category , base_symbols
@@ -185,6 +199,9 @@ async def add_financials(
185
199
The base symbols of the tickers.
186
200
"""
187
201
global tweet_overview
202
+ logger .debug (
203
+ f"Adding financials to the embed. For symbols: { symbols } , tickers: { tickers } "
204
+ )
188
205
189
206
# In case multiple tickers get send
190
207
crypto = stocks = forex = 0
@@ -200,7 +217,8 @@ async def add_financials(
200
217
util .vars .classified_tickers = remove_old_rows (util .vars .classified_tickers , 3 )
201
218
classified_tickers = util .vars .classified_tickers ["ticker" ].tolist ()
202
219
203
- for ticker in symbols [24 :]:
220
+ for symbol in symbols :
221
+ logger .debug (f"Symbol: { symbol } " )
204
222
if crypto > stocks and crypto > forex :
205
223
majority = "crypto"
206
224
elif stocks > crypto and stocks > forex :
@@ -211,8 +229,10 @@ async def add_financials(
211
229
majority = "Unknown"
212
230
213
231
# Get the information about the ticker
214
- if ticker not in classified_tickers :
215
- ticker_info = await classify_ticker (ticker , majority )
232
+ if symbol not in classified_tickers :
233
+ logger .debug (f"Classifying ticker: { symbol } with majority: { majority } " )
234
+ ticker_info = await classify_ticker (symbol , majority )
235
+
216
236
if ticker_info :
217
237
(
218
238
_ ,
@@ -224,20 +244,23 @@ async def add_financials(
224
244
one_d_ta ,
225
245
base_symbol ,
226
246
) = ticker_info
247
+ logger .debug (
248
+ f"Classified ticker: { symbol } as { base_symbol } . Website: { website } "
249
+ )
227
250
228
251
# Skip if this ticker has been done before, for instance in tweets containing Solana and SOL
229
252
if base_symbol in base_symbols :
230
253
continue
231
254
232
255
if exchanges is None :
233
256
exchanges = []
234
- logger .warn ("No exchanges found for" , ticker )
257
+ logger .warn (f "No exchanges found for ticker: { symbol } " )
235
258
236
259
# Convert info to a dataframe
237
260
df = pd .DataFrame (
238
261
[
239
262
{
240
- "ticker" : ticker ,
263
+ "ticker" : symbol ,
241
264
"website" : website ,
242
265
# Db cannot handle lists, so we convert them to strings
243
266
"exchanges" : (
@@ -255,17 +278,18 @@ async def add_financials(
255
278
)
256
279
257
280
else :
258
- if ticker in tickers :
259
- e .add_field (name = f"${ ticker } " , value = majority )
260
- logger .debug (
261
- f"No crypto or stock match found for ${ ticker } in { user } 's tweet at { datetime .datetime .now ().strftime ('%Y-%m-%d %H:%M' )} "
262
- )
281
+ if symbol in tickers :
282
+ e .add_field (name = f"${ symbol } " , value = majority )
283
+ logger .debug (
284
+ f"No crypto or stock match found for ${ symbol } in { user } 's tweet at { datetime .datetime .now ().strftime ('%Y-%m-%d %H:%M' )} "
285
+ )
263
286
264
287
# Go to next in symbols
265
288
continue
266
289
else :
290
+ logger .debug (f"Found ticker { symbol } in previously classified tickers." )
267
291
ticker_info = util .vars .classified_tickers [
268
- util .vars .classified_tickers ["ticker" ] == ticker
292
+ util .vars .classified_tickers ["ticker" ] == symbol
269
293
]
270
294
website = ticker_info ["website" ].values [0 ]
271
295
exchanges = ticker_info ["exchanges" ].values [0 ]
@@ -274,9 +298,9 @@ async def add_financials(
274
298
base_symbol = ticker_info ["base_symbol" ].values [0 ]
275
299
276
300
# Still need the price, change, TA info
277
- price , change , four_h_ta , one_d_ta = await get_financials (ticker , website )
301
+ price , change , four_h_ta , one_d_ta = await get_financials (symbol , website )
278
302
279
- title = f"${ ticker } "
303
+ title = f"${ symbol } "
280
304
281
305
# Add to base symbol list to prevent duplicates
282
306
base_symbols .append (base_symbol )
0 commit comments