Eru Ilúvatar bfbf1cc379
feat: analyze profits - closes #19 (#20)
* feat: analyze profits - closes #19

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

* feat: analyze profits - closes #19

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

* fix peotry lock

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

* feat: add save to csv option

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

* fix: update dockerfile to resolve deps automatically at build-time

Signed-off-by: Luca Georges Francois <luca@quartz.technology>

* feat: add porfit by day

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

* feat: add failures saving

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

* fix: launch script

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

* feat: get rpc url from env

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>
Signed-off-by: Luca Georges Francois <luca@quartz.technology>
Co-authored-by: Luca Georges Francois <luca@quartz.technology>
2023-01-16 07:00:21 +00:00

30 lines
836 B
Python

import pandas as pd
def read_from_db_all_into_dataframe(db_session, table, columns, where_clause):
"""
Reads all relevant rows from the DB as a df
:param db_session:
:param table:
:param columns:
:param where_clause:
:return:
"""
query = "SELECT " + columns + " FROM " + table
if where_clause != "":
query += " WHERE " + where_clause
result = db_session.execute(query)
return result
def read_profit_from_to(db_session, block_from, block_to):
where_clause = (
"block_number>=" + str(block_from) + " AND " + "block_number<=" + str(block_to)
)
profit = read_from_db_all_into_dataframe(
db_session, "total_profit_by_block", "*", where_clause
)
profit = pd.DataFrame(profit.fetchall())
profit = profit.drop(["id"], axis=1)
return profit