hotfix / Save session on oauth login (#5195)

* save session on oauth login

* avoid `asyncio.run` if in a running loop

* tests

* fix economy rtps
This commit is contained in:
teh_coderer
2023-07-04 17:08:16 -06:00
committed by GitHub
parent ecf7814ffd
commit 923327c321
7 changed files with 126 additions and 35 deletions

View File

@@ -35,7 +35,7 @@ class ProfileModel(BaseModel):
self.uuid = session.get("uuid", "")
self.email = email
self.username = session.get("username", None) or email.split("@").pop(0)
self.primary_usage = session.get("primary_usage", "")
self.primary_usage = session.get("primary_usage", None) or "personal"
self.remember = remember
def get_uuid(self) -> str:

View File

@@ -490,14 +490,14 @@ async def download_plotly_js():
print(f"Error downloading plotly.js: {err}")
# To avoid having plotly.js in the repo, we download it if it's not present
if not PLOTLYJS_PATH.exists() and not JUPYTER_NOTEBOOK:
asyncio.run(download_plotly_js())
def plots_backend() -> Backend:
"""Get the backend."""
global BACKEND # pylint: disable=W0603 # noqa
if BACKEND is None:
BACKEND = Backend()
return BACKEND
# To avoid having plotly.js in the repo, we download it if it's not present
if not PLOTLYJS_PATH.exists() and not JUPYTER_NOTEBOOK:
plots_backend().loop.run_until_complete(download_plotly_js())

View File

@@ -98,7 +98,12 @@ def pywry_login(welcome: bool = True):
):
response[new_key] = response.pop(r_key, None)
if remember := response.get("remember", False):
response["primary_usage"] = response.get("primary_usage", None) or "personal"
if remember := (
response.get("remember", False) or response.get("is_oauth", False)
):
response["remember"] = remember
Local.save_session(response)
return login_and_launch(response, remember)

View File

