-
-
-
+
-
-
- 12233 Event
-
- Detaila mozna structured
- Lorem ipsum dolor sit amet, consectetur adipisicing elit,
- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
- quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-
-
-
-
-
-
12233 Event
-
- Detaila mozna structured
- Lorem ipsum dolor sit amet, consectetur adipisicing elit,
- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
- quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-
- Status: Not connected
+
+
+
diff --git a/v2realbot/static/js/mychart.js b/v2realbot/static/js/mychart.js
index 15ca211..b5832d0 100644
--- a/v2realbot/static/js/mychart.js
+++ b/v2realbot/static/js/mychart.js
@@ -29,7 +29,7 @@ const vwapSeries = chart.addLineSeries({
lastValueVisible: false
})
-chart.timeScale().fitContent();
+//chart.timeScale().fitContent();
//TBD dynamicky zobrazovat vsechny indikatory
//document.getElementById('chart').style.display = 'inline-block';
diff --git a/v2realbot/static/js/mytables.js b/v2realbot/static/js/mytables.js
index d9aae48..0f4818b 100644
--- a/v2realbot/static/js/mytables.js
+++ b/v2realbot/static/js/mytables.js
@@ -399,6 +399,7 @@ $("#runModal").on('submit','#runForm', function(event){
localStorage.setItem("debug", $('#debug').val());
event.preventDefault();
$('#run').attr('disabled','disabled');
+
var formData = $(this).serializeJSON();
//rename runid to id
Object.defineProperty(formData, "id", Object.getOwnPropertyDescriptor(formData, "runid"));
@@ -415,7 +416,13 @@ $("#runModal").on('submit','#runForm', function(event){
method:"PUT",
contentType: "application/json",
data: jsonString,
- success:function(data){
+ success:function(data){
+ //pokud mame subscribnuto na RT
+ if ($('#subscribe').prop('checked')) {
+ //subscribe input value gets id of current runner
+ $('#runnerId').val($('#runid').val());
+ $( "#bt-conn" ).trigger( "click" );
+ }
$('#runForm')[0].reset();
window.$('#runModal').modal('hide');
$('#run').attr('disabled', false);
diff --git a/v2realbot/static/js/mywebsocket.js b/v2realbot/static/js/mywebsocket.js
index 1977473..e591f73 100644
--- a/v2realbot/static/js/mywebsocket.js
+++ b/v2realbot/static/js/mywebsocket.js
@@ -2,8 +2,11 @@ const momentumIndicatorNames = ["roc", "slope"]
var indList = []
var pbiList = []
var ws = null;
+var logcnt = 0
var positionsPriceLine = null
var limitkaPriceLine = null
+var angleSeries = 1
+
function connect(event) {
var runnerId = document.getElementById("runnerId")
try {
@@ -21,7 +24,7 @@ function connect(event) {
ws.onmessage = function(event) {
var parsed_data = JSON.parse(event.data)
- console.log(JSON.stringify(parsed_data))
+ //console.log(JSON.stringify(parsed_data))
//check received data and display lines
if (parsed_data.hasOwnProperty("bars")) {
@@ -38,6 +41,7 @@ function connect(event) {
}
if (parsed_data.hasOwnProperty("bars")) {
+ console.log("mame bary")
var bar = parsed_data.bars
candlestickSeries.update(bar);
volumeSeries.update({
@@ -53,7 +57,7 @@ function connect(event) {
//loglist
if (parsed_data.hasOwnProperty("iter_log")) {
iterLogList = parsed_data.iter_log
- console.log("Incoming logline object")
+ //console.log("Incoming logline object")
var lines = document.getElementById('lines')
var line = document.createElement('div')
@@ -63,21 +67,38 @@ function connect(event) {
lines.appendChild(line)
iterLogList.forEach((logLine) => {
- console.log("logline item")
- console.log(JSON.stringify(logLine,null,2))
- row = logLine.time + " " + logLine.event + ":" + logLine.message;
+ //console.log("logline item")
+ //console.log(JSON.stringify(logLine,null,2))
+
+ // '
+
var lines = document.getElementById('lines')
var line = document.createElement('div')
line.classList.add("line")
- //const newLine = document.createTextNode(row)
+
line.insertAdjacentHTML( 'beforeend', row );
+ line.insertAdjacentHTML( 'beforeend', row_detail );
//line.appendChild(newLine)
- var pre = document.createElement("span")
- pre.classList.add("pidi")
- const stLine = document.createTextNode(str_row)
- pre.appendChild(stLine)
- line.appendChild(pre)
+ //var pre = document.createElement("span")
+ //pre.classList.add("pidi")
+ //const stLine = document.createTextNode(str_row)
+ //pre.appendChild(stLine)
+ //line.appendChild(pre)
lines.appendChild(line)
});
$('#messages').animate({
@@ -100,7 +121,7 @@ function connect(event) {
candlestickSeries.removePriceLine(limitkaPriceLine)
}
limitkaPriceLine = candlestickSeries.createPriceLine(limitkaLine);
- }
+ }
if (parsed_data.hasOwnProperty("pendingbuys")) {
@@ -108,7 +129,7 @@ function connect(event) {
//vymazeme vsechny predchozi instance pendingbuys
if (pbiList.length) {
- console.log(pbiList)
+ //console.log(pbiList)
pbiList.forEach((line) => {
candlestickSeries.removePriceLine(line)
});
@@ -116,9 +137,9 @@ function connect(event) {
}
//zobrazime pendingbuys a ulozime instance do pole
- console.log("pred loopem")
+ //console.log("pred loopem")
for (const [orderid, price] of Object.entries(pendingbuys)) {
- console.log("v loopu", price)
+ //console.log("v loopu", price)
const pbLine = {
price: parseFloat(price),
color: "#e3a059",
@@ -149,52 +170,99 @@ function connect(event) {
candlestickSeries.removePriceLine(positionsPriceLine)
}
positionsPriceLine = candlestickSeries.createPriceLine(posLine);
- }
+ }
+
+ if (parsed_data.hasOwnProperty("statinds")) {
+ console.log("got static indicators")
+ var statinds = parsed_data.statinds
+ if (Object.keys(statinds).length > 0) {
+ console.log("got static indicators")
+ console.log(JSON.stringify(statinds))
+
+ for (const [klic, hodnota] of Object.entries(statinds)) {
+ console.log(JSON.stringify(klic))
+ console.log(JSON.stringify(hodnota))
+
+ if (klic === "angle") {
+
+ //nejsou vsechny hodnoty
+ if (Object.keys(hodnota).length > 0) {
+ console.log("angle nalezen");
+ console.log(JSON.stringify(hodnota));
+ if (angleSeries !== 1) {
+ console.log("angle neni jedna" + toString(angleSeries))
+ chart.removeSeries(angleSeries)
+ }
+
+ angleSeries = chart.addLineSeries({
+ //title: key,
+ lineWidth: 2,
+ lineStyle: 2,
+ color: "#d432e6",
+ lastValueVisible: false,
+ priceLineVisible: false
+ })
+ dataPoints = [{time: hodnota.lookbacktime, value: hodnota.lookbackprice},{ time: hodnota.time, value: hodnota.price}]
+ console.log("pridano")
+ console.log(toString(dataPoints))
+ angleSeries.setData(dataPoints)
+ }
+ }
+ }
+
+
+
+
+
+
+
+
+
+ }
+ }
if (parsed_data.hasOwnProperty("indicators")) {
+ console.log("jsme uvnitr indikatoru")
var indicators = parsed_data.indicators
//if there are indicators it means there must be at least two keys (except time which is always present)
if (Object.keys(indicators).length > 1) {
for (const [key, value] of Object.entries(indicators)) {
if (key !== "time") {
- //if indicator exists in array, initialize it and store reference to array
+ //if indicator doesnt exists in array, initialize it and store reference to array
const searchObject= indList.find((obj) => obj.name==key);
if (searchObject == undefined) {
- console.log("object new - init and add")
+ //console.log("object new - init and add")
var obj = {name: key, series: null}
if (momentumIndicatorNames.includes(key)) {
obj.series = chart.addLineSeries({
priceScaleId: 'left',
title: key,
- lineWidth: 1,
- })
+ lineWidth: 1
+ });
}
else {
obj.series = chart.addLineSeries({
//title: key,
lineWidth: 1,
lastValueVisible: false
- })
+ });
}
obj.series.update({
time: indicators.time,
value: value});
- indList.push(obj)
+ indList.push(obj);
}
- //indicator exists in an array, let update it
+ //indicator exists in an array, lets update it
else {
- console.log("object found - update")
+ //console.log("object found - update")
searchObject.series.update({
time: indicators.time,
value: value
});
}
}
-
- console.log(`${key}: ${value}`);
}
}
- //chart.timeScale().fitContent();
}
}
ws.onclose = function(event) {
diff --git a/v2realbot/static/main.css b/v2realbot/static/main.css
index 0f61487..68843f6 100644
--- a/v2realbot/static/main.css
+++ b/v2realbot/static/main.css
@@ -61,6 +61,6 @@ pre {
}
.pidi {
- display: block;
+ /* display: block; */
font-size: smaller;
}
\ No newline at end of file
diff --git a/v2realbot/strategy/StrategyOrderLimitVykladaci.py b/v2realbot/strategy/StrategyOrderLimitVykladaci.py
index e8b6613..49ede6a 100644
--- a/v2realbot/strategy/StrategyOrderLimitVykladaci.py
+++ b/v2realbot/strategy/StrategyOrderLimitVykladaci.py
@@ -18,12 +18,12 @@ class StrategyOrderLimitVykladaci(Strategy):
async def orderUpdateBuy(self, data: TradeUpdate):
o: Order = data.order
- self.state.ilog(e="NOT:BUY_NOT_INCOMING", status=o.status, orderid=str(o.id))
+ self.state.ilog(e="Příchozí BUY notifikace", msg="order status:"+o.status, status=o.status, orderid=str(o.id))
if o.status == OrderStatus.FILLED or o.status == OrderStatus.CANCELED:
#pokud existuje objednavka v pendingbuys - vyhodime ji
if self.state.vars.pendingbuys.pop(str(o.id), False):
- self.state.ilog(e="NOT:BUY_NOT_DELETE_PB", msg="mazeme z pendingu", orderid=str(o.id), pb=self.state.vars.pendingbuys)
+ self.state.ilog(e="Příchozí BUY notifikace - mazeme ji z pb", msg="order status:"+o.status, orderid=str(o.id), pb=self.state.vars.pendingbuys)
print("limit buy filled or cancelled. Vyhazujeme z pendingbuys.")
ic(self.state.vars.pendingbuys)
@@ -37,7 +37,7 @@ class StrategyOrderLimitVykladaci(Strategy):
price=price2dec(float(o.filled_avg_price)+self.state.vars.profit)
self.state.vars.limitka = await self.interface.sell_l(price=price, size=o.filled_qty)
self.state.vars.limitka_price = price
- self.state.ilog(e="NOT:BUY_NOT_LIMITKA_CREATE", msg="limitka neni vytvarime", orderid=str(o.id), limitka=str(self.state.vars.limitka), limtka_price=self.state.vars.limitka_price)
+ self.state.ilog(e="Příchozí BUY notif - vytvarime limitku", msg="order status:"+o.status, orderid=str(o.id), limitka=str(self.state.vars.limitka), limtka_price=self.state.vars.limitka_price)
else:
#avgp, pos
self.state.avgp, self.state.positions = self.state.interface.pos()
@@ -46,9 +46,9 @@ class StrategyOrderLimitVykladaci(Strategy):
puvodni = self.state.vars.limitka
self.state.vars.limitka = await self.interface.repl(price=cena,orderid=self.state.vars.limitka,size=int(self.state.positions))
self.state.vars.limitka_price = cena
- self.state.ilog(e="NOT:BUY_NOT_LIMITKA_REPLACE", msg="limitka existuje-replace", orderid=str(o.id), limitka=str(self.state.vars.limitka), limtka_price=self.state.vars.limitka_price, puvodni_limitka=str(puvodni))
+ self.state.ilog(e="Příchozí BUY notif - menime limitku", msg="order status:"+o.status, orderid=str(o.id), limitka=str(self.state.vars.limitka), limtka_price=self.state.vars.limitka_price, puvodni_limitka=str(puvodni))
except APIError as e:
- self.state.ilog(e="NOT:BUY_NOT_LIMITKA_REPLACE_ERROR", msg=str(e), orderid=str(o.id), limitka=str(self.state.vars.limitka), limitka_price=self.state.vars.limitka_price, puvodni_limitka=str(puvodni))
+ self.state.ilog(e="API ERROR pri zmene limitky", msg=str(e), orderid=str(o.id), limitka=str(self.state.vars.limitka), limitka_price=self.state.vars.limitka_price, puvodni_limitka=str(puvodni))
#stejne parametry - stava se pri rychle obratce, nevadi
if e.code == 42210000: return 0,0
@@ -58,7 +58,7 @@ class StrategyOrderLimitVykladaci(Strategy):
async def orderUpdateSell(self, data: TradeUpdate):
if data.event == TradeEvent.PARTIAL_FILL:
- self.state.ilog(e="NOT:SELL_PARTIAL_FILL", msg="pouze update pozic", orderid=str(data.order.id))
+ self.state.ilog(e="SELL notifikace - Partial fill", msg="pouze update pozic", orderid=str(data.order.id))
ic("partial fill jen udpatujeme pozice")
self.state.avgp, self.state.positions = self.interface.pos()
elif data.event == TradeEvent.FILL or data.event == TradeEvent.CANCELED:
@@ -74,7 +74,7 @@ class StrategyOrderLimitVykladaci(Strategy):
self.state.vars.lastbuyindex = -5
self.state.vars.jevylozeno = 0
await self.state.cancel_pending_buys()
- self.state.ilog(e="NOT:SELL_FILL_OR_CANCEL", msg="mazeme limitku a pb", orderid=str(data.order.id), pb=self.state.vars.pendingbuys)
+ self.state.ilog(e="Příchozí SELL - FILL nebo CANCEL - mazeme limitku a pb", msg="order status:"+ data.order.status, orderid=str(data.order.id), pb=self.state.vars.pendingbuys)
#this parent method is called by strategy just once before waiting for first data
def strat_init(self):
@@ -89,7 +89,7 @@ class StrategyOrderLimitVykladaci(Strategy):
def buy(self, size = None, repeat: bool = False):
print("overriden method to size&check maximum ")
if int(self.state.positions) >= self.state.vars.maxpozic:
- self.state.ilog(e="BUY_REQ_MAX_POS_REACHED", msg="Pozadavek na buy, max pozic", curr_positions=self.state.positions)
+ self.state.ilog(e="buy Maxim mnozstvi naplneno", curr_positions=self.state.positions)
print("max mnostvi naplneno")
return 0
if size is None:
@@ -105,13 +105,13 @@ class StrategyOrderLimitVykladaci(Strategy):
def buy_l(self, price: float = None, size = None, repeat: bool = False):
print("entering overriden BUY")
if int(self.state.positions) >= self.state.vars.maxpozic:
- self.state.ilog(e="BUY_REQ_MAX_POS_REACHED", msg="Pozadavek na buy, max pozic", price=price, size=size, curr_positions=self.state.positions)
+ self.state.ilog(e="buyl Maxim mnozstvi naplneno", price=price, size=size, curr_positions=self.state.positions)
return 0
if size is None: size=self.state.vars.chunk
if price is None: price=price2dec((self.state.interface.get_last_price(self.symbol)))
ic(price)
print("odesilame LIMIT s cenou/qty", price, size)
- self.state.ilog(e="BUY_REQ_ORDER_SENDING", msg="Pozadavek na buy, odesilame do if", price=price, size=size)
+ self.state.ilog(e="odesilame buy_l do if", price=price, size=size)
order = self.state.interface.buy_l(price=price, size=size)
print("ukladame pendingbuys")
self.state.vars.pendingbuys[str(order)]=price
@@ -119,11 +119,11 @@ class StrategyOrderLimitVykladaci(Strategy):
self.state.vars.lastbuyindex = self.state.bars['index'][-1]
ic(self.state.blockbuy)
ic(self.state.vars.lastbuyindex)
- self.state.ilog(e="BUY_REQ_ORDER_SENT", msg="Uloženo do pb", order=str(order), pb=self.state.vars.pendingbuys)
+ self.state.ilog(e="Odslano a ulozeno do pb", order=str(order), pb=self.state.vars.pendingbuys)
async def cancel_pending_buys(self):
print("cancel pending buys called.")
- self.state.ilog(e="CANCEL_ALL_PB_REQUESTED", pb=self.state.vars.pendingbuys)
+ self.state.ilog(e="Rusime pendingy", pb=self.state.vars.pendingbuys)
##proto v pendingbuys pridano str(), protoze UUIN nejde serializovat
##padalo na variable changed during iteration, pridano
if len(self.state.vars.pendingbuys)>0:
@@ -133,9 +133,9 @@ class StrategyOrderLimitVykladaci(Strategy):
#nejprve vyhodime z pendingbuys
self.state.vars.pendingbuys.pop(key, False)
res = self.interface.cancel(key)
- self.state.ilog(e="PB_CANCELLED", orderid=key, res=str(res))
+ self.state.ilog(e="Pendingy zrusen pro"+str(key), orderid=str(key), res=str(res))
print("CANCEL PENDING BUYS RETURN", res)
self.state.vars.pendingbuys={}
self.state.vars.jevylozeno = 0
print("cancel pending buys end")
- self.state.ilog(e="CANCEL_ALL_PB_FINISHED", pb=self.state.vars.pendingbuys)
+ self.state.ilog(e="Dokončeno zruseni vsech pb", pb=self.state.vars.pendingbuys)
diff --git a/v2realbot/strategy/__pycache__/StrategyOrderLimitVykladaci.cpython-310.pyc b/v2realbot/strategy/__pycache__/StrategyOrderLimitVykladaci.cpython-310.pyc
index 70bd52c..b70d00a 100644
Binary files a/v2realbot/strategy/__pycache__/StrategyOrderLimitVykladaci.cpython-310.pyc and b/v2realbot/strategy/__pycache__/StrategyOrderLimitVykladaci.cpython-310.pyc differ
diff --git a/v2realbot/strategy/__pycache__/base.cpython-310.pyc b/v2realbot/strategy/__pycache__/base.cpython-310.pyc
index bbca36c..78550ae 100644
Binary files a/v2realbot/strategy/__pycache__/base.cpython-310.pyc and b/v2realbot/strategy/__pycache__/base.cpython-310.pyc differ
diff --git a/v2realbot/strategy/base.py b/v2realbot/strategy/base.py
index 782948c..85e51cd 100644
--- a/v2realbot/strategy/base.py
+++ b/v2realbot/strategy/base.py
@@ -338,9 +338,16 @@ class Strategy:
#odchyceny pripad, kdy indikatory jsou inicializovane, ale jeste v nich nejsou data, pak do WS nic neposilame
try:
rt_out["indicators"][key]= value[-1]
+ #zatim takto odchycene identifikatory, ktere nemaji list, ale dict - do budoucna predelat na samostatny typ "indicators_static"
except IndexError:
pass
-
+
+ #same for static indicators
+ if len(self.state.statinds) > 0:
+ rt_out["statinds"] = dict()
+ for key, value in self.state.statinds.items():
+ rt_out["statinds"][key] = value
+
#vkladame average price and positions, pokud existuji
#self.state.avgp , self.state.positions
rt_out["positions"] = dict(time=self.state.time, positions=self.state.positions, avgp=self.state.avgp)
@@ -363,8 +370,9 @@ class Strategy:
print("RTQUEUE INSERT")
#send current values to Realtime display on frontend
#all datetime values are converted to timestamp
- self.rtqueue.put(json.dumps(rt_out, default=json_serial))
- print("RTQUEUE", self.rtqueue)
+ if self.rtqueue is not None:
+ self.rtqueue.put(json.dumps(rt_out, default=json_serial))
+ print("RTQUEUE", self.rtqueue)
#cleaning iterlog lsit
#TODO pridat cistku i mimo RT blok
@@ -466,6 +474,7 @@ class StrategyState:
self.bars = AttributeDict(bars)
self.trades = AttributeDict(trades)
self.indicators = AttributeDict(time=[])
+ self.statinds = AttributeDict()
#these methods can be overrided by StrategyType (to add or alter its functionality)
self.buy = self.interface.buy
self.buy_l = self.interface.buy_l
diff --git a/v2realbot/utils/__pycache__/utils.cpython-310.pyc b/v2realbot/utils/__pycache__/utils.cpython-310.pyc
index b6375bb..4042b81 100644
Binary files a/v2realbot/utils/__pycache__/utils.cpython-310.pyc and b/v2realbot/utils/__pycache__/utils.cpython-310.pyc differ
diff --git a/v2realbot/utils/utils.py b/v2realbot/utils/utils.py
index d8684fa..25ff9f6 100644
--- a/v2realbot/utils/utils.py
+++ b/v2realbot/utils/utils.py
@@ -15,6 +15,7 @@ from typing import List
import tomli
from v2realbot.config import DATA_DIR
import requests
+from uuid import UUID
def send_to_telegram(message):
apiToken = '5836666362:AAGPuzwp03tczMQTwTBiHW6VsZZ-1RCMAEE'
@@ -35,7 +36,9 @@ def json_serial(obj):
if isinstance(obj, (datetime, date)):
return obj.timestamp()
- raise TypeError ("Type %s not serializable" % type(obj))
+ if isinstance(obj, UUID):
+ return str(obj)
+ raise TypeError (str(obj)+"Type %s not serializable" % type(obj))
def parse_toml_string(tomlst: str):
try:
+ //
+
+
+ logcnt++;
+ row = '12233 Event
+ //
+ // Detaila mozna structured
+ // Lorem ipsum dolor sit amet, consectetur adipisicing elit,
+ // sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
+ // quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ //
+ // '+logLine.time + " " + logLine.event + ' - '+ logLine.message+'
'
str_row = JSON.stringify(logLine.details, null, 2)
+
+ row_detail = '' + str_row + '