Skip to content

Commit

Permalink
Fix strategies' symbol evaluation [#15]
Browse files Browse the repository at this point in the history
- Use the strategy's symbol instead of the bot's symbol
  • Loading branch information
math-a3k committed Dec 15, 2023
1 parent bd53f8f commit 3ed5f7c
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions base/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def is_available(cls):

@property
def time_safeguard(self):
return (timezone.now() - self.bot.symbol.last_updated).seconds > 60
return (timezone.now() - self.symbol.last_updated).seconds > 60

def local_memory_update(self):
pass
Expand Down Expand Up @@ -108,7 +108,7 @@ class ACMadness(TradingStrategy):
def __init__(self, bot, symbol=None, **kwargs):
self.bot = bot
self.symbol = symbol or self.bot.symbol
self.ac = Decimal(self.bot.symbol.others["stp"]["next_n_sum"])
self.ac = Decimal(self.symbol.others["stp"]["next_n_sum"])
#
self.microgain = self.get_param("microgain", kwargs)
self.ac_threshold = self.microgain * self.get_param(
Expand Down Expand Up @@ -155,7 +155,7 @@ def evaluate_jump(self):
if self.time_safeguard:
return False, None
symbols_with_siblings = self.get_symbols_with_siblings()
symbols = self.bot.symbol._meta.concrete_model.objects.top_symbols()
symbols = self.symbol._meta.concrete_model.objects.top_symbols()
symbols = sorted(
symbols, key=lambda s: s.others["stp"]["next_n_sum"], reverse=True
)
Expand All @@ -179,7 +179,7 @@ def evaluate_jump(self):

def get_ac(self):
if self.ac_adjusted:
return self.ac * self.bot.symbol.model_score
return self.ac * self.symbol.model_score
else:
return self.ac

Expand All @@ -191,21 +191,18 @@ def get_min_selling_threshold(self):
)

def buying_protections(self):
if (
self.outlier_protection
and self.bot.symbol.others["outliers"]["o1"]
):
if self.outlier_protection and self.symbol.others["outliers"]["o1"]:
return (
False,
"Outlier Protection - waiting for next turn...",
)
if (
self.max_var_protection > 0
and self.bot.symbol.last_variation > self.max_var_protection
and self.symbol.last_variation > self.max_var_protection
):
return (
False,
f"Max Var Protection ({self.bot.symbol.last_variation:.3f} > "
f"Max Var Protection ({self.symbol.last_variation:.3f} > "
f"{self.max_var_protection:.3f}) - waiting for next turn...",
)
if (
Expand Down Expand Up @@ -273,7 +270,7 @@ def evaluate_jump(self):
if self.use_matrix_time_res and self.time_safeguard:
return False, None
symbols_with_siblings = self.get_symbols_with_siblings()
symbols = self.bot.symbol._meta.concrete_model.objects.top_symbols()
symbols = self.symbol._meta.concrete_model.objects.top_symbols()
symbols = sorted(
symbols, key=lambda s: s.others["dc"]["upper_break"], reverse=True
)
Expand Down Expand Up @@ -392,7 +389,7 @@ def evaluate_jump(self):
if self.use_matrix_time_res and self.time_safeguard:
return False, None
symbols_with_siblings = self.get_symbols_with_siblings()
symbols = self.bot.symbol._meta.concrete_model.objects.top_symbols()
symbols = self.symbol._meta.concrete_model.objects.top_symbols()
if self.early_onset:
key = lambda s: s.others["scg"]["seo_index"]
else:
Expand Down

0 comments on commit 3ed5f7c

Please sign in to comment.