snad ok CONS TRADES REQ support
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -219,6 +219,8 @@ class Backtester:
|
|||||||
|
|
||||||
if o.order_type == OrderType.LIMIT:
|
if o.order_type == OrderType.LIMIT:
|
||||||
if o.side == OrderSide.BUY:
|
if o.side == OrderSide.BUY:
|
||||||
|
#counter for consecutive trades
|
||||||
|
consec_cnt = 0
|
||||||
for index, i in enumerate(work_range):
|
for index, i in enumerate(work_range):
|
||||||
#print(i)
|
#print(i)
|
||||||
##najde prvni nejvetsi čas vetsi nez minfill a majici odpovídající cenu
|
##najde prvni nejvetsi čas vetsi nez minfill a majici odpovídající cenu
|
||||||
@ -242,17 +244,23 @@ class Backtester:
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
if float(i[0]) > float(order_min_fill_time+BT_DELAYS.limit_order_offset) and fill_condition:
|
if float(i[0]) > float(order_min_fill_time+BT_DELAYS.limit_order_offset) and fill_condition:
|
||||||
#(1679081919.381649, 27.88)
|
consec_cnt += 1
|
||||||
ic(i)
|
if consec_cnt == FILL_CONS_TRADES_REQUIRED:
|
||||||
fill_time = i[0]
|
|
||||||
fill_price = i[1]
|
#(1679081919.381649, 27.88)
|
||||||
print("FILL LIMIT BUY at", fill_time, datetime.fromtimestamp(fill_time).astimezone(zoneNY), "at",i[1])
|
ic(i)
|
||||||
if FILL_LOG_SURROUNDING_TRADES != 0:
|
fill_time = i[0]
|
||||||
#TODO loguru
|
fill_price = i[1]
|
||||||
print("FILL SURR TRADES: before",work_range[index-FILL_LOG_SURROUNDING_TRADES:index])
|
print("FILL LIMIT BUY at", fill_time, datetime.fromtimestamp(fill_time).astimezone(zoneNY), "at",i[1])
|
||||||
print("FILL SURR TRADES: fill and after",work_range[index:index+FILL_LOG_SURROUNDING_TRADES])
|
if FILL_LOG_SURROUNDING_TRADES != 0:
|
||||||
break
|
#TODO loguru
|
||||||
|
print("FILL SURR TRADES: before",work_range[index-FILL_LOG_SURROUNDING_TRADES:index])
|
||||||
|
print("FILL SURR TRADES: fill and after",work_range[index:index+FILL_LOG_SURROUNDING_TRADES])
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
consec_cnt = 0
|
||||||
else:
|
else:
|
||||||
|
consec_cnt = 0
|
||||||
for index, i in enumerate(work_range):
|
for index, i in enumerate(work_range):
|
||||||
#print(i)
|
#print(i)
|
||||||
#NASTVENI PODMINEK PLNENI
|
#NASTVENI PODMINEK PLNENI
|
||||||
@ -267,16 +275,20 @@ class Backtester:
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
if float(i[0]) > float(order_min_fill_time+BT_DELAYS.limit_order_offset) and fill_condition:
|
if float(i[0]) > float(order_min_fill_time+BT_DELAYS.limit_order_offset) and fill_condition:
|
||||||
#(1679081919.381649, 27.88)
|
consec_cnt += 1
|
||||||
ic(i)
|
if consec_cnt == FILL_CONS_TRADES_REQUIRED:
|
||||||
fill_time = i[0]
|
#(1679081919.381649, 27.88)
|
||||||
fill_price = i[1]
|
ic(i)
|
||||||
print("FILL LIMIT SELL at", fill_time, datetime.fromtimestamp(fill_time).astimezone(zoneNY), "at",i[1])
|
fill_time = i[0]
|
||||||
if FILL_LOG_SURROUNDING_TRADES != 0:
|
fill_price = i[1]
|
||||||
#TODO loguru
|
print("FILL LIMIT SELL at", fill_time, datetime.fromtimestamp(fill_time).astimezone(zoneNY), "at",i[1])
|
||||||
print("FILL SELL SURR TRADES: before",work_range[index-FILL_LOG_SURROUNDING_TRADES:index])
|
if FILL_LOG_SURROUNDING_TRADES != 0:
|
||||||
print("FILL SELL SURR TRADES: fill and after",work_range[index:index+FILL_LOG_SURROUNDING_TRADES])
|
#TODO loguru
|
||||||
break
|
print("FILL SELL SURR TRADES: before",work_range[index-FILL_LOG_SURROUNDING_TRADES:index])
|
||||||
|
print("FILL SELL SURR TRADES: fill and after",work_range[index:index+FILL_LOG_SURROUNDING_TRADES])
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
consec_cnt = 0
|
||||||
|
|
||||||
elif o.order_type == OrderType.MARKET:
|
elif o.order_type == OrderType.MARKET:
|
||||||
for i in work_range:
|
for i in work_range:
|
||||||
|
|||||||
@ -3,11 +3,12 @@ from v2realbot.enums.enums import Mode, Account, FillCondition
|
|||||||
from appdirs import user_data_dir
|
from appdirs import user_data_dir
|
||||||
|
|
||||||
|
|
||||||
#how many consecutive trades with the fill price are necessary for limit fill to happen()
|
#how many consecutive trades with the fill price are necessary for LIMIT fill to happen()
|
||||||
#0 - optimistic, every knot high will fill the order
|
#0 - optimistic, every knot high will fill the order
|
||||||
#N - N consecutive trades required
|
#N - N consecutive trades required
|
||||||
#not impl.yet
|
#not impl.yet
|
||||||
FILL_CONS_TRADES_REQUIRED = 0
|
#minimum is 1
|
||||||
|
FILL_CONS_TRADES_REQUIRED = 2
|
||||||
#during trade execution logs X-surrounding trades of the one that triggers the fill
|
#during trade execution logs X-surrounding trades of the one that triggers the fill
|
||||||
FILL_LOG_SURROUNDING_TRADES = 10
|
FILL_LOG_SURROUNDING_TRADES = 10
|
||||||
#fill condition for limit order
|
#fill condition for limit order
|
||||||
|
|||||||
Reference in New Issue
Block a user