mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-06 09:22:26 +00:00
Docs/byod (#5996)
* add byod to reference * fix: rename add-in name * feat: add data conectors page * fix: additional notes * tiny tweaks * update functions.json and openapi.json * fix: fix bug in hedge controller * fix: another bug hedgecontroller * black --------- Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
This commit is contained in:
@@ -49,26 +49,40 @@ class HedgeController(BaseController):
|
||||
|
||||
self.underlying_asset_position: str = ""
|
||||
self.chain = get_option_chain(ticker, expiration)
|
||||
self.calls = list(
|
||||
zip(
|
||||
self.chain.calls["strike"].tolist(),
|
||||
self.chain.calls["impliedVolatility"].tolist(),
|
||||
self.chain.calls["lastPrice"].tolist(),
|
||||
self.chain.calls["currency"].tolist(),
|
||||
self.calls = (
|
||||
list(
|
||||
zip(
|
||||
self.chain.calls["strike"].tolist(),
|
||||
self.chain.calls["impliedVolatility"].tolist(),
|
||||
self.chain.calls["lastPrice"].tolist(),
|
||||
self.chain.calls["currency"].tolist(),
|
||||
)
|
||||
)
|
||||
if "calls" in self.chain.columns
|
||||
else []
|
||||
)
|
||||
self.puts = list(
|
||||
zip(
|
||||
self.chain.puts["strike"].tolist(),
|
||||
self.chain.puts["impliedVolatility"].tolist(),
|
||||
self.chain.puts["lastPrice"].tolist(),
|
||||
self.chain.calls["currency"].tolist(),
|
||||
self.puts = (
|
||||
list(
|
||||
zip(
|
||||
self.chain.puts["strike"].tolist(),
|
||||
self.chain.puts["impliedVolatility"].tolist(),
|
||||
self.chain.puts["lastPrice"].tolist(),
|
||||
self.chain.calls["currency"].tolist(),
|
||||
)
|
||||
)
|
||||
if "puts" in self.chain.columns
|
||||
else []
|
||||
)
|
||||
|
||||
start = self.calls[0] if self.calls else 0
|
||||
end = self.calls[-1] if self.calls else 0
|
||||
|
||||
start = int(start[0]) if isinstance(start, list) and start else 0
|
||||
end = int(end[0]) if isinstance(end, list) and end else 0
|
||||
|
||||
self.PICK_CHOICES = [
|
||||
f"{strike} {position} {side}"
|
||||
for strike in range(int(self.calls[0][0]), int(self.calls[-1][0]), 5)
|
||||
for strike in range(start, end, 5)
|
||||
for position in ["Long", "Short"]
|
||||
for side in ["Call", "Put"]
|
||||
]
|
||||
@@ -76,7 +90,11 @@ class HedgeController(BaseController):
|
||||
self.ticker = ticker
|
||||
self.current_price: float = get_price(ticker)
|
||||
self.expiration = expiration
|
||||
self.implied_volatility = self.chain.calls["impliedVolatility"]
|
||||
self.implied_volatility = (
|
||||
self.chain.calls.get("impliedVolatility", 0.0)
|
||||
if "calls" in self.chain.columns
|
||||
else 0.0
|
||||
)
|
||||
self.options: Dict = {"Portfolio": {}, "Option A": {}, "Option B": {}}
|
||||
self.underlying = 0.0
|
||||
self.side: str = ""
|
||||
|
||||
36
website/content/excel/data-conectors.md
vendored
Normal file
36
website/content/excel/data-conectors.md
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: Data connectors
|
||||
sidebar_position: 4
|
||||
description: Access your data connectors from OpenBB Terminal Pro inside OpenBB Add-in for Excel.
|
||||
keywords:
|
||||
- Microsoft Excel
|
||||
- Add-in
|
||||
- Advanced
|
||||
- Data connectors
|
||||
- BYOD
|
||||
- Bring your own data
|
||||
---
|
||||
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
|
||||
|
||||
<HeadTitle title="Data connectors | OpenBB Add-in for Excel Docs" />
|
||||
|
||||
OpenBB Add-In for Excel allows you to access your [data connectors](https://docs.openbb.co/pro/main-menu/data-connectors) from OpenBB Terminal Pro inside Microsoft Excel.
|
||||
|
||||
To access data from a [single widget](https://docs.openbb.co/pro/main-menu/data-connectors/single-widget) use:
|
||||
|
||||
```excel
|
||||
=OBB.BYOD("widget_name")
|
||||
```
|
||||
|
||||
To access data from your own [backend](https://docs.openbb.co/pro/main-menu/data-connectors/integrate-your-own-backend) use:
|
||||
|
||||
```excel
|
||||
=OBB.BYOD("widget_name", "backend_name")
|
||||
```
|
||||
|
||||
#### Additional notes
|
||||
|
||||
- Make sure your backend's CORS settings allow requests coming from <https://excel.openbb.co>.
|
||||
- Requests via HTTP will be blocked by Excel. So if you are using the Add-in for Excel on Mac or Office on the web with Safari browser you need to run your backend via HTTPS.
|
||||
98
website/content/excel/functions.json
vendored
98
website/content/excel/functions.json
vendored
@@ -1,5 +1,27 @@
|
||||
{
|
||||
"functions": [
|
||||
{
|
||||
"description": "Bring Your Own Data features from OpenBB Terminal Pro.",
|
||||
"helpUrl": "https://docs.openbb.co/excel/data-conectors",
|
||||
"id": "BYOD",
|
||||
"name": "BYOD",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Name of the widget to get data for.",
|
||||
"name": "widget",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Name of the backend to use, required for widgets in custom backends.",
|
||||
"name": "backend",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"dimensionality": "matrix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Cryptocurrency Historical Price. Cryptocurrency historical price data.",
|
||||
"helpUrl": "https://docs.openbb.co/excel/reference/crypto/price/historical",
|
||||
@@ -1316,6 +1338,18 @@
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Start date of the data, in YYYY-MM-DD format.",
|
||||
"name": "start_date",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "End date of the data, in YYYY-MM-DD format.",
|
||||
"name": "end_date",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Options: fmp, intrinio, defaults to fmp.",
|
||||
"name": "provider",
|
||||
@@ -1324,7 +1358,7 @@
|
||||
},
|
||||
{
|
||||
"description": "The number of data entries to return. (provider: intrinio)",
|
||||
"name": "page_size",
|
||||
"name": "limit",
|
||||
"optional": true,
|
||||
"type": "number"
|
||||
}
|
||||
@@ -1385,6 +1419,12 @@
|
||||
"optional": true,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"description": "Sort the data in ascending or descending order. (provider: fmp)",
|
||||
"name": "sort",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Start date of the data, in YYYY-MM-DD format. (provider: intrinio)",
|
||||
"name": "start_date",
|
||||
@@ -1745,6 +1785,18 @@
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Start date of the data, in YYYY-MM-DD format.",
|
||||
"name": "start_date",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "End date of the data, in YYYY-MM-DD format.",
|
||||
"name": "end_date",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Options: fmp, defaults to fmp.",
|
||||
"name": "provider",
|
||||
@@ -2040,6 +2092,12 @@
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "The number of data entries to return. Default is 252, the number of trading days in a year.",
|
||||
"name": "limit",
|
||||
"optional": true,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"description": "Options: tiingo, defaults to tiingo.",
|
||||
"name": "provider",
|
||||
@@ -2227,6 +2285,12 @@
|
||||
"name": "provider",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "Include current quarter data. (provider: fmp)",
|
||||
"name": "include_current_quarter",
|
||||
"optional": true,
|
||||
"type": "boolean"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
@@ -2430,7 +2494,7 @@
|
||||
"name": "EQUITY.PRICE.QUOTE",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Symbol to get data for. In this case, the comma separated list of symbols.",
|
||||
"description": "Symbol to get data for. This endpoint will accept multiple symbols separated by commas.",
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
},
|
||||
@@ -3723,7 +3787,7 @@
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"description": "Options: benzinga, fmp, intrinio, polygon, tiingo, defaults to benzinga.",
|
||||
"description": "Options: benzinga, fmp, intrinio, polygon, tiingo, ultima, defaults to benzinga.",
|
||||
"name": "provider",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
@@ -3835,6 +3899,34 @@
|
||||
"dimensionality": "matrix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Sector News. Get news for one or more sectors.",
|
||||
"helpUrl": "https://docs.openbb.co/excel/reference/news/sector",
|
||||
"id": "NEWS.SECTOR",
|
||||
"name": "NEWS.SECTOR",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "A coma separated list of sectors.",
|
||||
"name": "sectors",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "The number of data entries to return. Here it is the no. of articles to return.",
|
||||
"name": "limit",
|
||||
"optional": true,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"description": "Options: ultima, defaults to ultima.",
|
||||
"name": "provider",
|
||||
"optional": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"dimensionality": "matrix"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "World News. Global news data.",
|
||||
"helpUrl": "https://docs.openbb.co/excel/reference/news/world",
|
||||
|
||||
@@ -14,7 +14,7 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
|
||||
|
||||
<HeadTitle title="Basics | OpenBB Add-in for Excel Docs" />
|
||||
|
||||
The OpenBB Excel Add-in provides direct access to the OpenBB platform, where each function implements the following pattern:
|
||||
The OpenBB Add-in for Excel provides direct access to the OpenBB platform, where each function implements the following pattern:
|
||||
|
||||
- `OBB.[MENU].[SUB_MENU].[COMMAND]`
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
|
||||
<HeadTitle title="Installation | OpenBB Add-in for Excel Docs" />
|
||||
|
||||
## Requirements
|
||||
- The OpenBB Excel Add-in is available on the following platforms: Windows (Microsoft 365), Mac (Microsoft 365), Excel on the web.
|
||||
- The OpenBB Add-in for Excel is available on the following platforms: Windows (Microsoft 365), Mac (Microsoft 365), Excel on the web.
|
||||
- Access to the OpenBB Terminal Pro. If you don't have access you can sign up for the waitlist [here](https://my.openbb.co/app/pro).
|
||||
|
||||
## Installation
|
||||
@@ -27,7 +27,7 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
|
||||
/>
|
||||
</div>
|
||||
|
||||
The OpenBB Excel Add-in is available on the [Microsoft AppSource](https://appsource.microsoft.com/pt-pt/product/office/wa200006381?tab=overview). It can be installed by an administrator or by individual users.
|
||||
The OpenBB Add-in for Excel is available on the [Microsoft AppSource](https://appsource.microsoft.com/pt-pt/product/office/wa200006381?tab=overview). It can be installed by an administrator or by individual users.
|
||||
|
||||
### Individual user
|
||||
|
||||
|
||||
5333
website/content/excel/openapi.json
vendored
5333
website/content/excel/openapi.json
vendored
File diff suppressed because it is too large
Load Diff
4
website/content/excel/templates.mdx
vendored
4
website/content/excel/templates.mdx
vendored
@@ -1,7 +1,7 @@
|
||||
---
|
||||
title: Templates
|
||||
sidebar_position: 4
|
||||
description: OpenBB Excel Add-In offered by OpenBB. These templates are designed to help you perform a variety of tasks, from equity analysis to economic analysis. They can be used as-is or customized to suit your needs.
|
||||
description: OpenBB Add-In for Excel offered by OpenBB. These templates are designed to help you perform a variety of tasks, from equity analysis to economic analysis. They can be used as-is or customized to suit your needs.
|
||||
keywords:
|
||||
- Microsoft Excel
|
||||
- Add-in
|
||||
@@ -14,7 +14,7 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
|
||||
|
||||
<HeadTitle title="Templates | OpenBB Add-in for Excel Docs" />
|
||||
|
||||
OpenBB Excel Add-In offered by OpenBB. These templates are designed to help you perform a variety of tasks, from equity analysis to economic analysis. They can be used as-is or customized to suit your needs.
|
||||
OpenBB Add-In for Excel offered by OpenBB. These templates are designed to help you perform a variety of tasks, from equity analysis to economic analysis. They can be used as-is or customized to suit your needs.
|
||||
|
||||
These can be downloaded in the [OpenBB Hub](https://my.openbb.co).
|
||||
|
||||
|
||||
@@ -55,4 +55,3 @@ The language-agnostic API approach offers flexibility by allowing you to use the
|
||||
### Quick Start with Python and FastAPI
|
||||
|
||||
Our team has created several examples that you can use to quickly get started with Python and FastAPI. For more information, check [this open source repository](https://github.com/OpenBB-finance/backend-for-terminal-pro/tree/main) for examples.
|
||||
e
|
||||
|
||||
@@ -33,6 +33,9 @@ class CommandLib:
|
||||
|
||||
# These examples will be generated in the core, but we keep them here meanwhile
|
||||
EXAMPLE_PARAMS: Dict[str, Dict] = {
|
||||
"/byod": {
|
||||
"widget": '"widget_name"',
|
||||
},
|
||||
"crypto": {
|
||||
"symbol": '"BTCUSD"',
|
||||
"start_date": '"2023-01-01"',
|
||||
@@ -200,7 +203,12 @@ class CommandLib:
|
||||
|
||||
def _get_data(self, cmd: str) -> dict:
|
||||
"""Get the data of the command from the openapi."""
|
||||
model = self.openapi["paths"][f"/api/v1{cmd}"]["get"]["model"]
|
||||
model = (
|
||||
self.openapi.get("paths", {})
|
||||
.get(f"/api/v1{cmd}", {})
|
||||
.get("get", {})
|
||||
.get("model")
|
||||
)
|
||||
if model:
|
||||
schema = self.openapi["components"]["schemas"][model]["properties"]
|
||||
data = {}
|
||||
@@ -324,53 +332,58 @@ class Editor:
|
||||
return description
|
||||
|
||||
def get_syntax() -> str:
|
||||
sig = cmd_info["signature"]
|
||||
syntax = "## Syntax\n\n"
|
||||
syntax += f"```{self.interface} wordwrap\n"
|
||||
syntax += f"{sig}\n"
|
||||
syntax += "```\n\n"
|
||||
return syntax
|
||||
if sig := cmd_info["signature"]:
|
||||
syntax = "## Syntax\n\n"
|
||||
syntax += f"```{self.interface} wordwrap\n"
|
||||
syntax += f"{sig}\n"
|
||||
syntax += "```\n\n"
|
||||
return syntax
|
||||
return ""
|
||||
|
||||
def get_parameters() -> str:
|
||||
parameters = "## Parameters\n\n"
|
||||
parameters += "| Name | Type | Description | Required |\n"
|
||||
parameters += "| ---- | ---- | ----------- | -------- |\n"
|
||||
for field_name, field_info in cmd_info["parameters"].items():
|
||||
name = field_name
|
||||
type_ = field_info["type"]
|
||||
description = field_info["description"]
|
||||
required = field_info["required"]
|
||||
required_str = str(required).title()
|
||||
if required:
|
||||
parameters += f"| **{name}** | **{type_}** | **{description}** | **{required_str}** |\n"
|
||||
else:
|
||||
parameters += (
|
||||
f"| {name} | {type_} | {description} | {required_str} |\n"
|
||||
)
|
||||
|
||||
parameters += "\n"
|
||||
return parameters
|
||||
if parameter_schema := cmd_info["parameters"]:
|
||||
parameters = "## Parameters\n\n"
|
||||
parameters += "| Name | Type | Description | Required |\n"
|
||||
parameters += "| ---- | ---- | ----------- | -------- |\n"
|
||||
for field_name, field_info in parameter_schema.items():
|
||||
name = field_name
|
||||
type_ = field_info["type"]
|
||||
description = field_info["description"]
|
||||
required = field_info["required"]
|
||||
required_str = str(required).title()
|
||||
if required:
|
||||
parameters += f"| **{name}** | **{type_}** | **{description}** | **{required_str}** |\n"
|
||||
else:
|
||||
parameters += (
|
||||
f"| {name} | {type_} | {description} | {required_str} |\n"
|
||||
)
|
||||
parameters += "\n"
|
||||
return parameters
|
||||
return ""
|
||||
|
||||
def get_return_data() -> str:
|
||||
data = "## Return Data\n\n"
|
||||
data += "| Name | Description |\n"
|
||||
data += "| ---- | ----------- |\n"
|
||||
for field_name, field_info in cmd_info["data"].items():
|
||||
name = field_name
|
||||
description = field_info["description"]
|
||||
data += f"| {name} | {description} |\n"
|
||||
return data
|
||||
if data_schema := cmd_info["data"]:
|
||||
data = "## Return Data\n\n"
|
||||
data += "| Name | Description |\n"
|
||||
data += "| ---- | ----------- |\n"
|
||||
for field_name, field_info in data_schema.items():
|
||||
name = field_name
|
||||
description = field_info["description"]
|
||||
data += f"| {name} | {description} |\n"
|
||||
return data
|
||||
return ""
|
||||
|
||||
def get_examples() -> str:
|
||||
examples = "### Example\n\n"
|
||||
if cmd_examples := cmd_info["examples"]:
|
||||
examples = "### Example\n\n"
|
||||
for _, v in cmd_examples.items():
|
||||
# examples += f"### {k}\n\n"
|
||||
examples += f"```{self.interface} wordwrap\n"
|
||||
examples += f"{v}\n"
|
||||
examples += "```\n\n"
|
||||
|
||||
for _, v in cmd_info["examples"].items():
|
||||
# examples += f"### {k}\n\n"
|
||||
examples += f"```{self.interface} wordwrap\n"
|
||||
examples += f"{v}\n"
|
||||
examples += "```\n\n"
|
||||
|
||||
return examples
|
||||
return examples
|
||||
return ""
|
||||
|
||||
content = get_header()
|
||||
content += get_head_title()
|
||||
|
||||
4
website/src/pages/index.tsx
vendored
4
website/src/pages/index.tsx
vendored
@@ -53,10 +53,10 @@ export default function Home(): JSX.Element {
|
||||
className="!bg-grey-900 bg-[url('/img/excelbg.png')] bg-no-repeat shadow-sm group !no-underline text-white dark:hover:border-white hover:border-grey-600/80 relative w-full h-[238px] max-w-full p-8 rounded flex flex-col items-start justify-start border border-grey-300 hover:!text-white"
|
||||
>
|
||||
<h3 className="uppercase tracking-widest font-bold mb-0 mt-0 text-white">
|
||||
OpenBB Excel Add-In
|
||||
OpenBB Add-In for Excel
|
||||
</h3>
|
||||
<p className="text-sm lg:text-base text-grey-300">
|
||||
The OpenBB Excel Add-In allows access to the same data as the OpenBB Terminal Pro, but through Excel.
|
||||
The OpenBB Add-In for Excel allows access to the same data as the OpenBB Terminal Pro, but through Excel.
|
||||
</p>
|
||||
<p
|
||||
className={clsx(
|
||||
|
||||
Reference in New Issue
Block a user