-
Notifications
You must be signed in to change notification settings - Fork 21
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
Showing
7 changed files
with
56 additions
and
45 deletions.
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
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
"""Dashboard utilities""" | ||
|
||
from .build_fixed_rate import build_fixed_rate | ||
from .build_leaderboard import build_leaderboard | ||
from .build_ohlcv import build_ohlcv | ||
from .build_ticker import build_ticker | ||
from .extract_data_logs import get_combined_data, read_json_to_pd | ||
from .plot_fixed_rate import plot_fixed_rate | ||
from .plot_ohlcv import calc_ohlcv, plot_ohlcv | ||
from .plot_ohlcv import plot_ohlcv | ||
from .usernames import address_to_username, combine_usernames, get_user_lookup |
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,3 @@ | ||
def build_fixed_rate(pool_analysis): | ||
fixed_rate = pool_analysis[["timestamp", "fixed_rate"]] | ||
return fixed_rate |
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,27 @@ | ||
from decimal import Decimal | ||
|
||
import pandas as pd | ||
|
||
|
||
def build_ohlcv(pool_analysis, freq="D"): | ||
""" | ||
freq var: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases | ||
""" | ||
# TODO get volume from pool_analysis | ||
# fixme hacking it in for now | ||
pool_analysis["trade_volume"] = Decimal(1) | ||
|
||
spot_prices = pool_analysis[["timestamp", "spot_price", "trade_volume"]].copy() | ||
spot_prices = spot_prices.set_index("timestamp") | ||
|
||
# TODO this is filling groups without data with nans, is this desired? | ||
ohlcv = spot_prices.groupby([pd.Grouper(freq=freq)]).agg( | ||
{"spot_price": ["first", "last", "max", "min"], "trade_volume": "sum"} | ||
) | ||
|
||
ohlcv.columns = ["Open", "Close", "High", "Low", "Volume"] | ||
ohlcv.index.name = "Date" | ||
# ohlcv must be floats | ||
ohlcv = ohlcv.astype(float) | ||
|
||
return ohlcv |
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
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
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