sukiboo commited on
Commit
96e8117
Β·
1 Parent(s): 895ecad

change axes and colors

Browse files
Files changed (3) hide show
  1. app.ipynb +1 -1
  2. src/constants.py +14 -1
  3. src/style_elements.py +5 -5
app.ipynb CHANGED
@@ -33,7 +33,7 @@
33
  " "
34
  ],
35
  "text/plain": [
36
- "<IPython.lib.display.IFrame at 0x1223e6960>"
37
  ]
38
  },
39
  "metadata": {},
 
33
  " "
34
  ],
35
  "text/plain": [
36
+ "<IPython.lib.display.IFrame at 0x13f63e960>"
37
  ]
38
  },
39
  "metadata": {},
src/constants.py CHANGED
@@ -1,9 +1,22 @@
1
  APP_INITIAL_TICKERS = ["QQQ", "SPY", "VTI", "VT"]
2
  APP_DATE_START = "2020-01-01"
3
  APP_INITIAL_INTERVAL_DAYS = 365
4
- APP_MAX_TICKERS = 8
5
 
6
  PRICES_RETRIEVAL_INTERVAL = "1d"
7
  PRICES_EPS = 1e-6
8
  PRICES_ROLLING_WINDOW = 251
9
  PRICES_ROLLING_MIN_PERIOD = 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  APP_INITIAL_TICKERS = ["QQQ", "SPY", "VTI", "VT"]
2
  APP_DATE_START = "2020-01-01"
3
  APP_INITIAL_INTERVAL_DAYS = 365
4
+ APP_MAX_TICKERS = 10
5
 
6
  PRICES_RETRIEVAL_INTERVAL = "1d"
7
  PRICES_EPS = 1e-6
8
  PRICES_ROLLING_WINDOW = 251
9
  PRICES_ROLLING_MIN_PERIOD = 1
10
+
11
+ COLORS = [
12
+ "#4488FF",
13
+ "#FF8844",
14
+ "#00AA88",
15
+ "#8844FF",
16
+ "#FF4488",
17
+ "#66CCFF",
18
+ "#FFCC66",
19
+ "#66FFCC",
20
+ "#CC66FF",
21
+ "#FF66CC",
22
+ ]
src/style_elements.py CHANGED
@@ -1,10 +1,10 @@
1
  import itertools
2
  from datetime import datetime
3
 
4
- import plotly.express as px
5
  import plotly.graph_objects as go
6
  from dash import dcc, html
7
 
 
8
  from src.utils import normalize_prices
9
 
10
 
@@ -112,7 +112,7 @@ def plot_prices(timestamps, prices, rolling_changes, idx_range):
112
  fig = go.Figure()
113
 
114
  # rangeslider plot
115
- colors = itertools.cycle(px.colors.qualitative.Set2)
116
  for asset in prices.columns:
117
  fig.add_trace(
118
  go.Scatter(
@@ -126,7 +126,7 @@ def plot_prices(timestamps, prices, rolling_changes, idx_range):
126
  )
127
 
128
  # main plot
129
- colors = itertools.cycle(px.colors.qualitative.Set2)
130
  for asset in prices_normalized.columns:
131
  y_values = 100 * prices_normalized[asset]
132
  formatted_values = [f"{val:+.2f}%" for val in y_values]
@@ -171,7 +171,7 @@ def plot_prices(timestamps, prices, rolling_changes, idx_range):
171
  autorange=True,
172
  title="relative price change",
173
  nticks=12,
174
- tickformat=".0f",
175
  ticksuffix="%",
176
  ticks="outside",
177
  )
@@ -180,7 +180,7 @@ def plot_prices(timestamps, prices, rolling_changes, idx_range):
180
  overlaying="y2",
181
  side="right",
182
  nticks=12,
183
- tickformat=".0f",
184
  ticksuffix="%",
185
  ticks="outside",
186
  )
 
1
  import itertools
2
  from datetime import datetime
3
 
 
4
  import plotly.graph_objects as go
5
  from dash import dcc, html
6
 
7
+ from src.constants import COLORS
8
  from src.utils import normalize_prices
9
 
10
 
 
112
  fig = go.Figure()
113
 
114
  # rangeslider plot
115
+ colors = itertools.cycle(COLORS)
116
  for asset in prices.columns:
117
  fig.add_trace(
118
  go.Scatter(
 
126
  )
127
 
128
  # main plot
129
+ colors = itertools.cycle(COLORS)
130
  for asset in prices_normalized.columns:
131
  y_values = 100 * prices_normalized[asset]
132
  formatted_values = [f"{val:+.2f}%" for val in y_values]
 
171
  autorange=True,
172
  title="relative price change",
173
  nticks=12,
174
+ tickformat="+d",
175
  ticksuffix="%",
176
  ticks="outside",
177
  )
 
180
  overlaying="y2",
181
  side="right",
182
  nticks=12,
183
+ tickformat="+d",
184
  ticksuffix="%",
185
  ticks="outside",
186
  )