X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=blobdiff_plain;f=portfolio.py;fp=portfolio.py;h=94472a3636de776d0724c6484fd7dbd85c406566;hp=bed43261d70d127c1e4aca08b5b3baf9e9bbdfef;hb=51bc7cdec15d093272c259e793a9c691775b5194;hpb=84c9fe338676667b15f1c2601ae23ef945b36db7 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 from ccxt import ExchangeError, InsufficientFunds, ExchangeNotAvailable, InvalidOrder, OrderNotCached, OrderNotFound, RequestTimeout, InvalidNonce class Computation: + @staticmethod + def eat_several(market): + return lambda x, y: market.ccxt.fetch_nth_order_book(x["symbol"], y, 15) + computations = { "default": lambda x, y: x[y], "average": lambda x, y: x["average"], @@ -288,8 +292,12 @@ class Trade: if tick in self.tick_actions: update, compute_value = self.tick_actions[tick] elif tick % 3 == 1: - update = "market_adjust" - compute_value = "default" + if tick < 20: + update = "market_adjust" + compute_value = "default" + else: + update = "market_adjust_eat" + compute_value = Computation.eat_several(self.market) else: update = "waiting" compute_value = None