  KCoO2 has been found in 1975 to exist in a unique structure with P4/nmm
spacegroup with Co in a square pyramidal coordination with the Co atoms in the
plane linked by O in a square arrangement reminiscent of the cuprates but its
electronic structure has not been studied until now. Unlike Co atoms in LiCoO2
and NaCoO2 in octahedral coordination, which are non-magnetic band structure
insulators, the unusual coordination of d6 Co^{3+} in KCoO2 is here shown to
lead to a magnetic stabilization of an insulating structure with high magnetic
moments of 4{\mu}B per Co. The electronic band structure is calculated using
the quasiparticle self-consistent (QS)GW method and the basic formation of
magnetic moments is explained in terms of the orbital decomposition of the
bands. The optical dielectric function is calculated using the Bethe-Salpeter
equation including only transitions between equal spin bands. The magnetic
moments are shown to prefer an antiferromagnetic ordering along the [110]
direction. Exchange interactions are calculated from the transverse spin
susceptibility and a rigid spin approximation. The N\'eel temperature is
estimated using the mean-field and Tyablikov methods and found to be between
approximately 100 and 250 K. The band structure in the AFM ordering can be
related to the FM ordering by band folding effects. The optical spectra are
similar in both structures and show evidence of excitonic features below the
quasiparticle gap of about 4 eV.
