-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
54 lines (44 loc) · 1.83 KB
/
example_usage.py
File metadata and controls
54 lines (44 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Example usage of SpendSmart application."""
from main import SpendSmart
import logging
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
# Example: Process transactions
def example_process_transactions():
"""Example of processing transactions."""
# Replace with your actual Plaid access token
plaid_access_token = "your_plaid_access_token_here"
# Initialize application
app = SpendSmart(plaid_access_token)
try:
# Process last 30 days of transactions
stats = app.fetch_and_process_transactions(days=30, sync_to_sheets=True)
print("\nProcessing Statistics:")
print(f" Total fetched: {stats['total_fetched']}")
print(f" New transactions: {stats['new_transactions']}")
print(f" Categorized: {stats['categorized']}")
print(f" Average confidence: {stats['average_confidence']:.2%}")
print(f" Synced to sheets: {stats['synced_to_sheets']}")
# Get category summary
summary = app.get_category_summary()
print("\nSpending Summary by Category:")
for category, data in sorted(
summary.items(),
key=lambda x: x[1]['total'],
reverse=True
):
print(f" {category}: ${data['total']:.2f} ({data['count']} transactions)")
finally:
app.close()
if __name__ == "__main__":
print("SpendSmart Example Usage")
print("=" * 50)
print("\nNote: Make sure to:")
print("1. Set up your .env file with API credentials")
print("2. Replace 'your_plaid_access_token_here' with your actual token")
print("3. Have PostgreSQL running and database created")
print("\nUncomment the function call below to run the example:")
# example_process_transactions()