the problem of spectra to RGB is fairly complex. There are algorithms to convert spectra to XYZ and Lab color space coordinate that depend upon observer and illuminent settings. once you have XYZ, there is another transform with approximations to get to RGB.
I have included two lookup tables for spectra to RGB using Observer=IEC 1931 and Illuminant=D50. I do not remember where the coefficients for XYZ to RGB came from. One lookup table is more saturated that the other. Maybe this is good enough for your application.
The tables cover 380 to 780 nm every 5 nm.
Stu
Stu