-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1161 from Drakkar-Software/dev
Dev merge
- Loading branch information
Showing
13 changed files
with
144 additions
and
15 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
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
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 @@ | ||
from .coinex_websocket import CoinexCCXTWebsocketConnector |
31 changes: 31 additions & 0 deletions
31
Trading/Exchange/coinex_websocket_feed/coinex_websocket.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,31 @@ | ||
# Drakkar-Software OctoBot-Tentacles | ||
# Copyright (c) Drakkar-Software, All rights reserved. | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 3.0 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library. | ||
import octobot_trading.exchanges as exchanges | ||
from octobot_trading.enums import WebsocketFeeds as Feeds | ||
import tentacles.Trading.Exchange.coinex.coinex_exchange as coinex_exchange | ||
|
||
|
||
class CoinexCCXTWebsocketConnector(exchanges.CCXTWebsocketConnector): | ||
EXCHANGE_FEEDS = { | ||
Feeds.TRADES: True, | ||
Feeds.KLINE: Feeds.UNSUPPORTED.value, # only for swap markets (futures) | ||
Feeds.TICKER: True, | ||
Feeds.CANDLE: Feeds.UNSUPPORTED.value, # only for swap markets (futures) | ||
} | ||
|
||
@classmethod | ||
def get_name(cls): | ||
return coinex_exchange.Coinex.get_name() |
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,6 @@ | ||
{ | ||
"version": "1.2.0", | ||
"origin_package": "OctoBot-Default-Tentacles", | ||
"tentacles": ["CoinexCCXTWebsocketConnector"], | ||
"tentacles-requirements": [] | ||
} |
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
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,59 @@ | ||
import os | ||
import sys | ||
import requests | ||
|
||
|
||
CLOUDFLARE_ZONE = os.getenv("CLOUDFLARE_ZONE") | ||
CLOUDFLARE_TOKEN = os.getenv("CLOUDFLARE_TOKEN") | ||
S3_BUCKET_NAME = os.getenv("S3_BUCKET_NAME") | ||
|
||
|
||
def _send_purge_cache_request(url: str, cloudflare_token: str, urls_to_purge: list): | ||
with requests.post( | ||
url=url, | ||
headers={ | ||
"Content-Type": "application/json", | ||
"Authorization": f"Bearer {cloudflare_token}", | ||
}, | ||
json={ | ||
"files": urls_to_purge | ||
} | ||
) as resp: | ||
if resp.status_code == 200: | ||
print(f"Cache purged for {', '.join(urls_to_purge)}") | ||
else: | ||
print(f"Error when purging cache, status: {resp.status_code}, body: {resp.text}") | ||
|
||
|
||
def _get_tentacles_url(tentacle_url_identifier): | ||
if not S3_BUCKET_NAME: | ||
raise RuntimeError("Missing S3_BUCKET_NAME env variable") | ||
return os.getenv( | ||
"TENTACLES_URL", | ||
f"https://{S3_BUCKET_NAME}." | ||
f"{os.getenv('TENTACLES_OCTOBOT_ONLINE_URL', 'octobot.online')}/" | ||
f"officials/packages/full/base/" | ||
f"{tentacle_url_identifier}/" | ||
f"any_platform.zip" | ||
) | ||
|
||
|
||
def clear_cache(tentacle_url_identifiers): | ||
if not CLOUDFLARE_ZONE: | ||
raise RuntimeError("Missing CLOUDFLARE_ZONE env variable") | ||
if not CLOUDFLARE_TOKEN: | ||
raise RuntimeError("Missing CLOUDFLARE_TOKEN env variable") | ||
# https://developers.cloudflare.com/api/operations/zone-purge#purge-cached-content-by-url | ||
url = f"https://api.cloudflare.com/client/v4/zones/{CLOUDFLARE_ZONE}/purge_cache" | ||
_send_purge_cache_request( | ||
url, | ||
CLOUDFLARE_TOKEN, | ||
[ | ||
_get_tentacles_url(tentacle_url_identifier) | ||
for tentacle_url_identifier in tentacle_url_identifiers | ||
] | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
clear_cache(sys.argv[1:]) |