-
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
Karantezsure
committed
May 26, 2022
1 parent
0821947
commit a60eadf
Showing
272 changed files
with
10,235 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM python:3.10-slim-buster | ||
|
||
RUN pip install poetry | ||
|
||
|
||
WORKDIR /demo | ||
COPY poetry.lock pyproject.toml /demo/ | ||
|
||
RUN poetry config virtualenvs.create false && poetry install --no-dev | ||
|
||
COPY . /demo | ||
|
||
ENTRYPOINT ["poetry", "run", "dipdup"] | ||
CMD ["-c", "dipdup.yml", "run"] |
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from decimal import Decimal | ||
import imp | ||
from pyexpat import model | ||
import demo.models as models | ||
from datetime import datetime, timedelta | ||
|
||
async def history_main_data(start_date): | ||
try: | ||
main_data = await models.MainData\ | ||
.filter(timestamp__gte=start_date)\ | ||
.order_by("timestamp")\ | ||
.first() | ||
print("Hey Man", main_data.current_target); | ||
except(TypeError, AttributeError): | ||
# print("Errory") | ||
main_data = Decimal(0); | ||
|
||
return main_data; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from decimal import Decimal | ||
import imp | ||
from pyexpat import model | ||
import demo.models as models | ||
from datetime import datetime, timedelta | ||
|
||
async def main_history_data(): | ||
try: | ||
main_data = await models.MainData\ | ||
.all()\ | ||
.order_by("-timestamp")\ | ||
.first() | ||
except(TypeError, AttributeError): | ||
main_data = Decimal(0); | ||
|
||
return main_data; |
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+894 Bytes
demo/functions/Price_stats/__pycache__/change_price.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+878 Bytes
demo/functions/Price_stats/__pycache__/change_price_history.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+746 Bytes
demo/functions/Price_stats/__pycache__/history_block_level.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+652 Bytes
demo/functions/Price_stats/__pycache__/history_of_price.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+650 Bytes
demo/functions/Price_stats/__pycache__/history_of_price.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from decimal import Decimal | ||
import imp | ||
from pyexpat import model | ||
import demo.models as models | ||
from datetime import datetime, timedelta | ||
|
||
async def get_level(): | ||
try: | ||
ctez_trade = await models.Trade\ | ||
.filter(token_symbol = 'ctez')\ | ||
.order_by("-timestamp")\ | ||
.first() | ||
level_value = ctez_trade.level; | ||
except(TypeError, AttributeError): | ||
level_value = float(1); | ||
|
||
return level_value; |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from decimal import Decimal | ||
import imp | ||
from pyexpat import model | ||
import demo.models as models | ||
from datetime import datetime, timedelta | ||
|
||
async def price_change_stats(price_token, amount_of_days): | ||
current_timestamp = datetime.utcnow(); | ||
days_ago_time = current_timestamp - timedelta(days=amount_of_days); | ||
try: | ||
ctez_trade = await models.Trade\ | ||
.filter(timestamp__gte=days_ago_time)\ | ||
.filter(timestamp__lte=current_timestamp)\ | ||
.order_by("timestamp")\ | ||
.first() | ||
ctez_price_days_ago = float(ctez_trade.price); | ||
|
||
price_change = float(((price_token - ctez_price_days_ago)/ctez_price_days_ago)*100); | ||
# print("Hey", price_change); | ||
|
||
except(TypeError, AttributeError): | ||
price_change = float(0); | ||
|
||
return price_change; |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from decimal import Decimal | ||
import imp | ||
from pyexpat import model | ||
import demo.models as models | ||
from datetime import datetime, timedelta | ||
|
||
async def price_change_stats_history(price_token, start_date, amount_of_days): | ||
# current_timestamp = datetime.utcnow(); | ||
days_ago_time = start_date - timedelta(days=amount_of_days); | ||
try: | ||
ctez_trade = await models.Trade\ | ||
.filter(timestamp__gte=days_ago_time)\ | ||
.filter(timestamp__lte=start_date)\ | ||
.order_by("timestamp")\ | ||
.first() | ||
ctez_price_days_ago = float(ctez_trade.price); | ||
|
||
price_change = float(((price_token - ctez_price_days_ago)/ctez_price_days_ago)*100); | ||
# print("Hey", price_change); | ||
|
||
except(TypeError, AttributeError): | ||
price_change = float(0); | ||
|
||
return price_change; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from decimal import Decimal | ||
import imp | ||
from pyexpat import model | ||
import demo.models as models | ||
from datetime import datetime, timedelta | ||
|
||
async def get_history_level(start_date): | ||
try: | ||
ctez_trade = await models.Trade\ | ||
.filter(token_symbol = 'ctez')\ | ||
.filter(timestamp__gte=start_date)\ | ||
.order_by("timestamp")\ | ||
.first() | ||
level_value = ctez_trade.level; | ||
except(TypeError, AttributeError): | ||
level_value = float(1); | ||
|
||
return level_value; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def history_price(start_date): | ||
try: | ||
ctez_trade = await models.Trade\ | ||
.filter(timestamp__gte=start_date)\ | ||
.order_by("timestamp")\ | ||
.first() | ||
# print(ctez_trade); | ||
history_ctez_price = float(ctez_trade.price); | ||
except(TypeError, AttributeError): | ||
history_ctez_price = float(0); | ||
|
||
return history_ctez_price; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def price_stats_provider(): | ||
try: | ||
ctez_trade = await models.Trade\ | ||
.filter(token_symbol='ctez')\ | ||
.order_by("-timestamp")\ | ||
.first() | ||
# print(ctez_trade.price); | ||
ctez_price = float(ctez_trade.price); | ||
except(TypeError, AttributeError): | ||
ctez_price = float(0); | ||
|
||
return ctez_price; |
Binary file added
BIN
+702 Bytes
demo/functions/Tvl_stats/__pycache__/calculate_history_pool.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+698 Bytes
demo/functions/Tvl_stats/__pycache__/calculate_history_pool.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+640 Bytes
demo/functions/Tvl_stats/__pycache__/calculate_history_tvl.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+651 Bytes
demo/functions/Tvl_stats/__pycache__/calculate_history_tvl.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+711 Bytes
demo/functions/Tvl_stats/__pycache__/calculate_pool_history.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+672 Bytes
demo/functions/Tvl_stats/__pycache__/calculate_tvl_history.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from decimal import Decimal | ||
from multiprocessing import pool | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def history_pool(start_date): | ||
try: | ||
pool_data = await models.Position\ | ||
.filter(timestamp__gte=start_date)\ | ||
.order_by("timestamp")\ | ||
.first() | ||
# print(pool_data.quantity_pool1); | ||
pool_stats = Decimal(pool_data.quantity_pool1); | ||
# print("Hey", tvl_stat); | ||
|
||
except(TypeError, AttributeError): | ||
# print("Errory Women") | ||
pool_stats = Decimal(0); | ||
|
||
return pool_stats; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def history_tvl(start_date): | ||
try: | ||
tvl_data = await models.TezOven\ | ||
.filter(timestamp__gte=start_date)\ | ||
.order_by("timestamp")\ | ||
.first() | ||
# print(tvl_data); | ||
tvl_stats = Decimal(tvl_data.tez_in_all_ovens); | ||
# print("Hey", tvl_stat); | ||
|
||
except(TypeError, AttributeError): | ||
# print("Errory Man") | ||
tvl_stats = Decimal(0); | ||
|
||
return tvl_stats; |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from decimal import Decimal | ||
from multiprocessing import pool | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def pool_history(): | ||
try: | ||
pool_data = await models.Position\ | ||
.all()\ | ||
.order_by("-timestamp")\ | ||
.first() | ||
|
||
pool_stats = Decimal(pool_data.quantity_pool1); | ||
print("Hey Women") | ||
# print("Hey", tvl_stat); | ||
|
||
except(TypeError, AttributeError): | ||
print("Errory Women1") | ||
pool_stats = Decimal(0); | ||
|
||
return pool_stats; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def tvl_stats(): | ||
try: | ||
oven_stat = await models.ovendata\ | ||
.all() | ||
tvl_stat = Decimal(0); | ||
for i in range(len(oven_stat)): | ||
tvl_stat += Decimal(oven_stat[i].tez_standing); | ||
# print("Hey", tvl_stat); | ||
|
||
except(TypeError, AttributeError): | ||
tvl_stat = Decimal(0); | ||
|
||
return tvl_stat; |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def tvl_history(): | ||
try: | ||
tvl_data = await models.TezOven\ | ||
.all()\ | ||
.order_by("-timestamp")\ | ||
.first() | ||
|
||
print(tvl_data.tez_in_all_ovens) | ||
tvl_stats = Decimal(tvl_data.tez_in_all_ovens); | ||
# print("Hey", tvl_stat); | ||
print("Hey Man") | ||
|
||
except(TypeError, AttributeError): | ||
print("Errory Man1") | ||
tvl_stats = Decimal(0); | ||
|
||
return tvl_stats; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def dollar_stats(start_date): | ||
try: | ||
Usd_stats = await models.Token_USD\ | ||
.filter(timestamp__gte=start_date)\ | ||
.order_by("timestamp")\ | ||
.first() | ||
|
||
dollar = Decimal(Usd_stats.price); | ||
|
||
except(TypeError, AttributeError): | ||
# print("Errory Dollar") | ||
dollar = Decimal(0); | ||
|
||
return dollar; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
|
||
async def history_dollar_stats(): | ||
try: | ||
Usd_stats = await models.Token_USD\ | ||
.all()\ | ||
.order_by("-timestamp")\ | ||
.first() | ||
|
||
dollar = Decimal(Usd_stats.price); | ||
|
||
except(TypeError, AttributeError): | ||
print("Errory Dollar1") | ||
dollar = Decimal(0); | ||
|
||
return dollar; |
Binary file added
BIN
+634 Bytes
demo/functions/Volume_stats/__pycache__/buy_sell_volume.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+671 Bytes
demo/functions/Volume_stats/__pycache__/buy_sell_volume.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+1.03 KB
demo/functions/Volume_stats/__pycache__/calculate_buy_volume_ctez.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+1.03 KB
demo/functions/Volume_stats/__pycache__/calculate_buy_volume_ctez.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+1.05 KB
demo/functions/Volume_stats/__pycache__/calculate_history_buy_volume.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+1.03 KB
demo/functions/Volume_stats/__pycache__/calculate_history_sell_volume.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+1.03 KB
demo/functions/Volume_stats/__pycache__/calculate_sell_volume_ctez.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+1.03 KB
demo/functions/Volume_stats/__pycache__/calculate_sell_volume_ctez.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+992 Bytes
demo/functions/Volume_stats/__pycache__/ctez_volume_days.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+995 Bytes
demo/functions/Volume_stats/__pycache__/ctez_volume_days.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+935 Bytes
demo/functions/Volume_stats/__pycache__/history_of_volume.cpython-310.pyc
Binary file not shown.
Binary file added
BIN
+938 Bytes
demo/functions/Volume_stats/__pycache__/history_of_volume.cpython-38.pyc
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
from datetime import timedelta, datetime | ||
|
||
async def buy_sell_volume_percentage(buy_sell_volume, token_volume): | ||
try: | ||
|
||
buy_sell_volume = float(float(float(buy_sell_volume)/float(token_volume))*100); | ||
except(TypeError, AttributeError, ZeroDivisionError, ValueError): | ||
print("Errory") | ||
buy_sell_volume = float(0); | ||
|
||
return buy_sell_volume; | ||
|
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from decimal import Decimal | ||
from pyexpat import model | ||
import demo.models as models | ||
from datetime import timedelta, datetime | ||
|
||
async def buy_volume_of_24hours(): | ||
timestamp_now = datetime.utcnow(); | ||
timestamp_yesteraday = timestamp_now - timedelta(hours=24) | ||
|
||
|
||
try: | ||
token_stats = await models.pricestats\ | ||
.filter(token_symbol='ctez')\ | ||
.order_by("-timestamp")\ | ||
.first() | ||
token_price = float(token_stats.ctez_price); | ||
token_trades = await models.Trade\ | ||
.filter(timestamp__gte = timestamp_yesteraday)\ | ||
.filter(timestamp__lte = timestamp_now)\ | ||
.filter(side_trade=1) | ||
|
||
volume = float(0.0001); | ||
for i in range(len(token_trades)): | ||
volume += float(token_trades[i].token_qty); | ||
|
||
volume_token = float(volume*token_price); | ||
except(TypeError, AttributeError): | ||
volume_token = float(0); | ||
|
||
return volume_token; |
Oops, something went wrong.