diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-07-31 00:36:05 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-07-31 00:36:05 +0200 |
commit | 51bc7cdec15d093272c259e793a9c691775b5194 (patch) | |
tree | ae9a5f321daa052441b06af7ce5231be2dae4900 /portfolio.py | |
parent | 84c9fe338676667b15f1c2601ae23ef945b36db7 (diff) | |
download | Trader-51bc7cdec15d093272c259e793a9c691775b5194.tar.gz Trader-51bc7cdec15d093272c259e793a9c691775b5194.tar.zst Trader-51bc7cdec15d093272c259e793a9c691775b5194.zip |
Eat several positions in the order book after some time spent
Diffstat (limited to 'portfolio.py')
-rw-r--r-- | portfolio.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/portfolio.py b/portfolio.py index bed4326..94472a3 100644 --- a/portfolio.py +++ b/portfolio.py | |||
@@ -4,6 +4,10 @@ from decimal import Decimal as D, ROUND_DOWN | |||
4 | from ccxt import ExchangeError, InsufficientFunds, ExchangeNotAvailable, InvalidOrder, OrderNotCached, OrderNotFound, RequestTimeout, InvalidNonce | 4 | from ccxt import ExchangeError, InsufficientFunds, ExchangeNotAvailable, InvalidOrder, OrderNotCached, OrderNotFound, RequestTimeout, InvalidNonce |
5 | 5 | ||
6 | class Computation: | 6 | class Computation: |
7 | @staticmethod | ||
8 | def eat_several(market): | ||
9 | return lambda x, y: market.ccxt.fetch_nth_order_book(x["symbol"], y, 15) | ||
10 | |||
7 | computations = { | 11 | computations = { |
8 | "default": lambda x, y: x[y], | 12 | "default": lambda x, y: x[y], |
9 | "average": lambda x, y: x["average"], | 13 | "average": lambda x, y: x["average"], |
@@ -288,8 +292,12 @@ class Trade: | |||
288 | if tick in self.tick_actions: | 292 | if tick in self.tick_actions: |
289 | update, compute_value = self.tick_actions[tick] | 293 | update, compute_value = self.tick_actions[tick] |
290 | elif tick % 3 == 1: | 294 | elif tick % 3 == 1: |
291 | update = "market_adjust" | 295 | if tick < 20: |
292 | compute_value = "default" | 296 | update = "market_adjust" |
297 | compute_value = "default" | ||
298 | else: | ||
299 | update = "market_adjust_eat" | ||
300 | compute_value = Computation.eat_several(self.market) | ||
293 | else: | 301 | else: |
294 | update = "waiting" | 302 | update = "waiting" |
295 | compute_value = None | 303 | compute_value = None |