This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
082448f
commit 95a01a0
Showing
14 changed files
with
216 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import plots.colors as colors | ||
from matplotlib.gridspec import GridSpec | ||
from algorithms.custom_bollinger_rsi import algorithm as custom_bollinger_rsi | ||
from plots.rsi import plot as rsi | ||
from plots.bollinger_bands import plot as bollinger_bands | ||
|
||
def plot(prices, **kwargs): | ||
def plot(prices, timestamps, **kwargs): | ||
gs = GridSpec(3, 1, figure=plt.gcf()) | ||
|
||
plt.subplot(gs[0, :]) | ||
indicies = np.arange(0, prices.shape[0]) | ||
plt.plot(indicies, prices, color=colors.mainline()) | ||
plt.plot(timestamps, prices, color=colors.mainline()) | ||
|
||
upper_band, lower_band, middle_band, rsi_line = custom_bollinger_rsi(prices, **kwargs) | ||
upper_band, middle_band, lower_band, rsi_line = custom_bollinger_rsi(prices, **kwargs) | ||
sliced_prices = prices[:min(upper_band.shape[0], rsi_line.shape[0])] | ||
indicies = np.arange(0, indicies.shape[0]) | ||
|
||
upper_condition = (prices >= upper_band) & (rsi_line >= 70) | ||
lower_condition = (prices >= lower_band) & (30 >= rsi_line) | ||
plt.scatter(indicies[upper_condition], sliced_prices[upper_condition], color=colors.upper()) | ||
plt.scatter(indicies[lower_condition], sliced_prices[lower_condition], color=colors.lower()) | ||
plt.scatter(timestamps[upper_condition], sliced_prices[upper_condition], color=colors.upper()) | ||
plt.scatter(timestamps[lower_condition], sliced_prices[lower_condition], color=colors.lower()) | ||
|
||
plt.subplot(gs[-1, :]) | ||
rsi(prices) | ||
rsi(prices, timestamps) | ||
plt.subplot(gs[-2, :]) | ||
bollinger_bands(prices) | ||
bollinger_bands(prices, timestamps) | ||
|
||
return plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from algorithms.rsi import algorithm as rsi | ||
import plots.colors as colors | ||
from algorithms.rsi import algorithm as rsi | ||
|
||
def plot(prices, **kwargs): | ||
def plot(prices, timestamps, **kwargs): | ||
rsi_line = rsi(prices, **kwargs) | ||
indicies = np.arange(0, rsi_line.shape[0]) | ||
|
||
plt.plot(indicies, rsi_line, color=colors.mainline()) | ||
plt.plot(timestamps, rsi_line, color=colors.mainline()) | ||
|
||
# Thresholds | ||
upper = np.full(rsi_line.shape, 70) | ||
lower = np.full(rsi_line.shape, 30) | ||
|
||
plt.fill_between(indicies, upper, lower, color='grey', alpha=0.3) | ||
plt.plot(indicies, upper, linestyle='dashed', color=colors.upper()) | ||
plt.plot(indicies, lower, linestyle='dashed', color=colors.lower()) | ||
plt.fill_between(timestamps, upper, lower, color='grey', alpha=0.3) | ||
plt.plot(timestamps, upper, linestyle='dashed', color=colors.upper()) | ||
plt.plot(timestamps, lower, linestyle='dashed', color=colors.lower()) | ||
|
||
return plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import matplotlib.pyplot as plt | ||
import plots.colors as colors | ||
import datetime as dt | ||
import numpy as np | ||
from datetime import datetime as dt | ||
|
||
def plot(timestamps, values): | ||
def plot(values, timestamps): | ||
values = np.array(values) | ||
# times = [ dt.datetime.fromtimestamp(timestamp) for timestamp in timestamps ] | ||
times = np.arange(0, values.shape[0]) * 5 | ||
plt.plot(times, values, color=colors.upper()) | ||
timestamps = [dt.fromtimestamp(timestamp) for timestamp in timestamps] | ||
plt.plot(timestamps, values, color=colors.upper()) | ||
|
||
return plt |
Oops, something went wrong.