|
|
|
|
@ -327,7 +327,7 @@ class InsiderTransactionService:
|
|
|
|
|
if end:
|
|
|
|
|
conditions.append(InsiderTransaction.filing_date <= datetime(end.year, end.month, end.day, 23, 59, 59, tzinfo=timezone.utc))
|
|
|
|
|
if buy_only:
|
|
|
|
|
conditions.append(InsiderTransaction.transaction_code.in_(["P", "A"]))
|
|
|
|
|
conditions.append(InsiderTransaction.transaction_code == "P")
|
|
|
|
|
conditions.append(InsiderTransaction.shares > 0)
|
|
|
|
|
if csuite_only:
|
|
|
|
|
conditions.append(InsiderTransaction.is_c_suite == True)
|
|
|
|
|
@ -357,7 +357,7 @@ class InsiderTransactionService:
|
|
|
|
|
func.cast(InsiderTransaction.filing_date, SADate) == filing_date,
|
|
|
|
|
]
|
|
|
|
|
if buy_only:
|
|
|
|
|
conditions.append(InsiderTransaction.transaction_code.in_(["P", "A"]))
|
|
|
|
|
conditions.append(InsiderTransaction.transaction_code == "P")
|
|
|
|
|
conditions.append(InsiderTransaction.shares > 0)
|
|
|
|
|
|
|
|
|
|
result = await db.execute(
|
|
|
|
|
@ -384,7 +384,7 @@ class InsiderTransactionService:
|
|
|
|
|
InsiderTransaction.ticker == ticker,
|
|
|
|
|
InsiderTransaction.filing_date > window_start,
|
|
|
|
|
InsiderTransaction.filing_date <= as_of_dt,
|
|
|
|
|
InsiderTransaction.transaction_code.in_(["P", "A"]),
|
|
|
|
|
InsiderTransaction.transaction_code == "P",
|
|
|
|
|
InsiderTransaction.shares > 0,
|
|
|
|
|
InsiderTransaction.is_derivative == False,
|
|
|
|
|
)
|
|
|
|
|
@ -553,9 +553,9 @@ class InsiderTransactionService:
|
|
|
|
|
if price is not None and shares is not None:
|
|
|
|
|
total_value = round(abs(shares) * price, 2)
|
|
|
|
|
|
|
|
|
|
# purchase_pct_of_holding: only for open-market buys/awards with known post-holding
|
|
|
|
|
# purchase_pct_of_holding: only for open-market purchases (P) with known post-holding
|
|
|
|
|
purchase_pct = None
|
|
|
|
|
if code in ("P", "A") and shares is not None and shares > 0 and shares_after and shares_after > 0:
|
|
|
|
|
if code == "P" and shares is not None and shares > 0 and shares_after and shares_after > 0:
|
|
|
|
|
purchase_pct = abs(shares) / shares_after
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|