- new_order = None
- if tick in [0, 1, 3, 4, 6]:
- print("{}, tick {}, waiting".format(order, tick))
- elif tick == 2:
- self.prepare_order(compute_value=lambda x, y: (x[y] + x["average"]) / 2)
- new_order = self.orders[-1]
- print("{}, tick {}, cancelling and adjusting to {}".format(order, tick, new_order))
- elif tick ==5:
- self.prepare_order(compute_value=lambda x, y: (x[y]*2 + x["average"]) / 3)
- new_order = self.orders[-1]
- print("{}, tick {}, cancelling and adjusting to {}".format(order, tick, new_order))
- elif tick >= 7:
- if tick == 7:
- print("{}, tick {}, fallbacking to market value".format(order, tick))
- if (tick - 7) % 3 == 0:
- self.prepare_order(compute_value="default")
- new_order = self.orders[-1]
- print("{}, tick {}, market value, cancelling and adjusting to {}".format(order, tick, new_order))
+ actions = {
+ 0: ["waiting", None],
+ 1: ["waiting", None],
+ 2: ["adjusting", lambda x, y: (x[y] + x["average"]) / 2],
+ 3: ["waiting", None],
+ 4: ["waiting", None],
+ 5: ["adjusting", lambda x, y: (x[y]*2 + x["average"]) / 3],
+ 6: ["waiting", None],
+ 7: ["market_fallback", "default"],
+ }