Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -562,19 +562,21 @@ def ticker_insider_trades_page():
|
|
| 562 |
help="Enter the stock ticker symbol (e.g., AAPL for Apple Inc.).").upper()
|
| 563 |
|
| 564 |
if st.sidebar.button("Fetch Data"):
|
| 565 |
-
with st.spinner("Fetching insider trading data..."):
|
| 566 |
try:
|
| 567 |
latest_transactions, trade_statistics = get_insider_trading_data(symbol)
|
| 568 |
# Save to session state
|
| 569 |
st.session_state['ticker_insider_trades']['symbol'] = symbol
|
| 570 |
st.session_state['ticker_insider_trades']['latest_transactions'] = latest_transactions
|
| 571 |
st.session_state['ticker_insider_trades']['trade_statistics'] = trade_statistics
|
| 572 |
-
st.success("Data fetched successfully!")
|
|
|
|
| 573 |
except Exception as e:
|
| 574 |
st.error(f"Error fetching data: {e}")
|
| 575 |
|
| 576 |
# Check if data is available
|
| 577 |
if 'latest_transactions' in st.session_state['ticker_insider_trades']:
|
|
|
|
| 578 |
latest_transactions = st.session_state['ticker_insider_trades']['latest_transactions']
|
| 579 |
trade_statistics = st.session_state['ticker_insider_trades']['trade_statistics']
|
| 580 |
|
|
@@ -582,8 +584,8 @@ def ticker_insider_trades_page():
|
|
| 582 |
#st.subheader("Insider Trading Activity Insights")
|
| 583 |
|
| 584 |
# Chart 1: Monthly Transactions and Securities Transacted
|
|
|
|
| 585 |
st.markdown("""
|
| 586 |
-
### Monthly Transactions and Securities Transacted
|
| 587 |
This chart visualizes the number of acquisition and disposition transactions each month, alongside the total volume of securities transacted.
|
| 588 |
- **Lines** represent the count of transactions.
|
| 589 |
- **Bars** represent the volume of securities transacted.
|
|
@@ -592,8 +594,8 @@ def ticker_insider_trades_page():
|
|
| 592 |
st.plotly_chart(create_monthly_transactions_chart(latest_transactions), use_container_width=True)
|
| 593 |
|
| 594 |
# Chart 2: Trade Statistics Over Time
|
|
|
|
| 595 |
st.markdown("""
|
| 596 |
-
### Trade Statistics Over Time
|
| 597 |
This chart displays the trends in purchases, sales, and the buy/sell ratio over different quarters.
|
| 598 |
- **Purchases and Sales**: Represent the count of buy and sell transactions.
|
| 599 |
- **Buy/Sell Ratio**: Indicates the balance between buying and selling activities.
|
|
@@ -601,8 +603,8 @@ def ticker_insider_trades_page():
|
|
| 601 |
st.plotly_chart(create_trade_statistics_over_time_chart(trade_statistics), use_container_width=True)
|
| 602 |
|
| 603 |
# Chart 3: Total and Average Bought/Sold
|
|
|
|
| 604 |
st.markdown("""
|
| 605 |
-
### Total and Average Bought/Sold with Average Buy/Sell Ratio Over Time
|
| 606 |
This chart combines total and average amounts of securities bought and sold, along with the average buy/sell ratio.
|
| 607 |
- **Bars** show the total bought and sold.
|
| 608 |
- **Lines** indicate the average bought and sold per transaction.
|
|
@@ -611,14 +613,14 @@ def ticker_insider_trades_page():
|
|
| 611 |
st.plotly_chart(create_total_avg_bought_sold_chart(trade_statistics), use_container_width=True)
|
| 612 |
|
| 613 |
# Display DataFrames
|
| 614 |
-
st.subheader("Latest Transactional Data")
|
| 615 |
st.markdown("""
|
| 616 |
Below is the detailed table of the most recent insider transactions for the selected ticker.
|
| 617 |
It includes information such as the date of transaction, type (acquisition or disposition), and the number of securities transacted.
|
| 618 |
""")
|
| 619 |
st.dataframe(latest_transactions, use_container_width=True)
|
| 620 |
|
| 621 |
-
st.subheader("Trade Statistics Data")
|
| 622 |
st.markdown("""
|
| 623 |
This table presents aggregated trade statistics over time, including total purchases, sales, and the buy/sell ratio for each quarter.
|
| 624 |
""")
|
|
|
|
| 562 |
help="Enter the stock ticker symbol (e.g., AAPL for Apple Inc.).").upper()
|
| 563 |
|
| 564 |
if st.sidebar.button("Fetch Data"):
|
| 565 |
+
with st.spinner(f"Fetching insider trading data for {symbol}..."):
|
| 566 |
try:
|
| 567 |
latest_transactions, trade_statistics = get_insider_trading_data(symbol)
|
| 568 |
# Save to session state
|
| 569 |
st.session_state['ticker_insider_trades']['symbol'] = symbol
|
| 570 |
st.session_state['ticker_insider_trades']['latest_transactions'] = latest_transactions
|
| 571 |
st.session_state['ticker_insider_trades']['trade_statistics'] = trade_statistics
|
| 572 |
+
st.success(f"Data for {symbol} fetched successfully!")
|
| 573 |
+
#st.success("Data fetched successfully!")
|
| 574 |
except Exception as e:
|
| 575 |
st.error(f"Error fetching data: {e}")
|
| 576 |
|
| 577 |
# Check if data is available
|
| 578 |
if 'latest_transactions' in st.session_state['ticker_insider_trades']:
|
| 579 |
+
symbol = st.session_state['ticker_insider_trades']['symbol']
|
| 580 |
latest_transactions = st.session_state['ticker_insider_trades']['latest_transactions']
|
| 581 |
trade_statistics = st.session_state['ticker_insider_trades']['trade_statistics']
|
| 582 |
|
|
|
|
| 584 |
#st.subheader("Insider Trading Activity Insights")
|
| 585 |
|
| 586 |
# Chart 1: Monthly Transactions and Securities Transacted
|
| 587 |
+
st.markdown(f"### Monthly Transactions and Securities Transacted for {symbol}")
|
| 588 |
st.markdown("""
|
|
|
|
| 589 |
This chart visualizes the number of acquisition and disposition transactions each month, alongside the total volume of securities transacted.
|
| 590 |
- **Lines** represent the count of transactions.
|
| 591 |
- **Bars** represent the volume of securities transacted.
|
|
|
|
| 594 |
st.plotly_chart(create_monthly_transactions_chart(latest_transactions), use_container_width=True)
|
| 595 |
|
| 596 |
# Chart 2: Trade Statistics Over Time
|
| 597 |
+
st.markdown(f"### Trade Statistics Over Time for {symbol}")
|
| 598 |
st.markdown("""
|
|
|
|
| 599 |
This chart displays the trends in purchases, sales, and the buy/sell ratio over different quarters.
|
| 600 |
- **Purchases and Sales**: Represent the count of buy and sell transactions.
|
| 601 |
- **Buy/Sell Ratio**: Indicates the balance between buying and selling activities.
|
|
|
|
| 603 |
st.plotly_chart(create_trade_statistics_over_time_chart(trade_statistics), use_container_width=True)
|
| 604 |
|
| 605 |
# Chart 3: Total and Average Bought/Sold
|
| 606 |
+
st.markdown(f"### Average Bought/Sold and Buy/Sell Ratio for {symbol}")
|
| 607 |
st.markdown("""
|
|
|
|
| 608 |
This chart combines total and average amounts of securities bought and sold, along with the average buy/sell ratio.
|
| 609 |
- **Bars** show the total bought and sold.
|
| 610 |
- **Lines** indicate the average bought and sold per transaction.
|
|
|
|
| 613 |
st.plotly_chart(create_total_avg_bought_sold_chart(trade_statistics), use_container_width=True)
|
| 614 |
|
| 615 |
# Display DataFrames
|
| 616 |
+
st.subheader(f"Latest Transactional Data for {symbol}")
|
| 617 |
st.markdown("""
|
| 618 |
Below is the detailed table of the most recent insider transactions for the selected ticker.
|
| 619 |
It includes information such as the date of transaction, type (acquisition or disposition), and the number of securities transacted.
|
| 620 |
""")
|
| 621 |
st.dataframe(latest_transactions, use_container_width=True)
|
| 622 |
|
| 623 |
+
st.subheader(f"Trade Statistics Data for {symbol}")
|
| 624 |
st.markdown("""
|
| 625 |
This table presents aggregated trade statistics over time, including total purchases, sales, and the buy/sell ratio for each quarter.
|
| 626 |
""")
|