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

Commit

Permalink
added color api
Browse files Browse the repository at this point in the history
made all the plots use color api
  • Loading branch information
CelestialCrafter committed Sep 24, 2023
1 parent a02c70f commit 823a5ba
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
11 changes: 6 additions & 5 deletions plots/bollinger_bands.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
from algorithms.bollinger_bands import algorithm as boillinger_bands
import colors

def plot(prices):
upper_band, lower_band, middle_band = boillinger_bands(prices)
Expand All @@ -11,14 +12,14 @@ def plot(prices):
plt.fill_between(indicies, upper_band, lower_band, color='grey', alpha=0.3)

# Price/SMA
plt.plot(indicies, sliced_prices, color='plum')
plt.plot(indicies, middle_band, color='mediumpurple')
plt.plot(indicies, sliced_prices, color=colors.mainline())
plt.plot(indicies, middle_band, color=colors.secondaryline())

# Buy/Sell Signals
upper_condition = sliced_prices >= upper_band
lower_condition = sliced_prices <= lower_band

plt.scatter(indicies[upper_condition], sliced_prices[upper_condition], color='lightcoral')
plt.scatter(indicies[lower_condition], sliced_prices[lower_condition], color='darkturquoise')
plt.scatter(indicies[upper_condition], sliced_prices[upper_condition], color=colors.upper())
plt.scatter(indicies[lower_condition], sliced_prices[lower_condition], color=colors.lower())

return plt
5 changes: 3 additions & 2 deletions plots/bot_net_worth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import numpy as np
import matplotlib.pyplot as plt
import colors

def plot(bot_profit):
bot_profit = np.array(bot_profit)
indicies = np.arange(0, bot_profit.shape[0]) * 5
plt.plot(indicies, bot_profit, color='lightcoral')
plt.plot(indicies, bot_profit, color=colors.upper())

return plt
return plt
14 changes: 14 additions & 0 deletions plots/colors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def mainline():
return 'plum'

def secondaryline():
return 'mediumpurple'

def upper():
return 'lightcoral'

def lower():
return 'darkturquoise'

def inner():
return 'grey'
9 changes: 5 additions & 4 deletions plots/macd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
from algorithms.macd import algorithm as macd
import colors

def plot(prices):
macd_line, signal_line = macd(prices)
Expand All @@ -9,10 +10,10 @@ def plot(prices):
upper_condition = macd_line > signal_line
lower_condition = macd_line < signal_line

plt.scatter(indicies[upper_condition], signal_line[upper_condition], color='darkturquoise')
plt.scatter(indicies[lower_condition], signal_line[lower_condition], color='lightcoral')
plt.scatter(indicies[upper_condition], signal_line[upper_condition], color=colors.lower())
plt.scatter(indicies[lower_condition], signal_line[lower_condition], color=colors.upper())

plt.plot(signal_line, color='plum')
plt.plot(macd_line, color='mediumpurple')
plt.plot(signal_line, color=colors.mainline())
plt.plot(macd_line, color=colors.secondaryline())

return plt
7 changes: 4 additions & 3 deletions plots/rsi.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import numpy as np
import matplotlib.pyplot as plt
from algorithms.rsi import algorithm as rsi
import colors

def plot(prices):
rsi_data = rsi(prices)
rsi_indicies = np.arange(0, rsi_data.shape[0])

plt.plot(rsi_indicies, rsi_data, color='plum')
plt.plot(rsi_indicies, rsi_data, color=colors.mainline())

# Thresholds
rsi_upper = np.full(rsi_data.shape, 70)
rsi_lower = np.full(rsi_data.shape, 30)

plt.fill_between(rsi_indicies, rsi_upper, rsi_lower, color='grey', alpha=0.3)
plt.plot(rsi_indicies, rsi_upper, linestyle='dashed', color='lightcoral')
plt.plot(rsi_indicies, rsi_lower, linestyle='dashed', color='darkturquoise')
plt.plot(rsi_indicies, rsi_upper, linestyle='dashed', color=colors.upper())
plt.plot(rsi_indicies, rsi_lower, linestyle='dashed', color=colors.lower())

return plt

0 comments on commit 823a5ba

Please sign in to comment.