-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
1 parent
60ff2bd
commit aeeae61
Showing
11 changed files
with
2,252 additions
and
0 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
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,14 @@ | ||
# OpenBB Biztoc Provider | ||
|
||
This extension integrates the Biztoc data provider | ||
into the OpenBB Platform. | ||
|
||
## Installation | ||
|
||
To install the extension, run the following command in this folder: | ||
|
||
```bash | ||
pip install openbb-biztoc | ||
``` | ||
|
||
Documentation available [here](https://docs.openbb.co/platform/development/contributing). |
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 @@ | ||
"""Biztoc provider.""" |
24 changes: 24 additions & 0 deletions
24
openbb_platform/providers/binance/openbb_binance/__init__.py
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,24 @@ | ||
"""Biztoc provider module.""" | ||
|
||
from openbb_binance.models.crypto_historical import BinanceStreamFetcher | ||
from openbb_core.provider.abstract.provider import Provider | ||
|
||
binance_provider = Provider( | ||
name="binance", | ||
website="https://api.binance.com", | ||
description="""BizToc uses Rapid API for its REST API. | ||
You may sign up for your free account at https://rapidapi.com/thma/api/binance. | ||
The Base URL for all requests is: | ||
https://binance.p.rapidapi.com/ | ||
If you're not a developer but would still like to use Biztoc outside of the main website, | ||
we've partnered with OpenBB, allowing you to pull in BizToc's news stream in their Terminal.""", | ||
# credentials=["api_key"], | ||
fetcher_dict={ | ||
"bcrypto_historical": BinanceStreamFetcher, | ||
}, | ||
repr_name="Binance", | ||
instructions="The BizToc API is hosted on RapidAPI. To set up, go to: https://rapidapi.com/thma/api/binance.\n\n![binance0](https://github.com/marban/OpenBBTerminal/assets/18151143/04cdd423-f65e-4ad8-ad5a-4a59b0f5ddda)\n\nIn the top right, select 'Sign Up'. After answering some questions, you will be prompted to select one of their plans.\n\n![binance1](https://github.com/marban/OpenBBTerminal/assets/18151143/9f3b72ea-ded7-48c5-aa33-bec5c0de8422)\n\nAfter signing up, navigate back to https://rapidapi.com/thma/api/binance. If you are logged in, you will see a header called X-RapidAPI-Key.\n\n![binance2](https://github.com/marban/OpenBBTerminal/assets/18151143/0f3b6c91-07e0-447a-90cd-a9e23522929f)", # noqa: E501 pylint: disable=line-too-long | ||
) |
1 change: 1 addition & 0 deletions
1
openbb_platform/providers/binance/openbb_binance/models/__init__.py
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 @@ | ||
"""Biztoc Provider models.""" |
61 changes: 61 additions & 0 deletions
61
openbb_platform/providers/binance/openbb_binance/models/crypto_historical.py
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,61 @@ | ||
"""Binance Crypto Historical WS Data.""" | ||
|
||
import json | ||
from datetime import datetime | ||
from typing import Any, Dict, Optional | ||
|
||
from openbb_core.provider.standard_models.crypto_historical import ( | ||
CryptoHistoricalData, | ||
) | ||
from pydantic import Field | ||
|
||
from openbb_platform.core.openbb_core.provider.abstract.fetcher import StreamFetcher | ||
|
||
# pylint: disable=unused-kwargs | ||
|
||
|
||
class BinanceCryptoHistoricalData(CryptoHistoricalData): | ||
"""Binance Crypto Historical Data.""" | ||
|
||
__alias_dict__ = { | ||
"symbol": "s", | ||
"close": "c", | ||
"open": "o", | ||
"high": "h", | ||
"low": "l", | ||
"volume": "v", | ||
} | ||
event_type: Optional[str] = Field( | ||
default=None, | ||
description="Event type", | ||
alias="e", | ||
) | ||
quote_asset_volume: Optional[str] = Field( | ||
default=None, | ||
description="Total traded quote asset volume", | ||
alias="q", | ||
) | ||
|
||
|
||
class BinanceStreamFetcher(StreamFetcher): | ||
"""Define Binance Stream Fetcher.""" | ||
|
||
@staticmethod | ||
def transform_data(data: Dict[str, Any], **kwargs) -> BinanceCryptoHistoricalData: | ||
"""Transform the incoming data.""" | ||
if "date" not in data: | ||
data["date"] = datetime.now().isoformat() | ||
return BinanceCryptoHistoricalData(**data) | ||
|
||
@classmethod | ||
async def process_message( | ||
cls, message: str, **kwargs | ||
) -> Optional[BinanceCryptoHistoricalData]: | ||
"""Process incoming WebSocket messages.""" | ||
try: | ||
json_data = json.loads(message) | ||
transformed_data = cls.transform_data(json_data) | ||
return transformed_data | ||
except Exception as e: | ||
print(f"Error processing message from Binance: {e}") | ||
return None |
1 change: 1 addition & 0 deletions
1
openbb_platform/providers/binance/openbb_binance/utils/__init__.py
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 @@ | ||
"""Biztoc utils.""" |
Oops, something went wrong.