In this paper we present a financial mathematical model, based on networks, aiming at maximizing the profits while simultaneously minimizing the risk. In addition, our model is characterized by short selling, which consists in the sale of non-owned financial instruments with subsequent repurchase, and transfer of securities. We propose an Integer Nonlinear Programming (INLP) Problem, whose solution provides us with the optimal distribution of securities to be purchased and sold.