bugfixes and two version of strategies
This commit is contained in:
12
testy/numpytest.py
Normal file
12
testy/numpytest.py
Normal file
@ -0,0 +1,12 @@
|
||||
import numpy as np
|
||||
from v2realbot.utils.utils import isfalling
|
||||
arr = np.array([1, np.nan, 3, 4, 5, 6, 2.3])
|
||||
print(arr)
|
||||
b = list(arr)
|
||||
a = b[-1]
|
||||
print(a)
|
||||
if str(a) == "nan":
|
||||
print(a,"je nan")
|
||||
|
||||
rsi = [1,2,3,4,5]
|
||||
print(isfalling(rsi,1))
|
||||
@ -14,7 +14,6 @@ from msgpack import packb, unpackb
|
||||
import asyncio
|
||||
import os
|
||||
from traceback import format_exc
|
||||
import inspect
|
||||
|
||||
print(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
""""
|
||||
@ -502,6 +501,8 @@ def next(data, state: StrategyState):
|
||||
source = state.cbar_indicators.tick_price #[-rsi_length:] #state.bars.vwap
|
||||
crsi_res = rsi(source, crsi_length)
|
||||
crsi_value = crsi_res[-1]
|
||||
if str(crsi_value) == "nan":
|
||||
crsi_value = 0
|
||||
state.cbar_indicators.CRSI[-1]=crsi_value
|
||||
#state.ilog(e=f"RSI {rsi_length=} {rsi_value=} {rsi_dont_buy=} {rsi_buy_signal=}", rsi_indicator=state.indicators.RSI14[-5:])
|
||||
except Exception as e:
|
||||
@ -653,11 +654,11 @@ def next(data, state: StrategyState):
|
||||
#buy_cond["AND"]["rsi_buy_signal_below"] = state.indicators.RSI14[-1] < safe_get(state.vars, "rsi_buy_signal_below",40)
|
||||
#buy_cond["AND"]["ema_trend_is_falling"] = isfalling(state.indicators.ema,state.vars.Trend)
|
||||
|
||||
#pouze RSI nizke a RSI klesa
|
||||
#pouze RSI nizke a RSI klesa, pripadne k tomu CRSI
|
||||
#TATO KOMBINACE se da konfigurovat pouze hodnotama, aby platila libovolna kombinace podminek (např. Trend = 1 - vypne stredni podminku)
|
||||
buy_cond["AND"]["rsi_buy_signal_below"] = state.indicators.RSI14[-1] < safe_get(state.vars, "rsi_buy_signal_below",40)
|
||||
buy_cond["AND"]["rsi_is_falling"] = isfalling(state.indicators.RSI14,state.vars.Trend)
|
||||
|
||||
#buy_cond['crsi_below_crsi_buy_limit'] = state.cbar_indicators.CRSI[-1] < safe_get(state.vars, "crsi_buy_signal_below",30)
|
||||
buy_cond["AND"]['crsi_below_crsi_buy_limit'] = state.cbar_indicators.CRSI[-1] < safe_get(state.vars, "crsi_buy_signal_below",25)
|
||||
|
||||
#slopME klesa a RSI začalo stoupat
|
||||
# buy_cond["AND"]["rsi_is_rising2"] = isrising(state.indicators.RSI14,2)
|
||||
@ -668,8 +669,8 @@ def next(data, state: StrategyState):
|
||||
#zkusit jako doplnkovy BUY SIGNAL 3 klesavy cbar RSI pripadne TICK PRICE
|
||||
|
||||
result, conditions_met = eval_cond_dict(buy_cond)
|
||||
if result:
|
||||
state.ilog(e=f"BUY SIGNAL {conditions_met}")
|
||||
#if result:
|
||||
state.ilog(e=f"BUY SIGNAL {result} {conditions_met}")
|
||||
return result
|
||||
|
||||
def eval_buy():
|
||||
|
||||
Binary file not shown.
@ -3,7 +3,7 @@ from v2realbot.enums.enums import Mode, Account, FillCondition
|
||||
from appdirs import user_data_dir
|
||||
|
||||
#minimalni vzdalenost mezi trady, kterou agregator pousti pro CBAR(0.001 - blokuje mensi nez 1ms)
|
||||
AGG_MIN_TRADE_DELTA = 0.003
|
||||
GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN = 0.003
|
||||
#normalized price for tick 0.01
|
||||
NORMALIZED_TICK_BASE_PRICE = 30.00
|
||||
LOG_RUNNER_EVENTS = False
|
||||
|
||||
@ -11,7 +11,7 @@ from v2realbot.utils.utils import AttributeDict, zoneNY, dict_replace_value, Sto
|
||||
from v2realbot.utils.ilog import delete_logs
|
||||
from datetime import datetime
|
||||
from threading import Thread, current_thread, Event, enumerate
|
||||
from v2realbot.config import STRATVARS_UNCHANGEABLES, ACCOUNT1_LIVE_API_KEY, ACCOUNT1_LIVE_SECRET_KEY, DATA_DIR,BT_FILL_CONS_TRADES_REQUIRED,BT_FILL_LOG_SURROUNDING_TRADES,BT_FILL_CONDITION_BUY_LIMIT,BT_FILL_CONDITION_SELL_LIMIT, AGG_MIN_TRADE_DELTA
|
||||
from v2realbot.config import STRATVARS_UNCHANGEABLES, ACCOUNT1_LIVE_API_KEY, ACCOUNT1_LIVE_SECRET_KEY, DATA_DIR,BT_FILL_CONS_TRADES_REQUIRED,BT_FILL_LOG_SURROUNDING_TRADES,BT_FILL_CONDITION_BUY_LIMIT,BT_FILL_CONDITION_SELL_LIMIT, GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN
|
||||
import importlib
|
||||
from queue import Queue
|
||||
from tinydb import TinyDB, Query, where
|
||||
@ -476,7 +476,7 @@ def archive_runner(runner: Runner, strat: StrategyInstance):
|
||||
settings = dict(resolution=strat.state.timeframe,
|
||||
rectype=strat.state.rectype,
|
||||
configs=dict(
|
||||
AGG_MIN_TRADE_DELTA=AGG_MIN_TRADE_DELTA,
|
||||
GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN=GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN,
|
||||
BT_FILL_CONS_TRADES_REQUIRED=BT_FILL_CONS_TRADES_REQUIRED,
|
||||
BT_FILL_LOG_SURROUNDING_TRADES=BT_FILL_LOG_SURROUNDING_TRADES,
|
||||
BT_FILL_CONDITION_BUY_LIMIT=BT_FILL_CONDITION_BUY_LIMIT,
|
||||
|
||||
Binary file not shown.
@ -11,7 +11,7 @@ import threading
|
||||
from copy import deepcopy
|
||||
from msgpack import unpackb
|
||||
import os
|
||||
from config import DATA_DIR, AGG_MIN_TRADE_DELTA
|
||||
from config import DATA_DIR, GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN
|
||||
|
||||
class TradeAggregator:
|
||||
def __init__(self,
|
||||
@ -245,7 +245,7 @@ class TradeAggregator:
|
||||
self.diff_price = True
|
||||
self.last_price = data['p']
|
||||
|
||||
if float(data['t']) - float(self.lasttimestamp) < AGG_MIN_TRADE_DELTA:
|
||||
if float(data['t']) - float(self.lasttimestamp) < GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN:
|
||||
self.trades_too_close = True
|
||||
else:
|
||||
self.trades_too_close = False
|
||||
@ -344,7 +344,7 @@ class TradeAggregator:
|
||||
#127788.123000 127788.124000 (rozdil 0.001)
|
||||
|
||||
|
||||
#zkousime pustit i stejnou cenu(potrebujeme kvuli MYSELLU), ale blokoval kulomet,tzn. trady mensi nez AGG_MIN_TRADE_DELTA (1ms)
|
||||
#zkousime pustit i stejnou cenu(potrebujeme kvuli MYSELLU), ale blokoval kulomet,tzn. trady mensi nez GROUP_TRADES_WITH_TIMESTAMP_LESS_THAN (1ms)
|
||||
#if self.diff_price is True:
|
||||
|
||||
#pripadne jeste vratit jako subpodminkiu
|
||||
|
||||
0
v2realbot/v2trading.db
Normal file
0
v2realbot/v2trading.db
Normal file
Reference in New Issue
Block a user