beatzxbt / bybit-smm Goto Github PK
View Code? Open in Web Editor NEWbybit simple market maker
License: MIT License
bybit simple market maker
License: MIT License
Can you explain better this bug? I have been trying to repreduce it, but without any success until now!
Just as a heads up in the v2 alpha branch in smm/quote_generators/plain.py.
You allow negative numbers as input.
def generate_orders(self, skew: float, spread: float) -> List:
if skew > 0.0:
return self.generate_positive_skew_quotes(skew, spread)
elif skew <= 0.0:
return self.generate_negative_skew_quotes(skew, spread)
Negative skew values will be used in:
half_spread = spread / 2
aggressiveness = self.params["aggressiveness"] * (skew**0.5)
best_bid_price = self.mid - (half_spread * (1.0 - aggressiveness))
best_ask_price = best_bid_price + spread
This will cause unintended issues. Best shown by an example.
skew = -0.99
with_skew_var = 0.5 * (skew**0.5)
print("with skew var", with_skew_var)
print("with skew var",type(with_skew_var))
without_skew_var = 0.5 * (-0.99**0.5)
print("\n")
print("without skew var", without_skew_var)
print("without skew var",type(without_skew_var))
Output:
with skew var (3.0462704501111267e-17+0.49749371855331j)
with skew var <class 'complex'>
without skew var -0.49749371855331
without skew var <class 'float'>
Afaik interprets python the one with the skew variable used as: (-0.99)**0.5.
While interpreting the one without the var used as: -(0.99**0.5)
.
Raising a negative number to a fractional exponent results in a complex number rather than the expected float.
Have you not yet encountered this? I haven't looked at the skew calcs in depth yet and I know it's still a WIP maybe the current skew calcs will never output negative skew or the skew value is coming from somewhere else idk.
Below is from the bybit orderbook handler but saw the same thing in the binance one.
on snapshot or update_id representing a snapshot message ob is reset using snapshot data
self.update_id = new_update_id
self.bids = np.array(data["b"], dtype=np.float64)
self.asks = np.array(data["a"], dtype=np.float64)
self.orderbook.refresh(self.asks, self.bids)
Makes sense, note self.update_id is set (probably to 1 because of snapshot).
Then if message is not snapshot and not update_id 1 (so perhaps "delta" and 1234). We then check if 1234 > self.update_id which is probably still 1 from the last snapshot reset. So any delta msg will then reset bids or asks if it has any data for them.
self.bids = np.array(data["b"], dtype=np.float64)
for example
Is this intented? Surely you would want to update your book on delta messages rather than overwriting one or both sides entirely?
Afaik current implementation only works if you get a full book update on delta messages but then whats the snapshot for?
I thought usually delta message only contains data for bids/asks that actually had a change in p or q in any way.
Anyways love to hear your thoughts I might just be missing something simple!
def process(self, recv: Dict) -> None:
try:
data = recv["data"]
new_update_id = int(data["u"])
update_type = recv["type"]
if new_update_id == 1 or update_type == "snapshot":
self.update_id = new_update_id
self.bids = np.array(data["b"], dtype=np.float64)
self.asks = np.array(data["a"], dtype=np.float64)
self.orderbook.refresh(self.asks, self.bids)
elif new_update_id > self.update_id:
self.update_id = new_update_id
if len(data.get("b", [])) > 0:
self.bids = np.array(data["b"], dtype=np.float64)
self.orderbook.update_bids(self.bids)
if len(data.get("a", [])) > 0:
self.asks = np.array(data["a"], dtype=np.float64)
self.orderbook.update_asks(self.asks)
except Exception as e:
raise Exception(f"Orderbook Process :: {e}")
Hi, I was able to start the bot but facing an issue with the request. Here is the callback.
2024-04-09 13:00:01.263755: Starting data feeds...
2024-04-09 13:00:08.875183: Connected to ['position', 'order'] bybit feeds...
2024-04-09 13:00:10.722021: Connected to ['orderbook.500.ETHUSDT', 'orderbook.1.ETHUSDT', 'publicTrade.ETHUSDT', 'tickers.ETHUSDT', 'kline.1.ETHUSDT'] bybit feeds...
2024-04-09 13:00:10.877842: Starting strategy...
2024-04-09 13:00:48.918788: Error: 10002/invalid request, please check your server timestamp or recv_window param. req_timestamp[1712638815956],server_timestamp[1712638849231],recv_window[5000] | Endpoint: /v5/order/create-batch
2024-04-09 13:00:54.584375: Error: 10002/invalid request, please check your server timestamp or recv_window param. req_timestamp[1712638849922],server_timestamp[1712638855248],recv_window[5000] | Endpoint: /v5/order/cancel-all
2024-04-09 13:02:17.384118: Error: 10002/invalid request, please check your server timestamp or recv_window param. req_timestamp[1712638877054],server_timestamp[1712638938078],recv_window[5000] | Endpoint: /v5/order/cancel-all
2024-04-09 13:00:01.263755: Starting data feeds...
2024-04-09 13:00:08.875183: Connected to ['position', 'order'] bybit feeds...
2024-04-09 13:00:10.722021: Connected to ['orderbook.500.ETHUSDT', 'orderbook.1.ETHUSDT', 'publicTrade.ETHUSDT', 'tickers.ETHUSDT', 'kline.1.ETHUSDT'] bybit feeds...
2024-04-09 13:00:10.877842: Starting strategy...
2024-04-09 13:00:48.918788: Error: 10002/invalid request, please check your server timestamp or recv_window param. req_timestamp[1712638815956],server_timestamp[1712638849231],recv_window[5000] | Endpoint: /v5/order/create-batch
2024-04-09 13:00:54.584375: Error: 10002/invalid request, please check your server timestamp or recv_window param. req_timestamp[1712638849922],server_timestamp[1712638855248],recv_window[5000] | Endpoint: /v5/order/cancel-all
2024-04-09 13:02:17.384118: Error: 10002/invalid request, please check your server timestamp or recv_window param. req_timestamp[1712638877054],server_timestamp[1712638938078],recv_window[5000] | Endpoint: /v5/order/cancel-all
Greetings!
Wonder why in these lines of code you do such comparison and what is the value to use for it, since there is no self.ss.buffer in SharedState.py?
Thanks in advance!
OMS: amend_orders func
https://github.com/beatzxbt/bybit-smm/blob/56c803b25b836de459f6876b96f473b7c7cea82c/src/strategy/oms.py#L83C13-L83C59
OMS: 5th check
https://github.com/beatzxbt/bybit-smm/blob/56c803b25b836de459f6876b96f473b7c7cea82c/src/strategy/oms.py#L178C13-L178C60
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.