Skip to content

Commit

Permalink
ctez-Indexer added
Browse files Browse the repository at this point in the history
  • Loading branch information
Karantezsure committed May 26, 2022
1 parent 0821947 commit a60eadf
Show file tree
Hide file tree
Showing 272 changed files with 10,235 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Dockerfile
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 added demo.sqlite3
Binary file not shown.
Empty file added demo/__init__.py
Empty file.
Binary file added demo/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added demo/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file added demo/__pycache__/backups.cpython-38.pyc
Binary file not shown.
Binary file added demo/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added demo/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 18 additions & 0 deletions demo/functions/Main_stats/history_main.py
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;
16 changes: 16 additions & 0 deletions demo/functions/Main_stats/main_history.py
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 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.
17 changes: 17 additions & 0 deletions demo/functions/Price_stats/block_level.py
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;
24 changes: 24 additions & 0 deletions demo/functions/Price_stats/change_price.py
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;
24 changes: 24 additions & 0 deletions demo/functions/Price_stats/change_price_history.py
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;
18 changes: 18 additions & 0 deletions demo/functions/Price_stats/history_block_level.py
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;
16 changes: 16 additions & 0 deletions demo/functions/Price_stats/history_of_price.py
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;
16 changes: 16 additions & 0 deletions demo/functions/Price_stats/price_stats.py
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 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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions demo/functions/Tvl_stats/calculate_history_pool.py
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;
19 changes: 19 additions & 0 deletions demo/functions/Tvl_stats/calculate_history_tvl.py
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;
21 changes: 21 additions & 0 deletions demo/functions/Tvl_stats/calculate_pool_history.py
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;
17 changes: 17 additions & 0 deletions demo/functions/Tvl_stats/calculate_tvl.py
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;
21 changes: 21 additions & 0 deletions demo/functions/Tvl_stats/calculate_tvl_history.py
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;
18 changes: 18 additions & 0 deletions demo/functions/Tvl_stats/dollar.py
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;
18 changes: 18 additions & 0 deletions demo/functions/Tvl_stats/history_dollar.py
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 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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions demo/functions/Volume_stats/buy_sell_volume.py
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;

30 changes: 30 additions & 0 deletions demo/functions/Volume_stats/calculate_buy_volume_ctez.py
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;
Loading

0 comments on commit a60eadf

Please sign in to comment.