Download seed.py from smlflg/FireTracker: direct link, hf CLI and curl.
- Browser
- Download file 2.62 kB
-
https://huggingface.co/smlflg/FireTracker/resolve/main/seed.py
- Command line
-
hf download hf://smlflg/FireTracker/seed.py
-
curl -L -o seed.py https://huggingface.co/smlflg/FireTracker/resolve/main/seed.py
2.62 kB
| #!/usr/bin/env python3 | |
| """Seed script — Demo-Daten für schnelles lokales Testen.""" | |
| from datetime import date, datetime | |
| from database import init_db, SessionLocal | |
| from models import UserProfile, Asset, Snapshot | |
| def seed(): | |
| init_db() | |
| db = SessionLocal() | |
| # Idempotent: nur seeden wenn DB leer | |
| if db.query(UserProfile).first(): | |
| print("DB bereits befüllt — überspringe seed.") | |
| db.close() | |
| return | |
| # UserProfile | |
| profile = UserProfile( | |
| name="Samuel", | |
| monthly_income=4200, | |
| monthly_expenses=2100, | |
| birth_year=1995, | |
| target_retirement_age=50, | |
| swr=0.04, | |
| expected_return=0.07, | |
| inflation=0.02, | |
| ) | |
| db.add(profile) | |
| db.flush() | |
| # Assets | |
| assets = [ | |
| Asset( | |
| name="Vanguard FTSE All-World", | |
| asset_type="depot", | |
| current_value=45000, | |
| monthly_contribution=800, | |
| notes="Hauptdepot, Trade Republic", | |
| icon="📈", | |
| ), | |
| Asset( | |
| name="Wohnung Mannheim", | |
| asset_type="immobilie", | |
| current_value=180000, | |
| monthly_contribution=0, | |
| expected_return_override=0.03, | |
| notes="ETW, vermietet, 650€ Kaltmiete", | |
| icon="🏠", | |
| ), | |
| Asset( | |
| name="Tagesgeld ING", | |
| asset_type="cash", | |
| current_value=8500, | |
| monthly_contribution=200, | |
| expected_return_override=0.025, | |
| notes="Notgroschen, 6 Monate", | |
| icon="💰", | |
| ), | |
| Asset( | |
| name="Bitcoin", | |
| asset_type="crypto", | |
| current_value=12000, | |
| monthly_contribution=100, | |
| expected_return_override=0.10, | |
| notes="Cold Wallet, DCA", | |
| icon="₿", | |
| ), | |
| Asset( | |
| name="Riester-Rente", | |
| asset_type="pension", | |
| current_value=6200, | |
| monthly_contribution=162, | |
| expected_return_override=0.04, | |
| notes="fairr / Sutorbank", | |
| icon="🏛️", | |
| ), | |
| ] | |
| db.add_all(assets) | |
| db.flush() | |
| # Snapshots — ein initialer pro Asset | |
| today = date.today() | |
| for asset in assets: | |
| snapshot = Snapshot( | |
| asset_id=asset.id, | |
| date=today, | |
| value=asset.current_value, | |
| ) | |
| db.add(snapshot) | |
| total = sum(a.current_value for a in assets) | |
| db.commit() | |
| db.close() | |
| print(f"Seed erfolgreich! {len(assets)} Assets, Portfolio: {total:,.0f}€") | |
| if __name__ == "__main__": | |
| seed() | |