diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..9fe17bce
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,129 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+pip-wheel-metadata/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+.python-version
+
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..3232dba7
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 00000000..105ce2da
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..d1e22ecb
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..136d6b2c
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/streams21.iml b/.idea/streams21.iml
new file mode 100644
index 00000000..d0876a78
--- /dev/null
+++ b/.idea/streams21.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 00000000..ce1f3528
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1620233499982
+
+
+ 1620233499982
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/l4.py b/l4.py
new file mode 100644
index 00000000..0cf33179
--- /dev/null
+++ b/l4.py
@@ -0,0 +1,206 @@
+import matplotlib.pyplot as plt
+import requests
+import datetime
+from matplotlib.animation import FuncAnimation
+from matplotlib.dates import DateFormatter
+
+def Dates():
+ time_list_BTC.append(datetime.datetime.now())
+ buy, sell,volume = Values("BTCPLN")
+ BTCBuy.append(buy)
+ BTCSell.append(sell)
+ BTCVolume.append(volume)
+
+ time_list_LUNA.append(datetime.datetime.now())
+ buy, sell,volume = Values("LUNAPLN")
+ LUNABuy.append(buy)
+ LUNASell.append(sell)
+ LUNAVolume.append(volume)
+
+ time_list_DASH.append(datetime.datetime.now())
+ buy, sell,volume = Values("DASHPLN")
+ DASHBuy.append(buy)
+ DASHSell.append(sell)
+ DASHVolume.append(volume)
+ print(volume)
+
+def Values(currency):
+ r = requests.get(f"https://bitbay.net/API/Public/{currency}/ticker.json")
+ try:
+ values = r.json()
+ buy = values["bid"]
+ sell = values["ask"]
+ volume = values["volume"]
+ return buy, sell,volume
+ except requests.exceptions.HTTPError:
+ print("Something went wrong")
+
+def Avarage(list_buy,list_sell,user_parameter):
+ buy = []
+ sell = []
+ if len(list_sell) <= user_parameter:
+ for i in list_buy:
+ buy.append(i)
+ for i in list_sell:
+ sell.append(i)
+ buy = sum(buy) / len(list_sell)
+ sell = sum(sell) / len(list_buy)
+ return buy, sell
+ else:
+ for i in range(-1,-(user_parameter+1),-1):
+ buy.append(list_buy[i])
+ sell.append(list_sell[i])
+ buy = sum(buy) / user_parameter
+ sell = sum(sell) / user_parameter
+ return buy, sell
+
+
+def RSI(sell_list, user_parameter):
+ if len(sell_list) > user_parameter:
+ value = sell_list[len(sell_list) - 1] - sell_list[len(sell_list) - user_parameter]
+ if value > 0:
+ Increase_list.append(value)
+ elif value < 0:
+ Decrease_list.append(value)
+ print(Increase_list,Decrease_list)
+ a = (sum(Increase_list) + 1) / (len(Increase_list) + 1)
+ b = (sum(Decrease_list) + 1) / (len(Decrease_list) + 1)
+ else:
+ a = 1
+ b = 1
+ print(a,b)
+ RSI = 100 - (100 / (1 + (a / b)))
+ return RSI
+
+def plot():
+ global ax
+ fig, ax = plt.subplots(2,3, figsize=(14,6))
+ fig.tight_layout(pad=2)
+
+ lines.append(ax[0][0].plot(time_list_BTC, BTCBuy, color='red', label='Buy BTC',linewidth = 5))
+ lines.append(ax[0][0].plot(time_list_BTC, BTCSell, color='royalblue', label='Sell BTC', linewidth = 5))
+ lines.append(ax[0][0].plot(time_list_LUNA, BTCAVG_buy, color='gold', label='Avg buy BTC'))
+ lines.append(ax[0][0].plot(time_list_LUNA, BTCAVG_sell, color='lime', label='Avg sell BTC'))
+ ax[0][0].set_title("Quotation Chart BTC PLN")
+ ax[0][0].legend(loc=1)
+ ax[0][0].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][0].plot(time_list_BTC, BTCVolume, color='green', label='Volume BTC'))
+ ax[1][0].set_title("Volume BTC PLN")
+ ax[1][0].legend(loc=1)
+ ax[1][0].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[0][1].plot(time_list_LUNA, LUNABuy, color='red', label='Buy LUNA', linewidth = 5))
+ lines.append(ax[0][1].plot(time_list_LUNA, LUNASell, color='royalblue', label='Sell LUNA', linewidth = 5))
+ lines.append(ax[0][1].plot(time_list_LUNA, LUNAAVG_buy, color='gold', label='Avg buy LUNA'))
+ lines.append(ax[0][1].plot(time_list_LUNA, LUNAAVG_sell, color='lime', label='Avg sell LUNA'))
+ lines.append(ax[0][1].plot(time_list_LUNA, RSI_list, color='purple', label='RSI LUNA'))
+
+ ax[0][1].set_title("Quotation Chart LUNA PLN")
+ ax[0][1].legend(loc=1)
+ ax[0][1].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][1].plot(time_list_LUNA, LUNAVolume, color='green', label='Volume LUNA'))
+ ax[1][1].set_title("Volume LUNA PLN")
+ ax[1][1].legend(loc=1)
+ ax[1][1].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[0][2].plot(time_list_DASH, DASHBuy, color='red', label='Buy DASH', linewidth = 5))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHSell, color='royalblue', label='Sell DASH', linewidth = 5))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHAVG_buy, color='gold', label='Avg buy DASH'))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHAVG_sell, color='lime', label='Avg sell DASH'))
+ ax[0][2].set_title("Quotation Chart DASH PLN")
+ ax[0][2].legend(loc=1)
+ ax[0][2].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][2].plot(time_list_LUNA, LUNAVolume, color='green', label='Volume DASH'))
+
+ ax[1][2].set_title("Volume DASH PLN")
+ ax[1][2].legend(loc=1)
+ ax[1][2].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ fig.autofmt_xdate()
+
+ a = FuncAnimation(fig, func=update_plot, interval=5000)
+ plt.autoscale()
+ plt.show()
+
+def update_plot(i):
+ Dates()
+ buy, sell = Avarage(BTCBuy, BTCSell, 3)
+ BTCAVG_buy.append(buy)
+ BTCAVG_sell.append(sell)
+ buy, sell = Avarage(LUNABuy, LUNASell, 3)
+ LUNAAVG_buy.append(buy)
+ LUNAAVG_sell.append(sell)
+ buy, sell = Avarage(DASHBuy, DASHSell, 3)
+ DASHAVG_buy.append(buy)
+ DASHAVG_sell.append(sell)
+
+ rsi = RSI(LUNASell, 2)
+ print(rsi)
+ RSI_list.append(rsi)
+
+ lines[0][0].set_data(time_list_BTC, BTCBuy)
+ lines[1][0].set_data(time_list_BTC, BTCSell)
+ lines[2][0].set_data(time_list_BTC, BTCAVG_buy)
+ lines[3][0].set_data(time_list_BTC, BTCAVG_sell)
+ lines[4][0].set_data(time_list_BTC, BTCVolume)
+ lines[5][0].set_data(time_list_LUNA, LUNABuy)
+ lines[6][0].set_data(time_list_LUNA, LUNASell)
+ lines[7][0].set_data(time_list_LUNA, LUNAAVG_buy)
+ lines[8][0].set_data(time_list_LUNA, LUNAAVG_sell)
+ lines[9][0].set_data(time_list_LUNA, RSI_list)
+ lines[10][0].set_data(time_list_LUNA, LUNAVolume)
+ lines[11][0].set_data(time_list_DASH, DASHBuy)
+ lines[12][0].set_data(time_list_DASH, DASHSell)
+ lines[13][0].set_data(time_list_DASH, DASHAVG_sell)
+ lines[14][0].set_data(time_list_DASH, DASHAVG_buy)
+ lines[15][0].set_data(time_list_DASH, DASHVolume)
+
+ ax[1][0].fill_between(time_list_BTC, BTCVolume, color='green')
+ ax[1][1].fill_between(time_list_LUNA,LUNAVolume, color='green')
+ ax[1][2].fill_between(time_list_DASH, DASHVolume, color='green')
+
+ ax[0][0].relim()
+ ax[0][1].relim()
+ ax[0][2].relim()
+ ax[1][0].relim()
+ ax[1][1].relim()
+ ax[1][2].relim()
+ ax[0][0].autoscale_view()
+ ax[0][1].autoscale_view()
+ ax[0][2].autoscale_view()
+ ax[1][0].autoscale_view()
+ ax[1][1].autoscale_view()
+ ax[1][2].autoscale_view()
+ #ax[1][1].legend(loc=1)
+ #ax[1][1].xaxis.set_major_formatter(DateFormatter('%H:%M:%S')
+ #ax[1][1].set_xticks(xLabels)
+
+
+
+
+time_list_BTC = list()
+time_list_LUNA = list()
+time_list_DASH = list()
+BTCBuy = list()
+BTCSell = list()
+LUNABuy = list()
+LUNASell = list()
+DASHBuy = list()
+DASHSell = list()
+lines = list()
+BTCVolume = list()
+LUNAVolume = list()
+DASHVolume = list()
+BTCAVG_buy = list()
+BTCAVG_sell = list()
+LUNAAVG_buy = list()
+LUNAAVG_sell = list()
+DASHAVG_buy = list()
+DASHAVG_sell = list()
+RSI_list = list()
+Decrease_list = list()
+Increase_list = list()
+plot()
diff --git a/l5.py b/l5.py
new file mode 100644
index 00000000..ba0035e1
--- /dev/null
+++ b/l5.py
@@ -0,0 +1,363 @@
+import matplotlib.pyplot as plt
+import requests
+import datetime
+from matplotlib.animation import FuncAnimation
+from matplotlib.dates import DateFormatter
+import numpy as np
+
+def Values(currency):
+ r = requests.get(f"https://bitbay.net/API/Public/{currency}PLN/ticker.json")
+ try:
+ values = r.json()
+ buy = values["bid"]
+ sell = values["ask"]
+ return buy, sell
+ except requests.exceptions.HTTPError:
+ print("Something went wrong")
+
+
+def getVolume(currency, time):
+ url = f'https://api.bitbay.net/rest/trading/transactions/{currency}-PLN'
+
+ now = datetime.datetime.now()
+ before = int((now - datetime.timedelta(0, time)).timestamp()) * 1000
+ querystring = {"from": before}
+ try:
+ response = requests.request("GET", url, params=querystring)
+ volume = float(response.json()['items'][0]['a'])
+ except:
+ volume = 0
+ return volume
+
+def Avarage(list_buy, list_sell, user_parameter):
+ buy = []
+ sell = []
+ if len(list_sell) <= user_parameter:
+ for i in list_buy:
+ buy.append(i)
+ for i in list_sell:
+ sell.append(i)
+ buy = sum(buy) / len(list_sell)
+ sell = sum(sell) / len(list_buy)
+ return buy, sell
+ else:
+ for i in range(-1, -(user_parameter + 1), -1):
+ buy.append(list_buy[i])
+ sell.append(list_sell[i])
+ buy = sum(buy) / user_parameter
+ sell = sum(sell) / user_parameter
+ return buy, sell
+
+def RSI(sell_list, user_parameter, Increase_list, Decrease_list):
+ if len(sell_list) > user_parameter:
+ value = sell_list[len(sell_list) - 1] - sell_list[len(sell_list) - user_parameter]
+ if value > 0:
+ Increase_list.append(value)
+ elif value < 0:
+ Decrease_list.append(value*(-1))
+ a = (sum(Increase_list) + 1) / (len(Increase_list) + 1)
+ b = (sum(Decrease_list) + 1) / (len(Decrease_list) + 1)
+ else:
+ a = 1
+ b = 1
+ RSI = 100 - (100 / (1 +((a + 1) / (b + 1))))
+ return RSI
+
+def checkTrend(RSIArray):
+ if (RSIArray[-1] < RSIArray[-2]) and (RSIArray[-1] < RSIArray[-3]):
+ return "Downward trend"
+ elif ((RSIArray[-1] > RSIArray[-2]) and (RSIArray[-1] > RSIArray[-3])) :
+ return "Rising trend"
+ elif ((RSIArray[-1] > RSIArray[-2]) and (RSIArray[-1] == RSIArray[-3])) or ((RSIArray[-1] < RSIArray[-2]) and (RSIArray[-1] == RSIArray[-3])):
+ return "Sideways trend"
+ else:
+ return "No trend, waiting for new data"
+
+def defineCandidate(ETHTrend, LTCTrend, DASHTrend, ETHVolume, LTCVolume, DASHVolume):
+
+ ETHLastVolume = float(ETHVolume[-1])
+ LTCLastVolume = float(LTCVolume[-1])
+ DASHLastVolume = float(DASHVolume[-1])
+
+ LastVolumeArray = [ETHLastVolume, LTCLastVolume, DASHLastVolume]
+ maxVolume_list = list()
+
+ if ETHTrend != "Downward trend":
+ maxVolume_list.append(LastVolumeArray[0])
+ else:
+ maxVolume_list.append(0)
+
+ if LTCTrend != "Downward trend":
+ maxVolume_list.append(LastVolumeArray[0])
+ else:
+ maxVolume_list.append(0)
+
+ if DASHTrend != "Downward trend":
+ maxVolume_list.append(LastVolumeArray[2])
+ else:
+ maxVolume_list.append(0)
+
+ out = maxVolume_list.index(np.max(maxVolume_list))
+ if out == 0:
+ max = "ETH"
+ elif out == 1:
+ max = "LTC"
+ elif out == 2:
+ max = "DASH"
+ else:
+ max = None
+ return max
+
+def defineAsLiquid(buy, sell, S):
+ if buy > sell:
+ max = buy
+ min = sell
+ else:
+ max = sell
+ min = buy
+
+ out = min * 100/max
+ percent = 100 - out
+
+ if percent < S:
+ return True
+ else:
+ return False
+
+def defineAsVolatile(samples_list, Y, X):
+ if Y < len(samples_list):
+ Ysample = list()
+ for i in range(Y+1):
+ Ysample.append(samples_list[-i])
+ sample = Ysample[-1]
+ Ysample.pop(0)
+ else:
+ Ysample = samples_list.copy()
+ sample = Ysample[0]
+ Ysample.pop(0)
+
+ for i in range(len(Ysample)):
+ if Ysample[i] > sample:
+ max = Ysample[i]
+ min = sample
+ else:
+ max = sample
+ min = Ysample[i]
+ out = min * 100/max
+ percent = 100 - out
+
+ if percent > X:
+ return True
+
+ return False
+
+def plot():
+ global ax
+ fig, ax = plt.subplots(2, 3, figsize=(14, 6))
+ fig.tight_layout(pad=3)
+
+ lines.append(ax[0][0].plot(time_list_ETH, ETHBuy, color='red', label='Buy ETH', linewidth=5))
+ lines.append(ax[0][0].plot(time_list_ETH, ETHSell, color='royalblue', label='Sell ETH', linewidth=5))
+ lines.append(ax[0][0].plot(time_list_ETH, ETHAVG_buy, color='gold', label='Avg buy ETH'))
+ lines.append(ax[0][0].plot(time_list_ETH, ETHAVG_sell, color='lime', label='Avg sell ETH'))
+ lines.append(ax[0][0].plot(time_list_ETH, RSI_list_ETH, color='purple', label='RSI ETH'))
+ ax[0][0].set_title("Quotation Chart ETH PLN")
+ ax[0][0].legend(loc=1)
+ ax[0][0].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][0].plot(time_list_ETH, ETHVolume, color='green', label='Volume ETH'))
+ ax[1][0].set_title("Volume ETH PLN")
+ ax[1][0].legend(loc=1)
+ ax[1][0].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[0][1].plot(time_list_LTC, LTCBuy, color='red', label='Buy LTC', linewidth=5))
+ lines.append(ax[0][1].plot(time_list_LTC, LTCSell, color='royalblue', label='Sell LTC', linewidth=5))
+ lines.append(ax[0][1].plot(time_list_LTC, LTCAVG_buy, color='gold', label='Avg buy LTC'))
+ lines.append(ax[0][1].plot(time_list_LTC, LTCAVG_sell, color='lime', label='Avg sell LTC'))
+ lines.append(ax[0][1].plot(time_list_LTC, RSI_list_LTC, color='purple', label='RSI LTC'))
+
+ ax[0][1].set_title("Quotation Chart LTC PLN")
+ ax[0][1].legend(loc=1)
+ ax[0][1].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][1].plot(time_list_LTC, LTCVolume, color='green', label='Volume LTC'))
+ ax[1][1].set_title("Volume LTC PLN")
+ ax[1][1].legend(loc=1)
+ ax[1][1].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[0][2].plot(time_list_DASH, DASHBuy, color='red', label='Buy DASH', linewidth=5))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHSell, color='royalblue', label='Sell DASH', linewidth=5))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHAVG_buy, color='gold', label='Avg buy DASH'))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHAVG_sell, color='lime', label='Avg sell DASH'))
+ lines.append(ax[0][2].plot(time_list_DASH, RSI_list_DASH, color='purple', label='RSI LTC'))
+ ax[0][2].set_title("Quotation Chart DASH PLN")
+ ax[0][2].legend(loc=1)
+ ax[0][2].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][2].plot(time_list_LTC, LTCVolume, color='green', label='Volume DASH'))
+
+ ax[1][2].set_title("Volume DASH PLN")
+ ax[1][2].legend(loc=1)
+ ax[1][2].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ ax[0][0].set_yscale('log')
+ ax[0][1].set_yscale('log')
+ ax[0][2].set_yscale('log')
+
+ fig.autofmt_xdate()
+
+ a = FuncAnimation(fig, func=update_plot, interval=3000)
+ plt.autoscale()
+ plt.show()
+
+
+def update_plot(i):
+ time_list_ETH.append(datetime.datetime.now())
+ buyETH, sellETH = Values("ETH")
+ ETHBuy.append(buyETH)
+ ETHSell.append(sellETH)
+ volume = getVolume("ETH", 5)
+ ETHVolume.append(volume)
+
+ time_list_LTC.append(datetime.datetime.now())
+ buyLTC, sellLTC = Values("LTC")
+ LTCBuy.append(buyLTC)
+ LTCSell.append(sellLTC)
+ volume = getVolume("LTC", 5)
+ LTCVolume.append(volume)
+
+ time_list_DASH.append(datetime.datetime.now())
+ buyDASH, sellDASH = Values("DASH")
+ DASHBuy.append(buyDASH)
+ DASHSell.append(sellDASH)
+ volume = getVolume("DASH", 5)
+ DASHVolume.append(volume)
+
+ buy, sell = Avarage(ETHBuy, ETHSell, 3)
+ ETHAVG_buy.append(buy)
+ ETHAVG_sell.append(sell)
+
+ buy, sell = Avarage(LTCBuy, LTCSell, 3)
+ LTCAVG_buy.append(buy)
+ LTCAVG_sell.append(sell)
+
+ buy, sell = Avarage(DASHBuy, DASHSell, 3)
+ DASHAVG_buy.append(buy)
+ DASHAVG_sell.append(sell)
+
+ rsi = RSI(ETHSell, 2, Increase_list_ETH, Decrease_list_ETH)
+ RSI_list_ETH.append(rsi)
+
+ rsi = RSI(LTCSell, 2, Increase_list_LTC, Decrease_list_LTC)
+ RSI_list_LTC.append(rsi)
+
+ rsi = RSI(DASHSell, 2, Increase_list_DASH, Decrease_list_DASH)
+ RSI_list_DASH.append(rsi)
+
+ if len(RSI_list_ETH) > 3:
+ trendETH = checkTrend(RSI_list_ETH)
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}')
+ if len(RSI_list_LTC) > 3:
+ trendLTC = checkTrend(RSI_list_LTC)
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}')
+ if len(RSI_list_DASH) > 3:
+ trendDASH = checkTrend(RSI_list_DASH)
+ ax[0][2].set_xlabel(f'DASH Trend: {trendDASH}')
+
+ if len(RSI_list_LTC) > 3 and len(RSI_list_ETH) > 3 and len(RSI_list_DASH) > 3:
+ out = defineCandidate(trendETH, trendLTC, trendDASH, ETHVolume, LTCVolume, DASHVolume)
+ if out == "ETH":
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}|candiate')
+ if (defineAsLiquid(buyETH, sellETH, S)) and (defineAsVolatile(ETHBuy, Y, X)):
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}|candiate, volatile and liquid asset')
+ elif defineAsLiquid(buyETH, sellETH, S):
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}|candiate, liquid asset')
+ elif defineAsVolatile(ETHBuy, Y, X):
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}|candiate, volatile asset')
+ elif out == "LTC":
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}|candiate')
+ if (defineAsLiquid(buyLTC, sellLTC, S)) and (defineAsVolatile(LTCBuy, Y, X)):
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}|candiate, volatile and liquid asset')
+ elif defineAsLiquid(buyLTC, sellLTC, S):
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}|candiate, liquid asset')
+ elif defineAsVolatile(LTCBuy, Y, X):
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}|candiate, volatile asset')
+ elif out == "DASH":
+ ax[0][2].set_xlabel(f'DASH Trend: {trendDASH}|candiate')
+ if (defineAsLiquid(buyDASH, sellDASH, S)) and (defineAsVolatile(DASHBuy, Y, X)):
+ ax[0][1].set_xlabel(f'DASH Trend: {trendDASH}|candiate, volatile and liquid asset')
+ elif defineAsLiquid(buyDASH, sellDASH, S):
+ ax[0][2].set_xlabel(f'DASH Trend: {trendDASH}|candiate ,liquid asset')
+ elif defineAsVolatile(DASHBuy, Y, X):
+ ax[0][1].set_xlabel(f'DASH Trend: {trendDASH}|candiate, volatile asset')
+
+
+ lines[0][0].set_data(time_list_ETH, ETHBuy)
+ lines[1][0].set_data(time_list_ETH, ETHSell)
+ lines[2][0].set_data(time_list_ETH, ETHAVG_buy)
+ lines[3][0].set_data(time_list_ETH, ETHAVG_sell)
+ lines[4][0].set_data(time_list_ETH, RSI_list_ETH)
+ lines[5][0].set_data(time_list_ETH, ETHVolume)
+ lines[6][0].set_data(time_list_LTC, LTCBuy)
+ lines[7][0].set_data(time_list_LTC, LTCSell)
+ lines[8][0].set_data(time_list_LTC, LTCAVG_buy)
+ lines[9][0].set_data(time_list_LTC, LTCAVG_sell)
+ lines[10][0].set_data(time_list_LTC, RSI_list_LTC)
+ lines[11][0].set_data(time_list_LTC, LTCVolume)
+ lines[12][0].set_data(time_list_DASH, DASHBuy)
+ lines[13][0].set_data(time_list_DASH, DASHSell)
+ lines[14][0].set_data(time_list_DASH, DASHAVG_sell)
+ lines[15][0].set_data(time_list_DASH, DASHAVG_buy)
+ lines[16][0].set_data(time_list_DASH, RSI_list_DASH)
+ lines[17][0].set_data(time_list_DASH, DASHVolume)
+
+ ax[1][0].fill_between(time_list_ETH, ETHVolume, color='green')
+ ax[1][1].fill_between(time_list_LTC, LTCVolume, color='green')
+ ax[1][2].fill_between(time_list_DASH, DASHVolume, color='green')
+
+ ax[0][0].relim()
+ ax[0][1].relim()
+ ax[0][2].relim()
+ ax[1][0].relim()
+ ax[1][1].relim()
+ ax[1][2].relim()
+ ax[0][0].autoscale_view()
+ ax[0][1].autoscale_view()
+ ax[0][2].autoscale_view()
+ ax[1][0].autoscale_view()
+ ax[1][1].autoscale_view()
+ ax[1][2].autoscale_view()
+
+
+time_list_ETH = list()
+time_list_LTC = list()
+time_list_DASH = list()
+ETHBuy = list()
+ETHSell = list()
+LTCBuy = list()
+LTCSell = list()
+DASHBuy = list()
+DASHSell = list()
+lines = list()
+ETHVolume = list()
+LTCVolume = list()
+DASHVolume = list()
+ETHAVG_buy = list()
+ETHAVG_sell = list()
+LTCAVG_buy = list()
+LTCAVG_sell = list()
+DASHAVG_buy = list()
+DASHAVG_sell = list()
+RSI_list_ETH = list()
+RSI_list_DASH = list()
+RSI_list_LTC = list()
+Decrease_list_DASH = list()
+Increase_list_DASH = list()
+Decrease_list_ETH = list()
+Increase_list_ETH = list()
+Decrease_list_LTC = list()
+Increase_list_LTC = list()
+S = 5
+X = 3
+Y = 5
+plot()
diff --git a/l6.py b/l6.py
new file mode 100644
index 00000000..95c0a498
--- /dev/null
+++ b/l6.py
@@ -0,0 +1,461 @@
+import matplotlib.pyplot as plt
+import requests
+import datetime
+from matplotlib.animation import FuncAnimation
+from matplotlib.dates import DateFormatter
+import numpy as np
+import json
+
+def Values(currency):
+ r = requests.get(f"https://bitbay.net/API/Public/{currency}PLN/ticker.json")
+ try:
+ values = r.json()
+ buy = values["bid"]
+ sell = values["ask"]
+ return buy, sell
+ except requests.exceptions.HTTPError:
+ print("Something went wrong")
+
+
+def getVolume(currency, time):
+ url = f'https://api.bitbay.net/rest/trading/transactions/{currency}-PLN'
+
+ now = datetime.datetime.now()
+ before = int((now - datetime.timedelta(0, time)).timestamp()) * 1000
+ querystring = {"from": before}
+ try:
+ response = requests.request("GET", url, params=querystring)
+ volume = float(response.json()['items'][0]['a'])
+ except:
+ volume = 0
+ return volume
+
+def Avarage(list_buy, list_sell, user_parameter):
+ buy = []
+ sell = []
+ if len(list_sell) <= user_parameter:
+ for i in list_buy:
+ buy.append(i)
+ for i in list_sell:
+ sell.append(i)
+ buy = sum(buy) / len(list_sell)
+ sell = sum(sell) / len(list_buy)
+ return buy, sell
+ else:
+ for i in range(-1, -(user_parameter + 1), -1):
+ buy.append(list_buy[i])
+ sell.append(list_sell[i])
+ buy = sum(buy) / user_parameter
+ sell = sum(sell) / user_parameter
+ return buy, sell
+
+def RSI(sell_list, user_parameter, Increase_list, Decrease_list):
+ if len(sell_list) > user_parameter:
+ value = sell_list[len(sell_list) - 1] - sell_list[len(sell_list) - user_parameter]
+ if value > 0:
+ Increase_list.append(value)
+ elif value < 0:
+ Decrease_list.append(value*(-1))
+ a = (sum(Increase_list) + 1) / (len(Increase_list) + 1)
+ b = (sum(Decrease_list) + 1) / (len(Decrease_list) + 1)
+ else:
+ a = 1
+ b = 1
+ RSI = 100 - (100 / (1 +((a + 1) / (b + 1))))
+ return RSI
+
+def checkTrend(RSIArray):
+ if (RSIArray[-1] < RSIArray[-2]) and (RSIArray[-1] < RSIArray[-3]):
+ return "Downward trend"
+ elif ((RSIArray[-1] > RSIArray[-2]) and (RSIArray[-1] > RSIArray[-3])) :
+ return "Rising trend"
+ elif ((RSIArray[-1] > RSIArray[-2]) and (RSIArray[-1] == RSIArray[-3])) or ((RSIArray[-1] < RSIArray[-2]) and (RSIArray[-1] == RSIArray[-3])):
+ return "Sideways trend"
+ else:
+ return "No trend, waiting for new data"
+
+def defineCandidate(ETHTrend, LTCTrend, DASHTrend, ETHVolume, LTCVolume, DASHVolume):
+
+ ETHLastVolume = float(ETHVolume[-1])
+ LTCLastVolume = float(LTCVolume[-1])
+ DASHLastVolume = float(DASHVolume[-1])
+
+ LastVolumeArray = [ETHLastVolume, LTCLastVolume, DASHLastVolume]
+ maxVolume_list = list()
+
+ if ETHTrend != "Downward trend":
+ maxVolume_list.append(LastVolumeArray[0])
+ else:
+ maxVolume_list.append(0)
+
+ if LTCTrend != "Downward trend":
+ maxVolume_list.append(LastVolumeArray[0])
+ else:
+ maxVolume_list.append(0)
+
+ if DASHTrend != "Downward trend":
+ maxVolume_list.append(LastVolumeArray[2])
+ else:
+ maxVolume_list.append(0)
+
+ out = maxVolume_list.index(np.max(maxVolume_list))
+ if out == 0:
+ max = "ETH"
+ elif out == 1:
+ max = "LTC"
+ elif out == 2:
+ max = "DASH"
+ else:
+ max = None
+ return max
+
+def defineAsLiquid(buy, sell, S):
+ if buy > sell:
+ max = buy
+ min = sell
+ else:
+ max = sell
+ min = buy
+
+ out = min * 100/max
+ percent = 100 - out
+
+ if percent < S:
+ return True
+ else:
+ return False
+
+def defineAsVolatile(samples_list, Y, X):
+ if Y < len(samples_list):
+ Ysample = list()
+ for i in range(Y+1):
+ Ysample.append(samples_list[-i])
+ sample = Ysample[-1]
+ Ysample.pop(0)
+ else:
+ Ysample = samples_list.copy()
+ sample = Ysample[0]
+ Ysample.pop(0)
+
+ for i in range(len(Ysample)):
+ if Ysample[i] > sample:
+ max = Ysample[i]
+ min = sample
+ else:
+ max = sample
+ min = Ysample[i]
+ out = min * 100/max
+ percent = 100 - out
+
+ if percent > X:
+ return True
+
+ return False
+
+
+def get_filename():
+ filename = 'file1.json'
+ return filename
+
+def avg_from_json(filename):
+ with open(filename, 'r') as file:
+ datas = json.load(file)
+
+ pricing_list_ETH = list()
+ pricing_list_LTC = list()
+ pricing_list_DASH = list()
+ quantity_list_ETH = list()
+ quantity_list_LTC = list()
+ quantity_list_DASH = list()
+
+ for data in datas["ETH"]:
+ price_of_one = data[1] * data[0]
+ quantity_list_ETH.append(data[0])
+ pricing_list_ETH.append(price_of_one)
+ if len(pricing_list_ETH) < 1:
+ My_ETHmean = None
+ else:
+ My_ETHmean = (sum(pricing_list_ETH)) / (sum(quantity_list_ETH))
+
+ for data in datas["LTC"]:
+ price_of_one = data[1] * data[0]
+ quantity_list_LTC.append(data[0])
+ pricing_list_LTC.append(price_of_one)
+ if len(pricing_list_LTC) < 1:
+ My_LTCmean = None
+ else:
+ My_LTCmean = (sum(pricing_list_LTC)) / (sum(quantity_list_LTC))
+
+ for data in datas["DASH"]:
+ price_of_one = data[1] * data[0]
+ quantity_list_DASH.append(data[0])
+ pricing_list_DASH.append(price_of_one)
+ if len(pricing_list_DASH) < 1:
+ My_DASHmean = None
+ else:
+ My_DASHmean = (sum(pricing_list_DASH)) / (sum(quantity_list_DASH))
+
+ file.close()
+ return My_ETHmean, My_LTCmean, My_DASHmean
+
+
+def profit_value_json():
+ with open('sell_values_json.json', 'r') as file:
+ profit = json.load(file)
+
+ ETH_profit = profit["ETH"]
+ LTC_profit = profit["LTC"]
+ DASH_profit = profit["DASH"]
+ return sum(ETH_profit), sum(LTC_profit), sum(DASH_profit)
+def plot():
+ global ax
+ fig, ax = plt.subplots(3, 3, figsize=(20, 12))
+ fig.tight_layout(pad=5)
+
+ lines.append(ax[0][0].plot(time_list_ETH, ETHBuy, color='red', label='Buy ETH', linewidth=5))
+ lines.append(ax[0][0].plot(time_list_ETH, ETHSell, color='royalblue', label='Sell ETH', linewidth=5))
+ lines.append(ax[0][0].plot(time_list_ETH, ETHAVG_buy, color='gold', label='Avg buy ETH'))
+ lines.append(ax[0][0].plot(time_list_ETH, ETHAVG_sell, color='lime', label='Avg sell ETH'))
+ lines.append(ax[0][0].plot(time_list_ETH, MY_ETHAVG, color='pink', label='My avg buy ETH', linestyle ='dashed'))
+ ax[0][0].set_title("Quotation Chart ETH PLN")
+ ax[0][0].legend(loc=1)
+ ax[0][0].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][0].plot(time_list_ETH, ETHVolume, color='green', label='Volume ETH'))
+ ax[1][0].set_title("Volume ETH PLN")
+ ax[1][0].legend(loc=1)
+ ax[1][0].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[2][0].plot(time_list_ETH, RSI_list_ETH, color='purple', label='RSI ETH'))
+ ax[2][0].set_title("RSI ETH PLN")
+ ax[2][0].legend(loc=1)
+ ax[2][0].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[0][1].plot(time_list_LTC, LTCBuy, color='red', label='Buy LTC', linewidth=5))
+ lines.append(ax[0][1].plot(time_list_LTC, LTCSell, color='royalblue', label='Sell LTC', linewidth=5))
+ lines.append(ax[0][1].plot(time_list_LTC, LTCAVG_buy, color='gold', label='Avg buy LTC'))
+ lines.append(ax[0][1].plot(time_list_LTC, LTCAVG_sell, color='lime', label='Avg sell LTC'))
+ lines.append(ax[0][1].plot(time_list_LTC, MY_LTCAVG, color='pink', label='My avg buy LTC', linestyle ='dashed'))
+
+ ax[0][1].set_title("Quotation Chart LTC PLN")
+ ax[0][1].legend(loc=1)
+ ax[0][1].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][1].plot(time_list_LTC, LTCVolume, color='green', label='Volume LTC'))
+ ax[1][1].set_title("Volume LTC PLN")
+ ax[1][1].legend(loc=1)
+ ax[1][1].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+
+ lines.append(ax[2][1].plot(time_list_LTC, RSI_list_LTC, color='purple', label='RSI LTC'))
+ ax[2][1].set_title("RSI LTC PLN")
+ ax[2][1].legend(loc=1)
+ ax[2][1].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[0][2].plot(time_list_DASH, DASHBuy, color='red', label='Buy DASH', linewidth=5))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHSell, color='royalblue', label='Sell DASH', linewidth=5))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHAVG_buy, color='gold', label='Avg buy DASH'))
+ lines.append(ax[0][2].plot(time_list_DASH, DASHAVG_sell, color='lime', label='Avg sell DASH'))
+ lines.append(ax[0][2].plot(time_list_DASH, MY_DASHAVG, color='pink', label='My avg buy DASH', linestyle ='dashed'))
+ ax[0][2].set_title("Quotation Chart DASH PLN")
+ ax[0][2].legend(loc=1)
+ ax[0][2].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[1][2].plot(time_list_LTC, LTCVolume, color='green', label='Volume DASH'))
+ ax[1][2].set_title("Volume DASH PLN")
+ ax[1][2].legend(loc=1)
+ ax[1][2].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+ lines.append(ax[2][2].plot(time_list_DASH, RSI_list_DASH, color='purple', label='RSI DASH'))
+ ax[2][2].set_title("RSI DASH PLN")
+ ax[2][2].legend(loc=1)
+ ax[2][2].xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
+
+
+ fig.autofmt_xdate()
+ a = FuncAnimation(fig, func=update_plot, interval=3000)
+ plt.autoscale()
+ plt.show()
+
+
+def update_plot(i):
+ time_list_ETH.append(datetime.datetime.now())
+ buyETH, sellETH = Values("ETH")
+ ETHBuy.append(buyETH)
+ ETHSell.append(sellETH)
+ volume = getVolume("ETH", 5)
+ ETHVolume.append(volume)
+
+ time_list_LTC.append(datetime.datetime.now())
+ buyLTC, sellLTC = Values("LTC")
+ LTCBuy.append(buyLTC)
+ LTCSell.append(sellLTC)
+ volume = getVolume("LTC", 5)
+ LTCVolume.append(volume)
+
+ time_list_DASH.append(datetime.datetime.now())
+ buyDASH, sellDASH = Values("DASH")
+ DASHBuy.append(buyDASH)
+ DASHSell.append(sellDASH)
+ volume = getVolume("DASH", 5)
+ DASHVolume.append(volume)
+
+ buy, sell = Avarage(ETHBuy, ETHSell, 3)
+ ETHAVG_buy.append(buy)
+ ETHAVG_sell.append(sell)
+
+ buy, sell = Avarage(LTCBuy, LTCSell, 3)
+ LTCAVG_buy.append(buy)
+ LTCAVG_sell.append(sell)
+
+ buy, sell = Avarage(DASHBuy, DASHSell, 3)
+ DASHAVG_buy.append(buy)
+ DASHAVG_sell.append(sell)
+
+ rsi = RSI(ETHSell, 2, Increase_list_ETH, Decrease_list_ETH)
+ RSI_list_ETH.append(rsi)
+
+ rsi = RSI(LTCSell, 2, Increase_list_LTC, Decrease_list_LTC)
+ RSI_list_LTC.append(rsi)
+
+ rsi = RSI(DASHSell, 2, Increase_list_DASH, Decrease_list_DASH)
+ RSI_list_DASH.append(rsi)
+
+ if len(RSI_list_ETH) > 3:
+ trendETH = checkTrend(RSI_list_ETH)
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}')
+ if len(RSI_list_LTC) > 3:
+ trendLTC = checkTrend(RSI_list_LTC)
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}')
+ if len(RSI_list_DASH) > 3:
+ trendDASH = checkTrend(RSI_list_DASH)
+ ax[0][2].set_xlabel(f'DASH Trend: {trendDASH}')
+
+ if len(RSI_list_LTC) > 3 and len(RSI_list_ETH) > 3 and len(RSI_list_DASH) > 3:
+ out = defineCandidate(trendETH, trendLTC, trendDASH, ETHVolume, LTCVolume, DASHVolume)
+ if out == "ETH":
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}|candiate')
+ if (defineAsLiquid(buyETH, sellETH, S)) and (defineAsVolatile(ETHBuy, Y, X)):
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}|candiate, volatile and liquid asset')
+ elif defineAsLiquid(buyETH, sellETH, S):
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}|candiate, liquid asset')
+ elif defineAsVolatile(ETHBuy, Y, X):
+ ax[0][0].set_xlabel(f'ETH Trend: {trendETH}|candiate, volatile asset')
+ elif out == "LTC":
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}|candiate')
+ if (defineAsLiquid(buyLTC, sellLTC, S)) and (defineAsVolatile(LTCBuy, Y, X)):
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}|candiate, volatile and liquid asset')
+ elif defineAsLiquid(buyLTC, sellLTC, S):
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}|candiate, liquid asset')
+ elif defineAsVolatile(LTCBuy, Y, X):
+ ax[0][1].set_xlabel(f'LTC Trend: {trendLTC}|candiate, volatile asset')
+ elif out == "DASH":
+ ax[0][2].set_xlabel(f'DASH Trend: {trendDASH}|candiate')
+ if (defineAsLiquid(buyDASH, sellDASH, S)) and (defineAsVolatile(DASHBuy, Y, X)):
+ ax[0][2].set_xlabel(f'DASH Trend: {trendDASH}|candiate, volatile and liquid asset')
+ elif defineAsLiquid(buyDASH, sellDASH, S):
+ ax[0][2].set_xlabel(f'DASH Trend: {trendDASH}|candiate ,liquid asset')
+ elif defineAsVolatile(DASHBuy, Y, X):
+ ax[0][2].set_xlabel(f'DASH Trend: {trendDASH}|candiate, volatile asset')
+
+ averages = avg_from_json(FILE_NAME)
+ MY_ETHAVG.append(averages[0])
+ MY_LTCAVG.append(averages[1])
+ MY_DASHAVG.append(averages[2])
+
+ crypto_profits = profit_value_json()
+ ETH_profit_label = crypto_profits[0]
+ LTC_profit_label = crypto_profits[1]
+ DASH_profit_label = crypto_profits[2]
+
+ if ETH_profit_label != 0:
+ ax[0][0].set_title(f'Quotation Chart ETH PLN |Profit {ETH_profit_label} PLN')
+ if LTC_profit_label != 0:
+ ax[0][1].set_title(f'Quotation Chart LTC PLN |Profit {LTC_profit_label} PLN')
+ if DASH_profit_label != 0:
+ ax[0][2].set_title(f'Quotation Chart DASH PLN |Profit {DASH_profit_label} PLN')
+
+ lines[0][0].set_data(time_list_ETH, ETHBuy)
+ lines[1][0].set_data(time_list_ETH, ETHSell)
+ lines[2][0].set_data(time_list_ETH, ETHAVG_buy)
+ lines[3][0].set_data(time_list_ETH, ETHAVG_sell)
+ lines[4][0].set_data(time_list_ETH, MY_ETHAVG[-1])
+ lines[5][0].set_data(time_list_ETH, ETHVolume)
+ lines[6][0].set_data(time_list_ETH, RSI_list_ETH)
+ lines[7][0].set_data(time_list_LTC, LTCBuy)
+ lines[8][0].set_data(time_list_LTC, LTCSell)
+ lines[9][0].set_data(time_list_LTC, LTCAVG_buy)
+ lines[10][0].set_data(time_list_LTC, LTCAVG_sell)
+ lines[11][0].set_data(time_list_LTC, MY_LTCAVG[-1])
+ lines[12][0].set_data(time_list_LTC, LTCVolume)
+ lines[13][0].set_data(time_list_LTC, RSI_list_LTC)
+ lines[14][0].set_data(time_list_DASH, DASHBuy)
+ lines[15][0].set_data(time_list_DASH, DASHSell)
+ lines[16][0].set_data(time_list_DASH, DASHAVG_sell)
+ lines[17][0].set_data(time_list_DASH, DASHAVG_buy)
+ lines[18][0].set_data(time_list_DASH, MY_DASHAVG[-1])
+ lines[19][0].set_data(time_list_DASH, DASHVolume)
+ lines[20][0].set_data(time_list_DASH, RSI_list_DASH)
+
+ ax[1][0].fill_between(time_list_ETH, ETHVolume, color='green')
+ ax[1][1].fill_between(time_list_LTC, LTCVolume, color='green')
+ ax[1][2].fill_between(time_list_DASH, DASHVolume, color='green')
+
+ ax[0][0].relim()
+ ax[0][1].relim()
+ ax[0][2].relim()
+ ax[1][0].relim()
+ ax[1][1].relim()
+ ax[1][2].relim()
+ ax[2][0].relim()
+ ax[2][1].relim()
+ ax[2][2].relim()
+ ax[0][0].autoscale_view()
+ ax[0][1].autoscale_view()
+ ax[0][2].autoscale_view()
+ ax[1][0].autoscale_view()
+ ax[1][1].autoscale_view()
+ ax[1][2].autoscale_view()
+ ax[2][0].autoscale_view()
+ ax[2][1].autoscale_view()
+ ax[2][2].autoscale_view()
+
+
+time_list_ETH = list()
+time_list_LTC = list()
+time_list_DASH = list()
+ETHBuy = list()
+ETHSell = list()
+LTCBuy = list()
+LTCSell = list()
+DASHBuy = list()
+DASHSell = list()
+lines = list()
+ETHVolume = list()
+LTCVolume = list()
+DASHVolume = list()
+ETHAVG_buy = list()
+ETHAVG_sell = list()
+LTCAVG_buy = list()
+LTCAVG_sell = list()
+DASHAVG_buy = list()
+DASHAVG_sell = list()
+RSI_list_ETH = list()
+RSI_list_DASH = list()
+RSI_list_LTC = list()
+Decrease_list_DASH = list()
+Increase_list_DASH = list()
+Decrease_list_ETH = list()
+Increase_list_ETH = list()
+Decrease_list_LTC = list()
+Increase_list_LTC = list()
+
+FILE_NAME = get_filename()
+MY_ETHAVG = list()
+MY_LTCAVG = list()
+MY_DASHAVG = list()
+
+S = 5
+X = 3
+Y = 5
+plot()
diff --git a/l6_gui.py b/l6_gui.py
new file mode 100644
index 00000000..e4152611
--- /dev/null
+++ b/l6_gui.py
@@ -0,0 +1,149 @@
+import json
+from tkinter import *
+
+def file_to_read():
+ entered_name = 'file1.json'
+ return entered_name
+
+def save_app_data():
+ #file1 = crypto_chosen.get()
+ total_amount = 0
+ buying_price = 0
+
+ cryptocurr = variable.get()
+ type1 = variable_1.get()
+ amount = float(Text_2.get())
+ price = float(Text_1.get())
+ print(cryptocurr,type1,amount,price)
+
+ if type1 == "Buy":
+ file = open(file_name, 'r')
+ json_data = json.load(file)
+ file.close()
+
+ json_data[cryptocurr].append([amount, price])
+ file = open(file_name, 'w')
+ json.dump(json_data, file)
+ file.close()
+
+ elif type1 == "Sell":
+ file = open(file_name, 'r')
+ json_data = json.load(file)
+ file.close()
+ crypto_amount = json_data[cryptocurr]
+
+ for i in range(len(crypto_amount)):
+ total_amount += crypto_amount[i][0]
+
+ if amount > total_amount:
+ print(f'You do not have enough this crypto to sell it.')
+ else:
+ counter = 0
+ j = 0
+ while counter < amount:
+ if crypto_amount[j][0] >= amount:
+ buying_price += crypto_amount[j][1]*amount
+ crypto_amount[j][0] -= amount
+ counter += amount
+ elif (crypto_amount[j][0]+counter < amount) and crypto_amount[j][0] > 0:
+ buying_price += crypto_amount[j][1] * crypto_amount[j][0]
+ counter += crypto_amount[j][0]
+ crypto_amount[j][0] = 0
+ elif (crypto_amount[j][0] + counter > amount) and crypto_amount[j][0] > 0:
+ temp = amount-counter
+ buying_price += crypto_amount[j][1] * temp
+ counter += temp
+ crypto_amount[j][0] -= temp
+ elif crypto_amount[j][0] == 0:
+ j = j + 1
+
+ seling_price = (amount * price)
+ profit = seling_price - buying_price
+
+ for i in range(0, len(crypto_amount)):
+ if crypto_amount[0][0] == 0:
+ del crypto_amount[0]
+
+ json_data[cryptocurr] = crypto_amount
+ file = open(file_name, 'w')
+ json.dump(json_data, file)
+ file.close()
+
+ file_profit = open('sell_values_json.json', 'r')
+ profit_data = json.load(file_profit)
+ file_profit.close()
+ profit_data[cryptocurr].append(profit)
+
+ file_profit = open('sell_values_json.json', 'w')
+ json.dump(profit_data, file_profit)
+ file_profit.close()
+
+def clearing_json_file():
+ with open(file_name, 'w') as file:
+ json_data = {}
+ json_data["ETH"] = []
+ json_data["LTC"] = []
+ json_data["DASH"] = []
+ json.dump(json_data, file)
+ file.close()
+
+def clearing_profit_file():
+ with open('sell_values_json.json', 'w') as file:
+ json_data = {}
+ json_data["ETH"] = []
+ json_data["LTC"] = []
+ json_data["DASH"] = []
+ json.dump(json_data, file)
+ file.close()
+def buying_window():
+ global variable,variable_1,Text_2,Text_1
+
+ root =Tk()
+ img = PhotoImage(file='btc_logo.png')
+ root.iconphoto(False, img)
+ root.title("Crypto buying window")
+ root.geometry("300x300")
+ #Canvas(root, width = 1000, height = 800)
+ crytpo_list = ["ETH","LTC","DASH"]
+ crytpo_to_chose= Label(root,text = "Which crypto?",font=('Montserrat',10))
+ crytpo_to_chose.pack()
+
+ variable = StringVar(root)
+ variable.set("ETH") # default value
+ crypto_chosen = OptionMenu(root, variable, *crytpo_list)
+ crypto_chosen.pack()
+
+ crytpo_buy_sell= Label(root,text = "Do you want to buy or sell crypto?",font=('Montserrat',10))
+ crytpo_buy_sell.pack()
+
+ variable_1 = StringVar(root)
+ variable_1.set("Buy") # default value
+ crypto_buy_sell = OptionMenu(root, variable_1, "Buy","Sell")
+ crypto_buy_sell.pack()
+
+ crytpo_to_amout= Label(root,text = "Enter the amount of selected crypto:",font=('Montserrat',10))
+ crytpo_to_amout.pack()
+ Text_2 = Entry(root)
+ Text_2.pack()
+
+ crytpo_to_price= Label(root,text = "Enter the price of selected crypto:",font=('Montserrat',10))
+ crytpo_to_price.pack()
+ Text_1 = Entry(root)
+ Text_1.pack()
+
+ button_confirm = Button(root, text='Confirm',command= save_app_data,font=('Montserrat',10))
+ button_confirm.configure(background='royalblue', width=10)
+ button_confirm.pack(expand=True)
+
+ clearing = Button(root, text='Clear json file', font=('Montserrat',10), command=clearing_json_file)
+ clearing.pack(expand=True)
+ clearing.configure(background='red')
+
+ clearing = Button(root, text='Clear profit file', font=('Montserrat',10), command=clearing_profit_file)
+ clearing.pack(expand=True)
+ clearing.configure(background='red')
+
+ root.mainloop()
+file_name = file_to_read()
+buying_window()
+