@@ -178,29 +178,35 @@
"metadata": {},
"outputs": [],
"source": [
"rtps_data = openbb.economy.rtps()\n",
"subplots = OpenBBFigure.create_subplots(1, 2, horizontal_spacing=0.15)\n",
"openbb.economy.rtps_chart(external_axes=True).to_subplot(subplots, 1, 1)\n",
"try:\n",
" rtps_data = openbb.economy.rtps()\n",
" subplots = OpenBBFigure.create_subplots(1, 2, horizontal_spacing=0.15)\n",
" openbb.economy.rtps_chart(external_axes=True).to_subplot(subplots, 1, 1)\n",
"\n",
"chg = futures[\"%Chg\"]\n",
"colors = [theme.up_color if x > 0 else theme.down_color for x in list(chg.values)]\n",
"subplots.add_bar(\n",
" y=chg.index,\n",
" x=chg.values,\n",
" orientation=\"h\",\n",
" marker_color=colors,\n",
" showlegend=False,\n",
" row=1,\n",
" col=2,\n",
")\n",
"subplots.update_xaxes(title_text=\"Performance (%)\", row=1, col=1)\n",
"subplots.update_xaxes(title_text=\"Change %\", row=1, col=2)\n",
"subplots.update_layout(\n",
" margin=dict(l=0, r=0, t=0, b=0),\n",
" yaxis=dict(side=\"left\", nticks=15),\n",
" yaxis2=dict(nticks=15),\n",
")\n",
"chart_0 = subplots.to_html()"
" chg = futures[\"%Chg\"]\n",
" colors = [theme.up_color if x > 0 else theme.down_color for x in list(chg.values)]\n",
" subplots.add_bar(\n",
" y=chg.index,\n",
" x=chg.values,\n",
" orientation=\"h\",\n",
" marker_color=colors,\n",
" showlegend=False,\n",
" row=1,\n",
" col=2,\n",
" )\n",
" subplots.update_xaxes(title_text=\"Performance (%)\", row=1, col=1)\n",
" subplots.update_xaxes(title_text=\"Change %\", row=1, col=2)\n",
" subplots.update_layout(\n",
" margin=dict(l=0, r=0, t=0, b=0),\n",
" yaxis=dict(side=\"left\", nticks=15),\n",
" yaxis2=dict(nticks=15),\n",
" )\n",
" chart_0 = subplots.to_html()\n",
"except Exception as e:\n",
" print(e)\n",
" chart_0 = \"\"\n",
" rtps_data = pd.DataFrame()\n",
" \n"
]
},
{

View File

@@ -1,7 +1,6 @@
Last Price
2023-06-01 4137.75
2023-09-01 4173.50
2023-12-01 4207.50
2024-03-01 4242.00
2024-06-01 4273.00
2023-09-01 4173.5
2023-12-01 4207.5
2024-03-01 4242.0
2024-06-01 4273.0

View File

@@ -3619,4 +3619,85 @@ interactions:
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
method: GET
uri: https://api.nasdaq.com/api/quote/OXY/option-chain/greeks?assetclass=stocks&date=2023-07-07
response:
body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T4eFW2Bp9ixgEaA4DVn0WZ9FJFsH0j6B5bwSsMwAFpKAZdHK09DarClFR1bC0mmfZcwemlKLZggL
XTxpElhad41XDwvyppS8bB1I9crSrERMYOmhspwS21AZNLIptU5lsLwTBV65WEc3sJw2+1CW3qIs
blNkn4VroSSwbAbLmCA7+K65eA/d6rR1sIPrDrcW8bRNYOmuM0thdadj6jGAEbBMsg1pXQY+HdaW
6w6jMFJZ3AhlysoKPKCXsND2fRaHrlJlDa47XN6tbErRkITlIG9KucRnHXyvLHLozB5gra87f/GV
+vukabsvCfhW3VR3dXT0bTUdaXUwQlYb38BfqmYVb/hxWCpb6jXn3roZuR3Gjn8Hxnzk7bIGGlhz
Rd9ljTC09rutvbA+WT2MdgXiS0UDY9gViC8Bhta7AmFrGch1PR/xftluHUowwvpy3LLldmtQJcp3
89vsZQQ7Xg5ACfLlnNbjnZEA5pF8q6Yjrh3RmqQ1lYrXDsL65/puxHtvuzWvbSXB+WL32pSvHfX6
LpOhtR3IJMa9ZmKktenizgU73fAeWtuOd9xGz/VyWT3Um6/elm3Vrrpv3hY/ze55GmOluIv/X0jL
+/qlbmbzeiHm397+Bar8G+L9EwAA
headers:
Cache-Control:
- max-age=0, no-cache, no-store
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Length:
- '1275'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 04 Jul 2023 20:08:49 GMT
Expires:
- Tue, 04 Jul 2023 20:08:49 GMT
Pragma:
- no-cache
Server:
- Kestrel
Set-Cookie:
- ak_bmsc=CA48A533C03E0AB2A41A8D97062CF8CC~000000000000000000000000000000~YAAQhZTYF28GQBaJAQAAwp2FIhRdz367h0Ji8WTTdZSoEFsqSCvXO790g4NFi2qD5zcoNgxmcBbWBjrXS9SEuLNFDn95C/GDserdhsQErPwoxFAK9lKFj87cMQd9CUhIJ899pQcCiL+nr+ZdebD5ITC47/qdJPVb3gHbI/Zjdc3LlbY+pUjiIIUlQSeV/VXROpFyvFYCeCZuq8KMbUG3yWADY9FAAuqtKkWJxYe0yfn3Lwg1GpXEVXeXAbTVoFagHewEYAw4gRAQ8YNvozFClD7PcYJx/9BuovcauM99kqeaJgssAXIZDnyGBtKriFTPCjeLVKAxEbz+Inv64Wn7jlx/A+zfeWEljW21k6KdIPNlobhe6rqiMJnpxVc=;
Domain=.nasdaq.com; Path=/; Expires=Tue, 04 Jul 2023 22:08:48 GMT; Max-Age=7199;
HttpOnly
Strict-Transport-Security:
- max-age=86400
Vary:
- Accept-Encoding
X-EdgeConnect-MidMile-RTT:
- '1'
- '54'
X-EdgeConnect-Origin-MEX-Latency:
- '558'
- '558'
gid:
- '203'
lang:
- en
rid:
- 4f45a04f-62f4-4363-b113-406929761c89
srctype:
- default
status:
code: 200
message: OK
version: 1

View File

@@ -1 +1 @@
["Long Straddle", "Long Strangle", "Long Strangle", "Long Strangle", "Bull Call Spread", "Bear Put Spread", "Long Straddle", "Long Strangle", "Long Strangle", "Long Strangle", "Bull Call Spread", "Bear Put Spread", "Long Straddle", "Long Strangle", "Long Strangle", "Long Strangle", "Bull Call Spread", "Bear Put Spread", "Long Straddle", "Long Strangle", "Long Strangle", "Long Strangle", "Bull Call Spread", "Bear Put Spread"]
["Long Straddle", "Long Strangle", "Long Strangle", "Long Strangle", "Bull Call Spread", "Bear Put Spread", "Long Straddle", "Long Strangle", "Long Strangle", "Long Strangle", "Bull Call Spread", "Bear Put Spread", "Long Straddle", "Long Strangle", "Long Strangle", "Long Strangle", "Bull Call Spread", "Bear Put Spread"]