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

22 lines
622 B
Python

import datetime
import pandas as pd
from profit_analysis.column_names import BLOCK_KEY, TIMESTAMP_KEY
def add_block_timestamp(w3, profit_by_block):
block_timestamp = pd.DataFrame(
profit_by_block[BLOCK_KEY].unique(), columns=[BLOCK_KEY]
)
block_timestamp[TIMESTAMP_KEY] = block_timestamp[BLOCK_KEY].apply(
lambda x: get_block_timestamp(w3, x)
)
return profit_by_block.merge(block_timestamp, on=BLOCK_KEY)
def get_block_timestamp(w3, block):
block_info = w3.eth.get_block(int(block))
ts = block_info[TIMESTAMP_KEY]
dt = datetime.datetime.fromtimestamp(ts)
return dt