Skip to content

Commit

Permalink
fix: Coinbase missing API key and secret when starting scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
mominafiz committed Mar 2, 2024
1 parent c193d59 commit 903fa5c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Python Crypto Bot v8.2.3 (pycryptobot)
# Python Crypto Bot v8.2.4 (pycryptobot)

[![Docker](https://github.com/whittlem/pycryptobot/actions/workflows/container.yml/badge.svg)](https://github.com/whittlem/pycryptobot/actions/workflows/container.yml/badge.svg) [![Tests](https://github.com/whittlem/pycryptobot/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/whittlem/pycryptobot/actions/workflows/unit-tests.yml/badge.svg)

Expand Down Expand Up @@ -38,10 +38,10 @@ Follow my Medium publication for PyCryptoBot articles
For information about installing, using, and getting the most out of the bot... please refer to the articles on Medium!

Install and Setup of PyCryptoBot 7
https://trading-data-analysis.pro/install-and-setup-of-pycryptobot-7-f1b2c832e795
<https://trading-data-analysis.pro/install-and-setup-of-pycryptobot-7-f1b2c832e795>

PyCryptoBot 7 Live Test Results
https://trading-data-analysis.pro/pycryptobot-7-live-test-results-b56316e0995c
<https://trading-data-analysis.pro/pycryptobot-7-live-test-results-b56316e0995c>

PyCryptoBot 7 Configuration
https://trading-data-analysis.pro/pycryptobot-7-configuration-e314931f94
<https://trading-data-analysis.pro/pycryptobot-7-configuration-e314931f94>
38 changes: 29 additions & 9 deletions scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,39 @@
GRANULARITY = Granularity(Granularity.ONE_HOUR)

try:
with open("scanner.json", encoding='utf8') as json_file:
with open("scanner.json", encoding="utf8") as json_file:
config = json.load(json_file)
except IOError as err:
print(err)

try:
with open("config.json", encoding='utf8') as json_file:
with open("config.json", encoding="utf8") as json_file:
bot_config = json.load(json_file)
except IOError as err:
print(err)

for exchange in config:
ex = Exchange(exchange)
app = PyCryptoBot(exchange=ex)

for quote in config[ex.value]["quote_currency"]:
if ex == Exchange.BINANCE:
api = BPublicAPI(bot_config[ex.value]["api_url"])
elif ex == Exchange.COINBASE:
api = CBAuthAPI(bot_config[ex.value]["api_key"], bot_config[ex.value]["api_secret"], bot_config[ex.value]["api_url"])
# Read config from key file
try:
with open(app.api_key_file, "r") as f:
key = f.readline().strip()
secret = f.readline().strip()
bot_config[ex.value]["api_key"] = key
bot_config[ex.value]["api_secret"] = secret
except Exception:
raise RuntimeError(f"Unable to read {app.api_key_file}")
api = CBAuthAPI(
bot_config[ex.value]["api_key"],
bot_config[ex.value]["api_secret"],
bot_config[ex.value]["api_url"],
)
elif ex == Exchange.COINBASEPRO:
api = CPublicAPI()
elif ex == Exchange.KUCOIN:
Expand Down Expand Up @@ -85,10 +99,14 @@

ROW = 1
for market, data in df_markets.T.items():
print(f"[{ROW}/{len(df_markets)}] {market} {round((ROW/len(df_markets))*100, 2)}%")
print(
f"[{ROW}/{len(df_markets)}] {market} {round((ROW/len(df_markets))*100, 2)}%"
)
try:
if int(data["volume"]) > 0:
ta = TechnicalAnalysis(api.get_historical_data(market, GRANULARITY, None), app=app)
ta = TechnicalAnalysis(
api.get_historical_data(market, GRANULARITY, None), app=app
)
ta.add_ema(12)
ta.add_ema(26)
ta.add_atr(72)
Expand All @@ -97,13 +115,15 @@
df_1h_last = df_1h.tail(1)

# volatility over the last 72 hours
df_markets.at[market, "atr72"] = float(df_1h_last[["atr72"]].values[0][0])
df_markets.at[market, "atr72"] = float(
df_1h_last[["atr72"]].values[0][0]
)
df_markets["atr72_pcnt"] = (
df_markets["atr72"] / df_markets["price"] * 100
).round(2)
df_markets.at[market, "buy_next"] = df_1h_last[df_1h_last["market"] == market][
"ema12ltema26"
].values[0]
df_markets.at[market, "buy_next"] = df_1h_last[
df_1h_last["market"] == market
]["ema12ltema26"].values[0]
except Exception as err:
print(err)

Expand Down

0 comments on commit 903fa5c

Please sign in to comment.