From a3546fe9a24177af3358fae4bf7c2bdcb133405b Mon Sep 17 00:00:00 2001 From: David Brazda Date: Mon, 24 Apr 2023 16:13:10 +0200 Subject: [PATCH] bugfix --- v2realbot/ENTRY_backtest_strategyVykladaci.py | 6 +++--- v2realbot/__pycache__/config.cpython-310.pyc | Bin 2779 -> 2779 bytes v2realbot/config.py | 7 +++---- .../utils/__pycache__/utils.cpython-310.pyc | Bin 7930 -> 8049 bytes v2realbot/utils/utils.py | 7 ++++++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/v2realbot/ENTRY_backtest_strategyVykladaci.py b/v2realbot/ENTRY_backtest_strategyVykladaci.py index 4781d73..c003341 100644 --- a/v2realbot/ENTRY_backtest_strategyVykladaci.py +++ b/v2realbot/ENTRY_backtest_strategyVykladaci.py @@ -207,8 +207,8 @@ def next(data, state: StrategyState): #slope MA - cílem je identifikovat táhlá klesání, vypnout nákupy, až budou zase růsty - # slope_MA_length = 150 - # state.indicators.slopeMA = ema(state.indicators.slope, slope_MA_length) #state.bars.vwap + slope_MA_length = 5 + state.indicators.slopeMA = ema(state.indicators.slope, slope_MA_length) #state.bars.vwap # #TODO - docasne posilam cele MA # try: # state.ilog(e="Slope - MA"+str(state.indicators.slopeMA[-1]), slopeMA=str(state.indicators.slopeMA[-20:])) @@ -428,7 +428,7 @@ def init(state: StrategyState): print("INIT v main",state.name) state.indicators['ema'] = [] state.indicators['slope'] = [] - #state.indicators['slopeMA'] = [] + state.indicators['slopeMA'] = [] #static indicators - those not series based state.statinds['angle'] = {} state.vars["ticks2reset_backup"] = state.vars.ticks2reset diff --git a/v2realbot/__pycache__/config.cpython-310.pyc b/v2realbot/__pycache__/config.cpython-310.pyc index ca1a39a91ca91f390b45a9c004924eb5a319f1f7..43a4ca92073e2bde8b4052371fdff09db4690a2b 100644 GIT binary patch delta 322 zcmW-cyG{a85QcYl4|_Swa$jyLcx#M6Xbi@hWkbXO1|f`vA(_=kV`FS7pfBvlL$;i}*|-K2QRu%rYzfku&l-7<<&Y{oE2aZFJHT}on_QkWqZvy{eM z0OLGvQ3kgui#yU5D8sP0(YutxJ<8+0)CZKF|8(reT9ZB3|7{mN_yRaw9BC>*S(I2G zN{cBwQ{hB>=#|1UM5CvB!c^zn_q{>W8)CcPZPYJ^wQ36mH!9E*r-pn+yc;c>cdwdW q@8+Ui_k>|i#EV&$mrwH;mg3udl>5l~m3hs5OJh1yb*6)OnYl*0{Si^<-S0N)r^AC7{0DCSz!t=nZFvfKk?5~EC2ui diff --git a/v2realbot/config.py b/v2realbot/config.py index 6c44083..23d4f27 100644 --- a/v2realbot/config.py +++ b/v2realbot/config.py @@ -2,13 +2,14 @@ from alpaca.data.enums import DataFeed from v2realbot.enums.enums import Mode, Account, FillCondition from appdirs import user_data_dir - +#no print in console +QUIET_MODE = False #how many consecutive trades with the fill price are necessary for LIMIT fill to happen in backtesting #0 - optimistic, every knot high will fill the order #N - N consecutive trades required #not impl.yet #minimum is 1 -BT_FILL_CONS_TRADES_REQUIRED = 2 +BT_FILL_CONS_TRADES_REQUIRED = 3 #during bt trade execution logs X-surrounding trades of the one that triggers the fill BT_FILL_LOG_SURROUNDING_TRADES = 10 #fill condition for limit order in bt @@ -16,8 +17,6 @@ BT_FILL_LOG_SURROUNDING_TRADES = 10 # slow - price has to be bigger < BT_FILL_CONDITION_BUY_LIMIT = FillCondition.FAST BT_FILL_CONDITION_SELL_LIMIT = FillCondition.FAST -#no print in console -QUIET_MODE = True #backend counter of api requests COUNT_API_REQUESTS = False #stratvars that cannot be changed in gui diff --git a/v2realbot/utils/__pycache__/utils.cpython-310.pyc b/v2realbot/utils/__pycache__/utils.cpython-310.pyc index ab57a5d42fbce3905a585d904be598c7e854501a..85233dc29d6ddc0aa18fd052512eae93d5463ca1 100644 GIT binary patch delta 1789 zcmZ{kU2KzO6vzAY<89Zkm9<^lb?x|&ZCzPmU+nu61}F%~U_!l^-Ojtw(RSr&%h-Zh zWRnZPL^voPAz^+*LKLPfTo^@fjPcSKqse=LXw={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43..7424b83 100644 --- a/v2realbot/utils/utils.py +++ b/v2realbot/utils/utils.py @@ -17,7 +17,8 @@ import requests from uuid import UUID from enum import Enum #from v2realbot.enums.enums import Order -from v2realbot.common.model import Order, TradeUpdate +from v2realbot.common.model import Order as btOrder, TradeUpdate as btTradeUpdate +from alpaca.trading.models import Order, TradeUpdate def safe_get(collection, key, default=None): """Get values from a collection without raising errors""" @@ -61,6 +62,10 @@ def json_serial(obj): return obj.__dict__ if type(obj) is TradeUpdate: return obj.__dict__ + if type(obj) is btOrder: + return obj.__dict__ + if type(obj) is btTradeUpdate: + return obj.__dict__ raise TypeError (str(obj)+"Type %s not serializable" % type(obj)) def parse_toml_string(tomlst: str):