For white balancing there are some resources online that all talk about different algorithms, but they are all saying there is no perfect solution.
Most resources try to automate white balancing by determining a mid grey point. This is called Illuminant Estimation.
This forum thread discusses about the most commonly used algorithms:
https://www.dpreview.com/forums/thread/3641620
Gray-world seems to be the most common:
https://web.stanford.edu/~sujason/ColorBalancing/grayworld.html
The chromatic adaptation has different methods also, mentioned here:
https://web.stanford.edu/~sujason/ColorBalancing/adaptation.html
They refer to http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html which has a good outline of different adaptation matrices.