-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.py
132 lines (112 loc) · 3.55 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import datetime
from datetime import timedelta
import numpy as np
from cadCAD.configuration.utils import ep_time_step, config_sim
#from config import *
#Internal
avg_200 = 200
avg_250 = 250
avg_300 = 300
avg_350 = 350
avg_400 = 400
ts_format = '%Y-%m-%d %H:%M:%S'
t_delta = timedelta(days=0, minutes=0, seconds=1)
def set_time(_g, step, sL, s, _input):
y = 'timestamp'
x = ep_time_step(s, dt_str=s['timestamp'], fromat_str=ts_format, _timedelta=t_delta)
return (y, x)
def random(twentieths):
'''Returns normal random variable generated by first two central moments of price change of input ticker'''
rv = np.random.randint(0,20)
if rv >= twentieths:
hit = False
else:
hit = True
return hit
def AB(_g, step, sL, s):
hit_200 = random(avg_200 / 50)
hit_250 = random(avg_250 / 50)
hit_300 = random(avg_300 / 50)
hit_350 = random(avg_350 / 50)
hit_400 = random(avg_400 / 50)
return {'player_200': hit_200, 'player_250': hit_250, 'player_300': hit_300, 'player_350': hit_350, 'player_400': hit_400, }
def AB_200(_g, step, sL, s, _input):
key = 'player_200'
value = _input['player_200']
return key, value
def AB_250(_g, step, sL, s, _input):
key = 'player_250'
value = _input['player_250']
return key, value
def AB_300(_g, step, sL, s, _input):
key = 'player_300'
value = _input['player_300']
return key, value
def AB_350(_g, step, sL, s, _input):
key = 'player_350'
value = _input['player_350']
return key, value
def AB_400(_g, step, sL, s, _input):
key = 'player_400'
value = _input['player_400']
return key, value
# State of transmitting True for any of the 4 ABs
def game_hit_200(_g, step, sL, s, _input):
key = 'game_200'
value = _input['player_200']
if step == 1:
# print(step)
return key, value
elif s['game_200'] == False:
# print('input',_input['player_200'], 'output', s['test_200'])
return key, value
else:
return key, s['game_200']
# State of transmitting True for any of the 4 ABs
def game_hit_250(_g, step, sL, s, _input):
key = 'game_250'
value = _input['player_250']
if step == 1:
# print(step)
return key, value
elif s['game_250'] == False:
# print('input',_input['player_250'], 'output', s['test_250'])
return key, value
else:
return key, s['game_250']
# State of transmitting True for any of the 4 ABs
def game_hit_300(_g, step, sL, s, _input):
key = 'game_300'
value = _input['player_300']
if step == 1:
# print(step)
return key, value
elif s['game_300'] == False:
# print('input',_input['player_300'], 'output', s['test_300'])
return key, value
else:
return key, s['game_300']
# State of transmitting True for any of the 4 ABs
def game_hit_350(_g, step, sL, s, _input):
key = 'game_350'
value = _input['player_350']
if step == 1:
# print(step)
return key, value
elif s['game_350'] == False:
# print('input',_input['player_350'], 'output', s['test_350'])
return key, value
else:
return key, s['game_350']
# State of transmitting True for any of the 4 ABs
def game_hit_400(_g, step, sL, s, _input):
key = 'game_400'
value = _input['player_400']
if step == 1:
# print(step)
return key, value
elif s['game_400'] == False:
# print('input',_input['player_400'], 'output', s['test_400'])
return key, value
else:
return key, s['game_400']