bybit preparations

This commit is contained in:
Nicolás Sánchez 2024-12-05 11:43:45 -03:00
parent 0f5e215d78
commit c6015c9ada
2 changed files with 14 additions and 3 deletions

View File

@ -918,7 +918,7 @@ class broker:
market = self.fetch_market(pair)
if market is None:
return None
if self.get_exchange_name() in ["okex","kucoin"]:
if self.get_exchange_name() in ["okex","kucoin", "bybit"]:
return float(market["limits"]["amount"]["min"])
elif self.get_exchange_name() in ["gateio"]:
return (float(market["limits"]["cost"]["min"])+1)/self.get_ticker_price(pair)
@ -945,7 +945,7 @@ class broker:
if line["filterType"] == "NOTIONAL":
#return self.broker.amount_to_precision(pair,(float(line["minNotional"])))
return float(line["minNotional"])
elif self.get_exchange_name()=="gateio":
elif self.get_exchange_name() in ["gateio", "bybit"]:
#return self.cost_to_precision(pair,float(market["info"]["min_base_amount"])*self.broker.get_mid_price(pair))
return float(market["limits"]["cost"]["min"])
elif self.get_exchange_name() in ["okex","kucoin"]:
@ -971,7 +971,7 @@ class broker:
return float(filter["stepSize"])
elif self.get_exchange_name()=="kucoin":
return float(market["info"]["baseIncrement"])
elif self.get_exchange_name() in ["gateio","okex"]:
elif self.get_exchange_name() in ["gateio", "okex", "bybit"]:
return float(market["precision"]["amount"])
except Exception as e:
self.logger.log_this(f"Exception in get_step_size: {e}",1,pair)

11
main.py
View File

@ -250,6 +250,17 @@ def set_exchange(config: dict):
"timeout": timeout,
"enableRateLimit": True
})
elif config["exchange"]=="bybit":
exchange_class = getattr(ccxt, "bybit")
exchange = exchange_class({
"apiKey": config["key"],
"secret": config["secret"],
"timeout": timeout,
"enableRateLimit": True
})
exchange.options["acknowledged"] = True
if config["is_sandbox"]:
exchange.set_sandbox_mode(True)
else:
print(f"{time.strftime('[%Y/%m/%d %H:%M:%S]')} | Exchange not known or misspelled")
return None