The atomic structure of Pd40Ni40P20 bulk metallic glass has been simulated using an ab initio molecular dynamics method with projector-augmented wave pseudopotentials for electron-ion interaction and generalized gradient approximation for exchange-correlation energy. The calculated extended x-ray absorption fine structure (EXAFS) spectra of Pd-K and Ni-K edges, the mass density and the electronic structure agree remarkably well with the available experimental data and the EXAFS spectra measured at the SPring-8 synchrotron radiation facility. Our results show that the atomic structure can be described in terms of P-centered polyhedra. There are no two P atoms that are nearest neighbors at this composition and this could be a reason for the observed optimal P concentration of about 20 at.%. The neighboring polyhedra share metal (M) atoms and form a polar covalently bonded random network of P-M-P favoring certain angles. The remaining M atoms act as metallic glue with a tendency of nanoscale clustering of Pd-Pd and Ni-Ni atoms. {\textcopyright} 2011 American Physical Society.