Skip to content

Commit

Permalink
fixed recent data on local stocks
Browse files Browse the repository at this point in the history
  • Loading branch information
leftmove committed Aug 16, 2024
1 parent ae45bb5 commit bcb2def
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"name": "FastAPI: Module",
"type": "debugpy",
"module": "main",
"args": ["development"],
"justMyCode": false,
"request": "launch",
"cwd": "${workspaceFolder}/backend"
Expand Down
31 changes: 15 additions & 16 deletions backend/routers/lib/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,20 @@ def serialize_local(
name = local_stock["name"]
cusip = local_stock["cusip"]

sector = global_stock["sector"]
industry = global_stock["industry"]
rights = local_stock["class"]
update = global_stock["update"]
sector = global_stock.get("sector", "NA")
industry = global_stock.get("industry", "NA")
rights = local_stock.get("class", "NA")
update = global_stock.get("update", False)

shares_held = local_stock["shares_held"]
market_value = local_stock["market_value"]
shares_held_str = f"{int(shares_held):,}"
market_value_str = f"${int(market_value):,}"

recent_price = global_stock["recent_price"]
recent_price_str = global_stock["recent_price_str"]
gain_percent = global_stock["gain_percent"]
gain_percent_str = global_stock["gain_str"]
# recent_price = global_stock["recent_price"]
# recent_price_str = global_stock["recent_price_str"]
# gain_percent = global_stock["gain_percent"]
# gain_percent_str = global_stock["gain_str"]

sold = local_stock["sold"]
records = local_stock["records"]
Expand Down Expand Up @@ -281,12 +281,12 @@ def serialize_local(
"time_str": sold_date_str,
"series": sold_series,
},
"recent": {
"price": recent_price,
"price_str": recent_price_str,
"gain_percent": gain_percent,
"gain_str": gain_percent_str,
},
# "recent": {
# "price": recent_price,
# "price_str": recent_price_str,
# "gain_percent": gain_percent,
# "gain_str": gain_percent_str,
# },
},
}

Expand Down Expand Up @@ -471,7 +471,6 @@ def analyze_filings(cik, filings, last_report):
)
prices = {"buy": buy_stamp, "sold": sold_stamp}
stock_cache[cusip]["prices"] = prices

local_stock["prices"] = prices

filing_stock = serialize_local(
Expand All @@ -487,7 +486,7 @@ def analyze_filings(cik, filings, last_report):
yield stock_query, filing_stock

except Exception as e:
logging.error(e)
errors.report_error(cik, e)
database.add_log(
cik, "Error Querying Stock for Filings", cusip, access_number
)
Expand Down
4 changes: 4 additions & 0 deletions backend/routers/lib/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def format_error(e, program=None):


def report_error(identifier, e):

if not production_environment:
raise e

stamp = timestamp()
error_path = create_path(identifier, stamp)
with open(error_path, "w") as f:
Expand Down
12 changes: 6 additions & 6 deletions backend/static/statistics.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"latest": {
"count": 23,
"total": 24267.306618213654,
"average": 1055.1002877484198
"count": 1,
"total": 32.566046953201294,
"average": 32.566046953201294
},
"historical": {
"count": 20,
"total": 135744.65614962578,
"average": 6787.232807481289
"count": 0,
"total": 0,
"average": 0
}
}

0 comments on commit bcb2def

Please sign in to comment.