Skip to content

Instantly share code, notes, and snippets.

@OxMarco
Created February 18, 2025 14:30
Show Gist options
  • Save OxMarco/d134a4ba38e2ca6bd9bfd077223ac6ad to your computer and use it in GitHub Desktop.
Save OxMarco/d134a4ba38e2ca6bd9bfd077223ac6ad to your computer and use it in GitHub Desktop.

Financial analytics tools for merchants

Data Collected

Customers

By storing and analysing the payment card data, we can derive the following:

  • New vs returning customers
  • Geographical origin

Products

Tracking sales gives us:

  • Peak times
  • Product performance
  • Store vs store performance
  • Sales trends
    • hourly (coffees are mostly sold at 8-9am and 6-7pm)
    • daily (Sunday sales for trousers are highest, tshirts mostly sell on Wed)
    • weekly
    • seasonal

Transactions

Looking at the transactions for a given time period, we can obtain:

  • Avg. spent
  • Card type
  • Customer spending pattern

Predictions

Feeding the aforementioned data points, merchants can derive valuable data to optimise their CAC, loyalty programs and sales strategies.

Customers

  • Loyalty campaigns: Use time-based insights to run time-sensitive promotions. For example, a “Happy Hour” discount during a known dull hour can attract more customers.
  • Customer engagement: Tailor ads based on purchasing trends—promote items that have higher profit margins or that pair well together.

Inventory

  • Efficient stock management - predict when an item will run out of stock

Promotions

  • Evaluate efficacy of promotions respective to the season and the customer persona targeted.

Models

  • ARIMA and Holt-Winters' models: predict inventory depletion, cashflow for the week or month, avg. transaction size
  • Customer segmentation and Cohort analysis: separate customers to track favourite items and spending patterns
  • Prophet (by Fb) and Random forest models: time series analysis tools, good for stock management and cashflow predictions
  • Local Linear trend model: identify peaks in non-homogeneous datasets

$$ y_t = \mu_t + \epsilon_t $$

where

$$ \mu_{t+1} = \mu_t + \delta_t + \eta_t $$

and

$$ \delta_{t+1} = \delta_t + \zeta_t $$

All of these are within the variables $(0, \sigma^2)$ interval.

To the base model we can add a seasonality component, depending if the dataset is statistically significant in number (> 5) and the variance is reasonable according to a T-test.

$$ s_{t+1} = -\sum_{j=0}^{S-2} s_{t-j} + \omega_t, \quad \omega_t \sim N(0, \sigma_\omega^2) $$

  • General GARCH model:

$$ \sigma_t^2 = \omega + \sum_{i=1}^{q} \alpha_i \epsilon_{t-i}^2 + \sum_{j=1}^{p} \beta_j \sigma_{t-j}^2 $$

Variance considerations as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment