Skip to content

Commit

Permalink
removed seasonal arima model predictions as it's very processor inten…
Browse files Browse the repository at this point in the history
…sive and not needed
  • Loading branch information
whittlem committed Aug 11, 2023
1 parent 03004f4 commit 47f033e
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 155 deletions.
3 changes: 0 additions & 3 deletions config.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"trailingbuypcnt": 0.5,
"telegramtradesonly": 0,
"granularity": "1hour",
"enableml": 0,
"use_sell_fee": 1
}
},
Expand Down Expand Up @@ -73,7 +72,6 @@
"trailingbuypcnt": 0.5,
"telegramtradesonly": 0,
"granularity": "3600",
"enableml": 0
}
},
"coinbasepro": {
Expand Down Expand Up @@ -111,7 +109,6 @@
"trailingbuypcnt": 0.5,
"telegramtradesonly": 0,
"granularity": "3600",
"enableml": 0
}
},
"telegram": {
Expand Down
20 changes: 0 additions & 20 deletions controllers/PyCryptoBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,17 +910,6 @@ def _notify(notification: str = "", level: str = "normal") -> None:
self.console_log.print(self.table_console)
self.table_console = Table(title=None, box=None, show_header=False, show_footer=False) # clear table

if self.enableml:
# Seasonal Autoregressive Integrated Moving Average (ARIMA) model (ML prediction for 3 intervals from now)
if not self.is_sim:
try:
prediction = _technical_analysis.arima_model_prediction(int(self.granularity.to_integer / 60) * 3) # 3 intervals from now
_notify(
f"Seasonal ARIMA model predicts the closing self.price will be {str(round(prediction[1], 2))} at {prediction[0]} (delta: {round(prediction[1] - self.price, 2)})"
)
except Exception:
pass

if self.state.last_action == "BUY":
# display support, resistance and fibonacci levels
if not self.is_sim:
Expand Down Expand Up @@ -2304,15 +2293,6 @@ def config_option_row_enum(
default_value=False,
arg_name="manualtradesonly",
)
config_option_row_bool(
"AI/ML Predictions",
"enableml",
"Enable AI / Machine Learning Predictions",
break_below=False,
store_invert=False,
default_value=False,
arg_name="predictions",
)
config_option_row_str(
"Start Method",
"startmethod",
Expand Down
1 change: 0 additions & 1 deletion examples/create-graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
# tradinggraphs.render_fibonacci_retracement(True)
# tradinggraphs.render_support_resistance(True)
# tradinggraphs.render_candle_sticks(30, True)
# tradinggraphs.render_arima_model_prediction(1, True)
tradinggraphs.render_bollinger_bands()
2 changes: 0 additions & 2 deletions models/BotConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def __init__(self, *args, **kwargs):
self.disabletelegram = False
self.disablelog = False
self.disabletracker = True
self.enableml = False
self.websocket = False
self.exitaftersell = False
self.ignorepreviousbuy = True
Expand Down Expand Up @@ -424,7 +423,6 @@ def _parse_arguments(self):
parser.add_argument("--insufficientfundslogging", type=int, help="Enable insufficient funds logging")
parser.add_argument("--logbuysellinjson", type=int, help="Log buy and sell orders in a JSON file")
parser.add_argument("--manualtradesonly", type=int, help="Manual Trading Only (HODL)")
parser.add_argument("--predictions", type=int, help="Enable AI / Machine Learning Predictions")
parser.add_argument("--startmethod", type=str, help="Bot start method ('scanner', 'standard', 'telegram')")
parser.add_argument("--recvwindow", type=int, help="Binance exchange API recvwindow, integer between 5000 and 60000")
parser.add_argument("--lastaction", type=str, help="Manually set the last action performed by the bot (BUY, SELL)")
Expand Down
1 change: 0 additions & 1 deletion models/config/default_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ def config_option_date(
config_option_bool(option_name="insufficientfundslogging", option_default=False, store_name="enableinsufficientfundslogging", store_invert=False)
config_option_bool(option_name="logbuysellinjson", option_default=False, store_name="logbuysellinjson", store_invert=False)
config_option_bool(option_name="manualtradesonly", option_default=False, store_name="manual_trades_only", store_invert=False)
config_option_bool(option_name="predictions", option_default=False, store_name="enableml", store_invert=False)
config_option_str(option_name="startmethod", option_default="standard", store_name="startmethod", valid_options=["scanner", "standard", "telegram"])
config_option_int(option_name="recvwindow", option_default=5000, store_name="recv_window", value_min=5000, value_max=60000)
config_option_str(option_name="lastaction", option_default=None, store_name="last_action", valid_options=["BUY", "SELL"])
Expand Down
4 changes: 0 additions & 4 deletions pages/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,6 @@
"label": "Disable Bot Logs",
"value": "disablelog",
},
{
"label": "Enable Machine Learning Messages",
"value": "enableml",
},
],
value=[1],
id="switches-extras",
Expand Down
96 changes: 0 additions & 96 deletions views/TradingGraphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,36 +302,6 @@ def format_date(x, pos=None): # pylint: disable=unused-argument
if saveOnly is False:
plt.show()

def render_seasonal_arima_model(self, saveFile="", saveOnly=False):
"""Render the seasonal ARIMA model
Parameters
----------
saveFile : str, optional
Save the figure
saveOnly : bool
Save the figure without displaying it
"""

fittedValues = self.technical_analysis.seasonal_arima_model_fitted_values()

plt.plot(self.df["close"], label="original")
plt.plot(fittedValues, color="red", label="fitted")
plt.title("RSS: %.4f" % sum((fittedValues - self.df["close"]) ** 2))
plt.legend()
plt.ylabel("Price")
plt.xticks(rotation=90)
plt.tight_layout()

try:
if saveFile != "":
plt.savefig(saveFile)
except OSError:
raise SystemExit(f"Unable to save: {saveFile}")

if saveOnly is False:
plt.show()

def render_sma_and_macd(self, saveFile="", saveOnly=False):
"""Render the self.price, SMA20, SMA50, and SMA200
Expand Down Expand Up @@ -369,72 +339,6 @@ def render_sma_and_macd(self, saveFile="", saveOnly=False):
if saveOnly is False:
plt.show()

def render_arima_model_prediction(self, days=30, saveOnly=False):
"""Render the seasonal ARIMA model prediction
Parameters
----------
days : int
Number of days to predict
saveOnly : bool
Save the figure without displaying it
"""

# get dataframe from technical analysis object
df = self.technical_analysis.get_df()

if not isinstance(days, int):
raise TypeError("Prediction days is not numeric.")

if days < 1 or days > len(df):
raise ValueError("Predication days is out of range")

# extract market and granularity from trading dataframe
market = df.iloc[0].market
granularity = df.iloc[0].granularity

results_ARIMA = self.technical_analysis.seasonal_arima_model()

df = pd.DataFrame(self.df["close"])
start_date = df.last_valid_index()
end_date = start_date + timedelta(days=days)
pred = results_ARIMA.predict(start=str(start_date), end=str(end_date), dynamic=True)

fig, axes = plt.subplots(ncols=1, figsize=(12, 6)) # pylint: disable=unused-variable
fig.autofmt_xdate()
ax1 = plt.subplot(111)
ax1.set_title("Seasonal ARIMA Model Prediction")

date = pd.to_datetime(pred.index).to_pydatetime()

pred_length = len(pred)
# the evenly spaced plot indices
# indices = np.arange(pred_length) # TODO: why is this here?

def format_date(x, pos=None): # pylint: disable=unused-argument
thisind = np.clip(int(x + 0.5), 0, pred_length - 1)
return date[thisind].strftime("%Y-%m-%d %H:%M:%S")

fig, ax = plt.subplots(ncols=1, figsize=(12, 6)) # pylint: disable=unused-variable
fig.autofmt_xdate()

ax = plt.subplot(111)
ax.set_title("Seasonal ARIMA Model Prediction")
ax.plot(pred, label="prediction", color="black")
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_date))

plt.xticks(rotation=90)
plt.tight_layout()

try:
RichText.notify(f"creating: graphs/SAM_{market}_{str(granularity)}.png", self.app, "info")
plt.savefig(f"graphs/SAM_{market}_{str(granularity)}.png", dpi=300)
except OSError:
raise SystemExit(f"Unable to save: graphs/SAM_{market}_{str(granularity)}.png")

if saveOnly is False:
plt.show()

def render_candle_stick_astral_pattern(self, period=30, saveOnly=False):
# get dataframe from technical analysis object
df = self.technical_analysis.get_df()
Expand Down
28 changes: 0 additions & 28 deletions websvc/app/pages/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,32 +450,6 @@ def technical_analysis(exchange: str, market: str, g1, g2, g3) -> str:
adx14_6h_class = "table-danger"
adx14_6h_desc = "Weak Trend Up"

def arima_predictions(even_rows: bool = True):
results_ARIMA = ta.seasonal_arima_model()
start_date = df_1h.last_valid_index()
end_date = start_date + datetime.timedelta(days=3)
arima_pred = results_ARIMA.predict(
start=str(start_date), end=str(end_date), dynamic=True
)

if even_rows:
arima_pred_rows = arima_pred.iloc[::2]
else:
arima_pred_rows = arima_pred.iloc[1::2]

html = ""
for index, pred in arima_pred_rows.items():
html += f"""
<tbody>
<tr class={'table-success' if pred >= ticker[1] else 'table-danger'}>
<td>{index}</td>
<td>{pred}</td>
</tr>
</tbody>
"""

return html

return f"""
{header()}
Expand Down Expand Up @@ -955,7 +929,6 @@ def arima_predictions(even_rows: bool = True):
<th scope="col" style="width: 50%">Time</th>
<th scope="col" style="width: 50%">Prediction</th>
</thead>
{arima_predictions(True)}
</table>
</div>
<div class="col-sm">
Expand All @@ -964,7 +937,6 @@ def arima_predictions(even_rows: bool = True):
<th scope="col" style="width: 50%">Time</th>
<th scope="col" style="width: 50%">Prediction</th>
</thead>
{arima_predictions(False)}
</table>
</div>
<div>
Expand Down

0 comments on commit 47f033e

Please sign in to comment.