quiet mode support ready2live
This commit is contained in:
@ -4,10 +4,10 @@ from v2realbot.strategy.base import StrategyState
|
||||
from v2realbot.strategy.StrategyOrderLimitVykladaci import StrategyOrderLimitVykladaci
|
||||
from v2realbot.enums.enums import RecordType, StartBarAlign, Mode, Account, OrderSide
|
||||
from v2realbot.indicators.indicators import ema
|
||||
from v2realbot.utils.utils import ltp, isrising, isfalling,trunc,AttributeDict, zoneNY, price2dec, dict_replace_value
|
||||
from v2realbot.utils.utils import ltp, isrising, isfalling,trunc,AttributeDict, zoneNY, price2dec, dict_replace_value, print
|
||||
from datetime import datetime
|
||||
from icecream import install, ic
|
||||
from rich import print
|
||||
#from rich import print
|
||||
from threading import Event
|
||||
from msgpack import packb, unpackb
|
||||
import asyncio
|
||||
@ -119,7 +119,7 @@ def next(data, state: StrategyState):
|
||||
qty = qty + int(state.vars.chunk)
|
||||
else:
|
||||
state.buy_l(price=price, size=qty)
|
||||
print(i,"BUY limitka - delta",curve[i]," cena:", price, "mnozstvi:", qty)
|
||||
#print(i,"BUY limitka - delta",curve[i]," cena:", price, "mnozstvi:", qty)
|
||||
qty = int(state.vars.chunk)
|
||||
last_price = price
|
||||
state.vars.blockbuy = 1
|
||||
@ -174,10 +174,10 @@ def next(data, state: StrategyState):
|
||||
slope = ((state.bars.close[-1] - lookbackprice)/lookbackprice)*100
|
||||
state.indicators.slope.append(slope)
|
||||
|
||||
state.statinds.angle = dict(time=state.bars.time[-1], price=state.bars.close[-1], lookbacktime=state.bars.time[-slope_lookback], lookbackprice=lookbackprice)
|
||||
state.statinds.angle = dict(time=state.bars.time[-1], price=state.bars.close[-1], lookbacktime=state.bars.time[-slope_lookback], lookbackprice=lookbackprice, minimum_slope=minimum_slope)
|
||||
|
||||
#state.indicators.roc.append(roc)
|
||||
print("slope", state.indicators.slope[-5:])
|
||||
#print("slope", state.indicators.slope[-5:])
|
||||
state.ilog(e="Slope "+str(slope), msg="lookback price:"+str(lookbackprice), lookbackoffset=lookback_offset, minimum_slope=minimum_slope, last_slopes=state.indicators.slope[-5:])
|
||||
else:
|
||||
state.ilog(e="Slope - not enough data", slope_lookback=slope_lookback)
|
||||
@ -200,7 +200,7 @@ def next(data, state: StrategyState):
|
||||
#print(orderlist)
|
||||
pendingbuys_new = {}
|
||||
limitka_old = state.vars.limitka
|
||||
print("Puvodni LIMITKA", limitka_old)
|
||||
#print("Puvodni LIMITKA", limitka_old)
|
||||
#zaciname s cistym stitem
|
||||
state.vars.limitka = None
|
||||
state.vars.limitka_price = None
|
||||
@ -208,7 +208,7 @@ def next(data, state: StrategyState):
|
||||
limitka_qty = 0
|
||||
for o in orderlist:
|
||||
if o.side == OrderSide.SELL:
|
||||
print("Nalezena LIMITKA")
|
||||
#print("Nalezena LIMITKA")
|
||||
limitka_found = True
|
||||
state.vars.limitka = o.id
|
||||
state.vars.limitka_price = o.limit_price
|
||||
@ -233,7 +233,7 @@ def next(data, state: StrategyState):
|
||||
#snad to nespadne, kdyztak pridat exception handling
|
||||
state.vars.limitka = asyncio.run(state.interface.repl(price=state.vars.limitka_price, orderid=state.vars.limitka, size=int(state.positions)))
|
||||
limitka_qty = int(state.positions)
|
||||
state.ilog(e="Změněna limitka", limitka=str(state.vars.limitka), limitka_price=state.vars.limitka_price)
|
||||
state.ilog(e="Změněna limitka", limitka=str(state.vars.limitka), limitka_price=state.vars.limitka_price, limitka_qty=limitka_qty)
|
||||
|
||||
if pendingbuys_new != state.vars.pendingbuys:
|
||||
state.ilog(e="Rozdilna PB prepsana", pb_new=pendingbuys_new, pb_old = state.vars.pendingbuys)
|
||||
|
||||
Binary file not shown.
@ -2,6 +2,7 @@ from alpaca.data.enums import DataFeed
|
||||
from v2realbot.enums.enums import Mode, Account
|
||||
from appdirs import user_data_dir
|
||||
|
||||
QUIET_MODE = True
|
||||
COUNT_API_REQUESTS = False
|
||||
STRATVARS_UNCHANGEABLES = ['pendingbuys', 'blockbuy', 'jevylozeno', 'limitka']
|
||||
DATA_DIR = user_data_dir("v2realbot")
|
||||
|
||||
@ -182,7 +182,7 @@ function connect(event) {
|
||||
for (const [klic, hodnota] of Object.entries(statinds)) {
|
||||
console.log(JSON.stringify(klic))
|
||||
console.log(JSON.stringify(hodnota))
|
||||
|
||||
//TODO predelat na configuracni klice vizualizacni dotahovane z backendu, ktere namapuji vybrane stratvars na typ vizualizace
|
||||
if (klic === "angle") {
|
||||
|
||||
//nejsou vsechny hodnoty
|
||||
@ -233,13 +233,35 @@ function connect(event) {
|
||||
if (searchObject == undefined) {
|
||||
//console.log("object new - init and add")
|
||||
var obj = {name: key, series: null}
|
||||
|
||||
//predelat configuracne
|
||||
//inicializace indicatoru
|
||||
//momentum
|
||||
if (momentumIndicatorNames.includes(key)) {
|
||||
|
||||
|
||||
obj.series = chart.addLineSeries({
|
||||
priceScaleId: 'left',
|
||||
title: key,
|
||||
lineWidth: 1
|
||||
});
|
||||
});
|
||||
|
||||
//natvrdo nakreslime lajnu pro min angle
|
||||
//TODO predelat na configuracne
|
||||
const minSlopeLineOptopns = {
|
||||
price: parsed_data.statinds.angle.minimum_slope,
|
||||
color: '#b67de8',
|
||||
lineWidth: 2,
|
||||
lineStyle: 2, // LineStyle.Dotted
|
||||
axisLabelVisible: true,
|
||||
title: "max:",
|
||||
};
|
||||
|
||||
const minSlopeLine = obj.series.createPriceLine(minSlopeLineOptopns);
|
||||
|
||||
|
||||
}
|
||||
//ostatni
|
||||
else {
|
||||
obj.series = chart.addLineSeries({
|
||||
//title: key,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -2,12 +2,12 @@
|
||||
Strategy base class
|
||||
"""
|
||||
from datetime import datetime
|
||||
from v2realbot.utils.utils import AttributeDict, zoneNY, is_open_rush, is_close_rush, json_serial
|
||||
from v2realbot.utils.utils import AttributeDict, zoneNY, is_open_rush, is_close_rush, json_serial, print
|
||||
from v2realbot.utils.tlog import tlog
|
||||
from v2realbot.enums.enums import RecordType, StartBarAlign, Mode, Order, Account
|
||||
from v2realbot.config import BT_DELAYS, get_key, HEARTBEAT_TIMEOUT
|
||||
import queue
|
||||
from rich import print
|
||||
#from rich import print
|
||||
from v2realbot.loader.aggregator import TradeAggregator2Queue, TradeAggregator2List, TradeAggregator
|
||||
from v2realbot.loader.order_updates_streamer import LiveOrderUpdatesStreamer
|
||||
from v2realbot.loader.trade_offline_streamer import Trade_Offline_Streamer
|
||||
@ -39,6 +39,8 @@ class Strategy:
|
||||
self.state: StrategyState = None
|
||||
self.bt: Backtester = None
|
||||
self.debug = False
|
||||
self.debug_target_iter = 0
|
||||
self.debug_iter_cnt = 0
|
||||
#skip morning or closing rush
|
||||
self.open_rush = open_rush
|
||||
self.close_rush = close_rush
|
||||
@ -169,8 +171,18 @@ class Strategy:
|
||||
ic('time updated')
|
||||
def strat_loop(self, item):
|
||||
|
||||
##TODO do samostatne funkce
|
||||
if self.debug:
|
||||
a = input("Press key before next iteration")
|
||||
self.debug_iter_cnt += 1
|
||||
if (self.debug_iter_cnt >= self.debug_target_iter):
|
||||
try:
|
||||
cnt = int(input("Press enter for next iteration or number to skip"))
|
||||
self.debug_target_iter = self.debug_iter_cnt + cnt
|
||||
except ValueError:
|
||||
self.debug_target_iter = self.debug_iter_cnt + 1
|
||||
|
||||
|
||||
|
||||
|
||||
self.update_times(item)
|
||||
## BT - execute orders that should have been filled until this time
|
||||
|
||||
Binary file not shown.
@ -4,7 +4,7 @@ from queue import Queue
|
||||
from datetime import datetime, timezone, time, timedelta, date
|
||||
import pytz
|
||||
from dateutil import tz
|
||||
from rich import print
|
||||
from rich import print as richprint
|
||||
import decimal
|
||||
from icecream import ic
|
||||
from v2realbot.enums.enums import RecordType, Mode, StartBarAlign
|
||||
@ -13,7 +13,7 @@ import os
|
||||
from v2realbot.common.model import StrategyInstance, Runner
|
||||
from typing import List
|
||||
import tomli
|
||||
from v2realbot.config import DATA_DIR
|
||||
from v2realbot.config import DATA_DIR, QUIET_MODE
|
||||
import requests
|
||||
from uuid import UUID
|
||||
|
||||
@ -67,7 +67,11 @@ qu = Queue()
|
||||
zoneNY = tz.gettz('America/New_York')
|
||||
|
||||
def print(*args, **kwargs):
|
||||
ic(*args, **kwargs)
|
||||
if QUIET_MODE:
|
||||
pass
|
||||
else:
|
||||
#ic(*args, **kwargs)
|
||||
richprint(*args, **kwargs)
|
||||
|
||||
def price2dec(price: float) -> float:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user