Hugo Le Moine's Digital Garden and Blog

website·Indexed 30 days ago

https://hugolmn.github.io

A personal website featuring a digital garden on finance (stocks, ETFs, and account types), a blog with data science projects including SNCF found items and Twitter API usage, and a portfolio of projects such as TGV economic performance optimization and automatic noise detection.

Tokens
13.1K
Snippets
47
Records
86
Agent score
73%

What's inside Hugo Le Moine

  1. Understand the characteristics of individual stocks

    Stocks are the individual components that make up an ETF. Investing in individual stocks allows for precise control over portfolio composition, the potential for significantly higher returns than a broad index, and the elimination of management fees. The trade-off is the requirement for extensive due diligence and the risk of overconcentration.
  2. Understand the characteristics of Exchange Traded Funds (ETFs)

    ETFs are investment securities traded like stocks, but instead of a single company, they represent a 'basket' of stocks called an index. This allows investors to achieve instant diversification across thousands of constituents, specific countries, or sectors without manually picking individual stocks. Accumulative ETFs provide an additional benefit by automatically reinvesting dividends, which simplifies tax filing.
  3. Delete tweets programmatically with Tweepy

    Use the delete_tweet method passing the specific tweet ID. Note that Twitter imposes a rate limit on tweet deletions (approximately 50 per 15-minute window), which may cause large-scale deletions to take several hours.
    from tqdm import tqdm
    
    # Assuming 'tweets' is a list of tweet objects retrieved via get_users_tweets
    for tweet in tqdm(tweets):
        client.delete_tweet(tweet.id)
  4. Use LEP for high-interest low-income savings

    The LEP (Livret d'Epargne Populaire) offers higher interest rates than Livret A (at least Livret A + 0.5%, or current inflation if higher).

    Eligibility and Constraints:

    • Taxable income must be under 22,419€ for a single person (as of March 1st 2024).
    • Savings amount is capped at 10,000€ (interest can exceed this).
    • You can only hold one LEP.
    • The account is only closed if taxable income exceeds the limit for two consecutive years.
  5. Process SNCF train station and found items data with Pandas

    To analyze found items relative to station attendance, you can merge three SNCF datasets: station attendance (frequentation-gares), station reference data (referentiel-gares-voyageurs), and found items (objets-trouves-restitution). The common identifier across these datasets is the UIC code (International Union of Railways).
    import pandas as pd
    import numpy as np
    import plotly.colors
    import plotly.graph_objects as go
    
    # 1. Reading csv files
    df_frequentation = pd.read_csv('data/frequentation-gares.csv', sep=';')
    df_gares = pd.read_csv('data/referentiel-gares-voyageurs.csv', sep=';')
    df_items = pd.read_csv('data/objets-trouves-restitution.csv', sep=';')
    
    # 2. Merging dataframes using UIC codes
    df = df_gares.merge(
        right=df_frequentation, 
        left_on='Code UIC', 
        right_on='Code UIC complet', 
        how='inner')
    
    df = df.merge(df_items, on='Code UIC', how='right')
  6. Set up a Twitter Developer account and App

    To use the Twitter API, you must obtain a developer account. For basic automation tasks, the 'Essential' level is typically sufficient. After obtaining an account, you must create an app in the Developer Portal to generate the necessary keys and tokens.

    Crucial configuration steps:

    1. In the 'Settings' tab, activate 'OAuth 1.0a'.
    2. Set permissions to 'Read and write'.
    3. Provide a Callback URI / Redirect URL (e.g., a personal GitHub page).
    4. Retrieve the consumer keys and generate authentication tokens in the 'Keys and tokens' tab.
  7. Process and visualize SNCF train station attendance data

    This workflow demonstrates how to combine SNCF train station reference data with attendance statistics to create an interactive Mapbox scatter plot. The process involves merging two datasets on the UIC code, filtering for stations with more than 1,000 passengers, and categorizing stations by passenger volume for visual distinction.
    import pandas as pd
    import numpy as np
    import plotly.colors
    import plotly.graph_objects as go
    
    # 1. Load data
    df_frequentation = pd.read_csv('data/frequentation-gares.csv', sep=';')
    df_gares = pd.read_csv('data/referentiel-gares-voyageurs.csv', sep=';')
    
    # 2. Merge on UIC Code (different column names in each file)
    df = df_gares.merge(
        right=df_frequentation,
        left_on='Code UIC',
        right_on='Code UIC complet',
        how='inner')
    
    # 3. Filter for stations with > 1000 passengers
    df = df[df['Total Voyageurs 2018'] > 1000]
    
    # 4. Categorize passenger volume for coloring
    df['category'] = pd.cut(df['Total Voyageurs 2018'], bins=[1e4, 1e5, 1e6, 1e7, np.inf])
  8. Use Assurance Vie for inheritance and long-term tax optimization

    Assurance Vie (Life Insurance) is used for long-term wealth and inheritance optimization.

    Tax Benefits:

    • 17.2% social taxes + 7.5% flat tax on realized profits.
    • For contracts > 8 years: annual profit withdrawals up to 4,600€ (9,200€ for partners) are tax-exempt.

    Constraints:

    • Withdrawals within the first 8 years trigger a 30% flat tax.
    • Deposits beyond 150,000€ (across all contracts) are subject to the 30% flat tax.
    • You can hold multiple Life Insurance contracts.
  9. Use a PEA-PME for small-cap EU business investing

    The PEA-PME is similar to the PEA but restricted to Small and Medium Businesses (SMBs) in the EU.

    Eligibility for SMBs:

    • < 5k employees AND (revenue < 1.5B€ OR balance sheet < 2B€), OR
    • Market capitalization < 1B€.

    Constraints:

    • Cumulative deposits are limited to 225,000€ (this limit is shared between PEA and PEA-PME).
    • You can only hold one PEA-PME.
  10. Implement an unsupervised audio noise detection pipeline

    To automatically detect unwanted parasitic noise in audio recordings without prior knowledge of the noise types, use the following unsupervised pipeline:

    1. Harmonic-Percussive Source Separation (HPSS): Separate the signal to filter out tonal and broadband noise, keeping the percussive component (vertical lines on a spectrogram) which typically represents shocks, clicks, or voice.
    2. Feature Extraction: Extract signal characteristics using the librosa library.
    3. Feature Enrichment: Apply a sliding window to compute statistical indicators (standard deviation, skewness, and kurtosis) for each feature to capture local dispersion and distribution asymmetry.
    4. Anomaly Scoring: Use an Isolation Forest algorithm to score the n-dimensional data. Points with a score close to 1 are likely anomalies.
    5. Smoothing: Apply a rolling window (e.g., n-decile or standard deviation) to the scores to reduce false positives.