Schonfeld's risk dashboard receives compact arithmetic expressions for derived values. Implement a calculator that evaluates an expression containing integers, addition, subtraction, multiplication, division, parentheses, and unary plus or minus.
Multiplication and division must be evaluated before addition and subtraction. Parentheses override normal precedence. Division uses true division, so the result may be a floating-point number.
Implement calculate(expression), where expression is a string containing a valid arithmetic expression. Return its numeric result as an integer or floating-point value. Ignore whitespace. The input will not contain exponentiation, variables, malformed syntax, or division by zero.
Unary operators may appear before any number or parenthesized expression, such as -3, 2 * -4, or -(1 + 2).
def calculate(expression):