The proximate cause of the error is id
is not submitted with the form. There may be an easier way that would eliminate the code that is presumably duplicated between index and buy/sell.
The button element has an attribute formaction
that will override the action
attribute of the form attributeelement.