Skip to content

Commit

Permalink
Improved data saving for visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
golden-lucky-monkey committed Jun 28, 2022
1 parent cb2ff91 commit 1614399
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion orderbook-delta-visualizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ This will start a dash server, which you can open in your browser.

### To modify parameters
- All parameters are stored in `parameters.py/Parameters`
- All parameters can be updated live, the server will restart automatically
- All parameters can be updated live, the server will restart automatically
- Running the visualizer generates saves a time series (`pandas.DataFrame`) of all observed data on exit
16 changes: 12 additions & 4 deletions orderbook-delta-visualizer/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
from strategy import BaseStrategy, BollingerBandStrategy


def get_formatted_filepath(folder: str, base_filename: str, spot_market: str, perp_future: str) -> str:
""" Example output filename: 2022-06-28_08-52-21_BTC-USD_BTC-PERP_orderbook_delta_logger.csv """
filename = f"{datetime.datetime.utcnow().strftime('%Y-%m-%d_%H-%M-%S')}_{'-'.join(spot_market.split('/'))}_" \
f"{'-'.join(perp_future.split('-'))}_{base_filename}.csv"
return os.path.join(folder, filename)


@dataclass(frozen=True)
class Parameters:
""" Parameters to use when running visualizer """
Expand All @@ -22,8 +29,9 @@ class Parameters:
# Size of window in pixels
window_size: (int, int) = (1400, 850)
# Log live data to a csv file, use False to disable
logfile: Union[str, bool] = os.path.join(
"data",
f"{datetime.datetime.utcnow().strftime('%Y-%m-%d_%H-%M-%S')}_orderbook_delta_logger_"
f"{'_'.join(spot_market.split('/'))}_{'_'.join(perp_future.split('-'))}.csv"
logfile: Union[str, bool] = get_formatted_filepath(
folder="data",
base_filename="orderbook_delta_logger",
spot_market=spot_market,
perp_future=perp_future
)

0 comments on commit 1614399

Please sign in to comment.