This commit is contained in:
David Brazda
2023-04-24 16:13:10 +02:00
parent fcd3731441
commit a3546fe9a2
5 changed files with 12 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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):