Подскажите есть ли возможность доставать результаты тестовых или основных кампаний в цифровом виде?Только если вам дадут доступ в личный кабинет.
d ={'BTC': [(None, None), (1, -0.4), (3, 0.3333333333333333), (0, 0.75), (1, None)], 'ETH': [(None, None), (0, 0.5), (0, 0.3333333333333333), (0, -0.1), (2, None)]}
[dict(zip(d.keys(), v)) for v in zip(*d.values())]
[{'BTC': (None, None), 'ETH': (None, None)},
{'BTC': (1, -0.4), 'ETH': (0, 0.5)},
{'BTC': (3, 0.3333333333333333), 'ETH': (0, 0.3333333333333333)},
{'BTC': (0, 0.75), 'ETH': (0, -0.1)},
{'BTC': (1, None), 'ETH': (2, None)}]
In [1]: l1 = list(range(5))
In [2]: l2 = list(range(5, 10))
In [3]: l1
Out[3]: [0, 1, 2, 3, 4]
In [4]: l2
Out[4]: [5, 6, 7, 8, 9]
In [5]: list(zip(l1, l2[1:] + [None]))
Out[5]: [(0, 6), (1, 7), (2, 8), (3, 9), (4, None)]
In [6]: list(map(lambda x, y: (x, y), l1, l2[1:] + [None] ))
Out[6]: [(0, 6), (1, 7), (2, 8), (3, 9), (4, None)]
In [7]: def foo(x, y):
....: return '%s:::%s' % (x, y)
....:
In [8]: list(map(foo, l1, l2[1:] + [None] ))
Out[8]: ['0:::6', '1:::7', '2:::8', '3:::9', '4:::None']
def list_state(input_list):
check0 = lambda prev, now: 0 if now <= 1.5 * prev and now >= prev else None
check1 = lambda prev, nov: 1 if now >= 1.5 * prev else None
check2 = lambda prev, now: 2 if now * 1.5 >= prev and now < prev else None
check3 = lambda prev, now: 3 if now * 1.5 < prev else None
output = [None]
for index in range(len(input_list)):
if index > len(input_list)-2:
break
prev, now = input_list[index], input_list[index+1]
for condition in (check0, check1, check2, check3):
result = condition(prev, now)
if result is not None:
output.append(result)
break
return output
a = [200, 320, 405, 460]
print(list_state(a))
# [None, 1, 0, 0]
a = [200, 149, 98, 44]
print(list_state(a))
# [None, 2, 3, 3]
tickers = {'BTC': [200, 149, 98, 44], 'ETH': [200, 320, 405, 460]}
tickers_state = {}
for key, data_list in tickers.items():
tickers_state[key] = list_state(data_list)
print(tickers_state)
# {'BTC': [None, 2, 3, 3], 'ETH': [None, 1, 0, 0]}