Skip to content

Instantly share code, notes, and snippets.

@discosultan
Created November 18, 2018 13:28
Show Gist options
  • Save discosultan/c7cd9c0d8c1a17009c0b8dc42d5efe7b to your computer and use it in GitHub Desktop.
Save discosultan/c7cd9c0d8c1a17009c0b8dc42d5efe7b to your computer and use it in GitHub Desktop.
import sys
inputs = [
[ # High.
94.1875, 94.5000, 93.5000, 92.7500, 92.8750, 90.7500, 89.8750, 89.1250, 90.4375,
90.0000, 88.5000, 87.7500, 87.0625, 85.8125, 86.5625, 90.3750, 91.3750, 92.2500,
93.3750, 92.0625, 92.8750, 93.9375, 95.2500, 97.1250, 97.1875, 94.8750, 94.3125,
93.3125, 94.1250, 96.9375, 101.125, 108.750, 115.000, 117.125, 115.000, 116.625,
118.000, 119.250, 119.250, 118.812, 118.375, 119.938, 117.750, 118.625, 117.125,
116.375, 113.875, 112.250, 113.688, 114.250
],
[ # Low.
92.1250, 91.9375, 91.5000, 90.3125, 90.5000, 84.3750, 86.4375, 86.4375, 88.2500,
87.0625, 86.9375, 85.8750, 85.0000, 84.5000, 84.3750, 88.4375, 88.3750, 89.5000,
91.0000, 89.5000, 89.5625, 90.8750, 92.8750, 95.7344, 94.7500, 92.8750, 91.6875,
91.4375, 92.2500, 92.7500, 95.3125, 98.5000, 108.938, 113.625, 111.188, 110.625,
115.125, 116.750, 116.125, 117.062, 116.812, 117.125, 116.250, 112.000, 112.250,
109.375, 108.375, 107.312, 111.375, 108.688
],
[ # Close.
92.3750, 92.5625, 92.0000, 91.7500, 91.5625, 89.9375, 88.8750, 87.1250, 89.6250,
89.1875, 87.0000, 87.3125, 85.0000, 84.9375, 86.0000, 89.8125, 89.6250, 91.6875,
91.1250, 90.1875, 91.0469, 93.1875, 94.8125, 96.1250, 95.4375, 93.0000, 91.7500,
92.7500, 93.8750, 96.6250, 98.6875, 108.438, 113.688, 115.250, 112.750, 115.875,
117.562, 117.438, 119.125, 117.500, 117.938, 117.625, 116.750, 116.562, 112.625,
113.812, 110.000, 111.438, 112.250, 109.375
]
]
# Value 29.5118 was corrected to 29.5117.
outputs = [[18.4798, 17.7329, 16.6402, 16.4608, 17.5570, 19.9758, 22.9245, 25.8535, 27.6536,
29.5117, 31.3907, 33.2726, 34.7625, 36.1460, 37.3151, 38.6246, 39.4151, 38.3660,
37.3919, 35.4565, 33.3321, 31.0167, 29.3056, 27.5566]]
digits = 7
def transform(inputs, outputs, digits):
# Prefix outputs with Nones for when no values are available yet.
len_in = len(inputs[0])
len_out = len(outputs[0])
diff = len_in - len_out
for i in range(0, len(outputs)):
outputs[i] = [None] * diff + outputs[i]
# Merge inputs and outputs.
for output in outputs:
inputs.append(output)
# Zip that shit.
result = list(zip(*inputs))
print('[')
for i, res in enumerate(result):
sys.stdout.write(' (')
for j, val in enumerate(res):
val = str(val)
sys.stdout.write(val)
if val != 'None':
diff = digits - len(val)
if diff > 0:
sys.stdout.write('0' * diff)
if j != len(res) - 1:
sys.stdout.write(', ')
sys.stdout.write(')')
if i != len(result) - 1:
sys.stdout.write(',')
sys.stdout.write('\n')
sys.stdout.flush()
print(']', end='')
transform(inputs, outputs, digits)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment