diff --git a/val_sim.py b/val_sim.py index c57c354cd8aafa839e59e64927be16f95a52fde4..5251de736e310aa76af8c5de598e6ff0839725c3 100644 --- a/val_sim.py +++ b/val_sim.py @@ -5,26 +5,22 @@ import random from statistics import mean, stdev import json import sys -import cgitb -cgitb.enable() # Read input from stdin input_data = sys.stdin.read() - -# Parse the input data as JSON -event_dict = json.loads(input_data) +event = json.loads(input_data) # Extract the values from the event dictionary -dt = json.loads(event_dict['key1']) # List of dates -close = json.loads(event_dict['key2']) # List of close prices -buy = json.loads(event_dict['key3']) # List of buy signals -sell = json.loads(event_dict['key4']) # List of sell signals -h = int(event_dict['key5']) # History length -d = int(event_dict['key6']) # Number of shots -t = event_dict['key7'] # Trade type ('buy' or 'sell') +dt = eval(event['key1']) +close = eval(event['key2']) +buy = eval(event['key3']) +sell = eval(event['key4']) +h = int(event['key5']) +d = int(event['key6']) +t = event['key7'] -minhistory = int(h) -shots = int(d) +minhistory = h +shots = d var95_list = [] var99_list = [] @@ -65,6 +61,6 @@ response = { "var99_list": var99_list } -# Print the output as a JSON string, which is how CGI scripts return data +# Output result as JSON print("Content-Type: application/json\n") print(json.dumps(response))