Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

statements update if if -> if elif #19

Merged
merged 5 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion algorithms/bollinger_bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def signal(data):
upper_band, lower_band, middle_band = data
if middle_band[-1] > upper_band[-1]:
return 'sell', 1
if middle_band[-1] < lower_band[-1]:
elif middle_band[-1] < lower_band[-1]:
return 'buy', 0.5
return 'no_action', 0
4 changes: 2 additions & 2 deletions algorithms/macd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def algorithm(prices, window_sizes=[12, 26, 9]):

def signal(data):
macd, signal = data
# @TODO make this not stupid :3
# @TODO make signals accurate to macd
if macd[-1] > signal[-1]:
return 'sell'
if macd[-1] < signal[-1]:
elif macd[-1] < signal[-1]:
return 'buy'
return 'no_action'
2 changes: 1 addition & 1 deletion algorithms/rsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def signal(data):
rsi = data
if rsi[-1] > 70:
return 'sell'
if rsi[-1] < 30:
elif rsi[-1] < 30:
return 'buy'
return 'no_action'
2 changes: 1 addition & 1 deletion plots/bollinger_bands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
from algorithms.bollinger_bands import algorithm as boillinger_bands
import colors
import plots.colors as colors

def plot(prices):
upper_band, lower_band, middle_band = boillinger_bands(prices)
Expand Down
2 changes: 1 addition & 1 deletion plots/bot_net_worth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import matplotlib.pyplot as plt
import colors
import plots.colors as colors

def plot(bot_profit):
bot_profit = np.array(bot_profit)
Expand Down
2 changes: 1 addition & 1 deletion plots/macd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
from algorithms.macd import algorithm as macd
import colors
import plots.colors as colors

def plot(prices):
macd_line, signal_line = macd(prices)
Expand Down
2 changes: 1 addition & 1 deletion plots/rsi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
from algorithms.rsi import algorithm as rsi
import colors
import plots.colors as colors

def plot(prices):
rsi_data = rsi(prices)
Expand Down
3 changes: 1 addition & 2 deletions views/bot_net_worth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def bot_net_worth(bot_id):
return 'Bad Request', 400

try:
jwt_decoded = jwt.decode(
jwt_encoded, os.environ['JWT_SECRET'], algorithms=['HS256'])
jwt_decoded = jwt.decode(jwt_encoded, os.environ['JWT_SECRET'], algorithms=['HS256'])
if jwt_decoded._id != bot_id:
raise 'Token Mismatch'
except Exception:
Expand Down
7 changes: 2 additions & 5 deletions views/internal_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def internal_checker():
return 'Bad Request', 400

try:
jwt_decoded = jwt.decode(
jwt_encoded, os.environ['JWT_SECRET'], algorithms=['HS256'])
jwt_decoded = jwt.decode(jwt_encoded, os.environ['JWT_SECRET'], algorithms=['HS256'])
except Exception as e:
print(e)
return 'Unauthorized', 401
Expand All @@ -38,9 +37,7 @@ def internal_checker():
# Convert list of algorithms into {name: signal}
algorithms = get_algorithms()

base = dict(
map(lambda x: algorithm_output(*x),
zip(algorithms, [prices] * len(algorithms))))
base = dict(map(lambda x: algorithm_output(*x), zip(algorithms, [prices] * len(algorithms))))

signals = {k: v[0] for (k, v) in base.items()}
strengths = {k: v[1] for (k, v) in base.items()}
Expand Down
Loading