BRASIL ON ATZ NM mapping

This commit is contained in:
2025-11-09 13:12:45 -03:00
parent 5474644580
commit 0680f22e4d
3 changed files with 14 additions and 6 deletions

View File

@@ -10,6 +10,8 @@ from correpy.parsers.brokerage_notes.parser_factory import ParserFactory
from fastapi import UploadFile from fastapi import UploadFile
import re import re
import ntfy_service
account_id = '1590f1bb-b3ee-4dc8-ac46-bd1f15a83e87' account_id = '1590f1bb-b3ee-4dc8-ac46-bd1f15a83e87'
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -55,10 +57,20 @@ def convert_to_ghostfolio(brokerage_list: list, filename: str):
name = re.sub(r'@|#' , '', transaction.security.name.strip()) name = re.sub(r'@|#' , '', transaction.security.name.strip())
symbol = ''
try:
symbol = mappings.name_to_tickers[name.strip()].strip()
except:
logger.error(name.strip() + ' is not mapped.')
ntfy_service.send_notification(f'Failed to import: {name.strip()} is not mapped.')
activity = {'accountId': account_id, 'comment': filename, 'date': reference_date, activity = {'accountId': account_id, 'comment': filename, 'date': reference_date,
'type': transaction_type, 'type': transaction_type,
'fee': fees, 'unitPrice': transaction.unit_price, 'quantity': transaction.amount, 'fee': fees, 'unitPrice': transaction.unit_price, 'quantity': transaction.amount,
'symbol': mappings.name_to_tickers[name.strip()].strip(), 'symbol': symbol,
'currency': 'BRL', 'currency': 'BRL',
'dataSource': 'YAHOO'} 'dataSource': 'YAHOO'}
activities['activities'].append(activity) activities['activities'].append(activity)

View File

@@ -29,12 +29,7 @@ def import_activities(activities_json, filename: str):
if len(response.json()['activities']) < 1: if len(response.json()['activities']) < 1:
logger.info(f'No activity imported for {filename}') logger.info(f'No activity imported for {filename}')
print(f'No activity imported for {filename}')
ntfy_service.send_notification(f'No activity imported for {filename}') ntfy_service.send_notification(f'No activity imported for {filename}')
else: else:
ntfy_service.send_notification(f'Imported {len(response.json()['activities'])} activities from {filename}') ntfy_service.send_notification(f'Imported {len(response.json()['activities'])} activities from {filename}')
print(f'Imported {len(response.json()['activities'])} activities from {filename}')
# print(json.dumps(response.json(), indent=4))
return response.status_code return response.status_code

View File

@@ -1,6 +1,7 @@
name_to_tickers = { name_to_tickers = {
"BRASIL ON NM" : 'BBAS3.SA', "BRASIL ON NM" : 'BBAS3.SA',
"BRASIL ON EJ NM": 'BBAS3.SA', "BRASIL ON EJ NM": 'BBAS3.SA',
"BRASIL ON ATZ NM": 'BBAS3.SA',
"METAL LEVE ON NM": 'LEVE3.SA', "METAL LEVE ON NM": 'LEVE3.SA',
"METAL LEVE ON ED NM": 'LEVE3.SA', "METAL LEVE ON ED NM": 'LEVE3.SA',
"TRAN PAULIST PN N1": 'ISAE4.SA', "TRAN PAULIST PN N1": 'ISAE4.SA',