We prove an analog of the holomorphic Lefschetz formula for endofunctors of smooth compact dg-categories. We deduce from it a generalization of the Lefschetz formula of V. Lunts [21] that takes the form of a reciprocity law for a pair of commuting endofunctors. As an application, we prove a version of Lefschetz formula proposed by Frenkel and Ngô in [16]. Also, we compute explicitly the ingre-