We give a moduli interpretation of the outer automorphism group Out of a finite-dimensional algebra similar to that of the Picard group of a scheme. We deduce that the connected component of Out is invariant under derived and stable equivalences. This allows us to transfer gradings between algebras and gives rise to conjectural homological constructions of interesting gradings on blocks of finite groups with abelian defect. We give applications to the lifting of stable equivalences to derived equivalences. We give a counterpart of the invariance result for smooth projective varieties: the product Pic0 × Aut0 is invariant under derived equivalence.