In type II strings compactified on a Calabi-Yau threefold X, the low energy effective action receives infinite series of instanton corrections from Euclidean D-branes wrapping X. In particular, in the large volume limit and for fixed D3-brane charge, corrections due to D3-D1-D(-1) instantons involve a non-holomorphic theta series of indefinite signature $(1,b_2(X)-1)$. Supersymmetry requires that these corrections be described by holomorphic data, but naive holomorphic theta series of indefinite signature are divergent. In the main part of the talk, generalizing a construction due to Zwegers, I will explain how to define convergent holomorphic theta series for lattices of arbitrary signature, and how to find their modular completion (this part will not require any physics background). If time permits, I will then explain how this construction can be used to prove that D3-instanton corrections conspire to preserve an isometric action of S-duality on the hypermultiplet moduli space in CY string vacua. Based on [arXiv:1605.05945] (for physicists) and [arXiv:1606.05495] (for mathematicians).