@marcos_feitoza/personal-finance-backen-trades-assets 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.0.3](https://github.com/MarcosOps/personal-finance-backend-trades-assets/compare/v1.0.2...v1.0.3) (2025-11-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * crypto symbol working ([9c61bf9](https://github.com/MarcosOps/personal-finance-backend-trades-assets/commit/9c61bf91b382fc7563985c1973fc6a37e9e361c1))
7
+
1
8
  ## [1.0.2](https://github.com/MarcosOps/personal-finance-backend-trades-assets/compare/v1.0.1...v1.0.2) (2025-10-17)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marcos_feitoza/personal-finance-backen-trades-assets",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,7 +18,13 @@ def create_asset(asset: schemas.AssetCreate, db: Session = Depends(get_db)):
18
18
  db_asset = db.query(models.Asset).filter(models.Asset.symbol == asset.symbol).first()
19
19
  if db_asset:
20
20
  raise HTTPException(status_code=400, detail="Asset with this symbol already exists")
21
- db_asset = models.Asset(**asset.dict())
21
+ db_asset = models.Asset(
22
+ symbol=asset.symbol,
23
+ name=asset.name,
24
+ asset_type=asset.asset_type,
25
+ industry=asset.industry,
26
+ id_crypto=asset.id_crypto
27
+ )
22
28
  db.add(db_asset)
23
29
  db.commit()
24
30
  db.refresh(db_asset)
@@ -36,29 +36,20 @@ async def create_trade(trade: schemas.TradeCreate, db: Session = Depends(get_db)
36
36
  logger.info(f"Processing trade for symbol: {trade_symbol}")
37
37
 
38
38
  db_asset = db.query(models.Asset).filter(models.Asset.symbol == trade_symbol).first()
39
- if not db_asset and '.' not in trade_symbol:
40
- db_asset = db.query(models.Asset).filter(models.Asset.symbol == f"{trade_symbol}.TO").first()
41
39
 
42
40
  if not db_asset:
43
- logger.info(f"Asset with symbol {trade_symbol} not found. Fetching details...")
44
- asset_details = _get_asset_details_from_service(trade_symbol)
45
- canonical_symbol = asset_details.get("canonical_symbol", trade_symbol)
46
- db_asset = db.query(models.Asset).filter(models.Asset.symbol == canonical_symbol).first()
47
-
48
- if not db_asset:
49
- logger.info(f"Creating new asset with canonical symbol: {canonical_symbol}")
50
- db_asset = models.Asset(
51
- symbol=canonical_symbol,
52
- name=asset_details.get("name", canonical_symbol),
53
- asset_type=asset_details.get("asset_type", "Unknown"),
54
- industry=asset_details.get("industry", "N/A")
55
- )
56
- db.add(db_asset)
57
- db.commit()
58
- db.refresh(db_asset)
59
- logger.info(f"Created new asset with ID: {db_asset.id}")
60
- else:
61
- logger.info(f"Found existing asset with canonical symbol: {canonical_symbol}")
41
+ logger.info(f"Asset with symbol {trade_symbol} not found. Creating new asset...")
42
+ db_asset = models.Asset(
43
+ symbol=trade_symbol,
44
+ name=trade.name,
45
+ asset_type=trade.asset_type,
46
+ industry=trade.industry,
47
+ id_crypto=trade.id_crypto if hasattr(trade, 'id_crypto') else None
48
+ )
49
+ db.add(db_asset)
50
+ db.commit()
51
+ db.refresh(db_asset)
52
+ logger.info(f"Created new asset with ID: {db_asset.id}")
62
53
  else:
63
54
  logger.info(f"Found existing asset with ID: {db_asset.id}")
64
55
 
@@ -83,7 +74,7 @@ async def create_trade(trade: schemas.TradeCreate, db: Session = Depends(get_db)
83
74
  detail=f"Insufficient cash balance in '{investment_account_name}' to complete trade."
84
75
  )
85
76
 
86
- trade_data = trade.dict(exclude={'symbol', 'name', 'asset_type', 'industry'})
77
+ trade_data = trade.dict(exclude={'symbol', 'name', 'asset_type', 'industry', 'id_crypto'})
87
78
  db_trade = models.Trade(**trade_data, asset_id=db_asset.id)
88
79
 
89
80
  if db_trade.trade_type == 'buy':