use duckdb
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ from datetime import datetime, timedelta
|
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
import duckdb
|
|
|
5 |
from tabs.trades import (
|
6 |
prepare_trades,
|
7 |
get_overall_trades,
|
@@ -26,6 +27,19 @@ from tabs.error import (
|
|
26 |
from tabs.about import about_olas_predict
|
27 |
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def get_last_two_months_data():
|
30 |
con = duckdb.connect(':memory:')
|
31 |
two_months_ago = (datetime.now() - timedelta(days=60)).strftime('%Y-%m-%d')
|
@@ -40,11 +54,12 @@ def get_last_two_months_data():
|
|
40 |
FROM read_parquet('./data/all_trades_profitability.parquet')
|
41 |
WHERE creation_timestamp >= '{two_months_ago}'
|
42 |
"""
|
43 |
-
|
|
|
44 |
df2 = con.execute(query2).fetchdf()
|
45 |
-
|
46 |
df1 = con.execute(query1).fetchdf()
|
47 |
-
|
48 |
con.close()
|
49 |
return df1, df2
|
50 |
|
|
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
import duckdb
|
5 |
+
import logging
|
6 |
from tabs.trades import (
|
7 |
prepare_trades,
|
8 |
get_overall_trades,
|
|
|
27 |
from tabs.about import about_olas_predict
|
28 |
|
29 |
|
30 |
+
def get_logger():
|
31 |
+
logger = logging.getLogger(__name__)
|
32 |
+
logger.setLevel(logging.DEBUG)
|
33 |
+
# stream handler and formatter
|
34 |
+
stream_handler = logging.StreamHandler()
|
35 |
+
stream_handler.setLevel(logging.DEBUG)
|
36 |
+
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
37 |
+
stream_handler.setFormatter(formatter)
|
38 |
+
logger.addHandler(stream_handler)
|
39 |
+
return logger
|
40 |
+
|
41 |
+
logger = get_logger()
|
42 |
+
|
43 |
def get_last_two_months_data():
|
44 |
con = duckdb.connect(':memory:')
|
45 |
two_months_ago = (datetime.now() - timedelta(days=60)).strftime('%Y-%m-%d')
|
|
|
54 |
FROM read_parquet('./data/all_trades_profitability.parquet')
|
55 |
WHERE creation_timestamp >= '{two_months_ago}'
|
56 |
"""
|
57 |
+
logger.info("Query 1: " + query1)
|
58 |
+
logger.info("Query 2: " + query2)
|
59 |
df2 = con.execute(query2).fetchdf()
|
60 |
+
logger.info("here2")
|
61 |
df1 = con.execute(query1).fetchdf()
|
62 |
+
logger.info("here3")
|
63 |
con.close()
|
64 |
return df1, df2
|
65 |
|