Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with opening trade #48

Open
Amenocy opened this issue Jun 5, 2024 · 5 comments
Open

problem with opening trade #48

Amenocy opened this issue Jun 5, 2024 · 5 comments

Comments

@Amenocy
Copy link

Amenocy commented Jun 5, 2024

Hi
i am working to add a new exchange to mmbot, since I am not c/cpp developer, It took more than standard time/effort :)
branch is here: Amenocy#1
now I have a problem, I tested all broker_protcol commands and they work fine, and I am able to run trader, but the problem is, it doesn't even try to open an order, I could find any placeOrder call in the logfile, but I can see this in dashboard,
I have one guess, and since from strategy, order amount is too low, and my money in exchange ( for test) is too low ( 57usdt) , it tries to open order but from getinfo call data, it cannot pass min order amount, somehow it shows in the dashboard!
Screenshot 2024-06-05 at 10 40 00 AM
could you please help me a b I t ?

CSV format of that orders:
"date","pair","price","size","value","currency","asset"
"05/06/2024, 10:22:33","ethusdt",3803.193,0,0,"eth","usdt"
"05/06/2024, 10:23:32","ethusdt",3803.193,0,0,"eth","usdt"

@ondra-novak thanks in advance :)

@Amenocy
Copy link
Author

Amenocy commented Jun 5, 2024

i noticed that the currency and asset in csv are incorrect, I am not sure if it is from myyyy code or a bug in csv converter.

@Amenocy
Copy link
Author

Amenocy commented Jun 5, 2024

one step forward : what this error means ? Trade detected, waiting for confirmation (ADJ Timeout)

@ondra-novak
Copy link
Owner

Hi.

If your broker reports min_size or min_volume, the Bot can't create order with lower values. It also depend on strategy, try to test the strategy in the simulator to see correct behavior.

The mandatory fields are asset_step (increase of amount] and currency_step (which must not be zero, and specifies tick size). You can specify min_size (optional, can be zero) and min_volume (also optional). volume=amount*price

The strategy is trying to find optimal combination of price and amount to fit into the criteria. If this fails, it generates an alert which it is reported as you can see on the picture when it is triggered.

ADJ Timeout - "Adjust Timeout"

This is report of an error in your broker. When the strategy detects a change in assets/position but without associated trade, or when data reported by the trade doesn't match to detected change - for example, you buy 2 shares, but your assets increase is 3 shares, so there is one missing share. In this case, the trading is stopped, until missing trade arrives, or until timeout. If no trade arrives before timeout, the strategy generates fake trade to adjust current state.

From history experience, there were exchanges that delayed reported trades, for example Bitfinex was able to report a trade 49 minutes after it had been executed.

This can also happen, when you miscalculate eff_size of the trade (for example, when fees are subtracted from assets)

ADJ timeout can be changed in trader's configuration.

@Amenocy
Copy link
Author

Amenocy commented Jun 5, 2024

thanks Ondra,
what is means when "replaceOrderSize" is 0 ? for example : ["placeOrder",{"clientOrderId":186790643,"pair":"ethusdt","price":3818.79,"replaceOrderSize":0,"size":-7.8e-4}]

@ondra-novak
Copy link
Owner

So placeOrder can be used to replace an existing order.

The field repalceOrderSize is constrain which specifies remaining amount to execute of the order which is being replaced. If the remaining amount is less than this value, the replace is rejected ... or, you can cancel the order, but you should not place new one

Purpose of this is to prevent double execution. Consider following situation.

You have LIMIT order to buy 100 shares on 1234. You want to replace this order with order to buy 100 on 1200 . Your replaceOrderSize is set to 100. Before order arrives to the exchange, 90 shares are purchased.

Without this constrain, you could replace this order where are 10 shares remaining with and order where are 100 shares. So this constrain prevents you to place new order in this case.

If the exchange doesn't support such replace function directly, you need to implement this as CANCEL+PLACE. Many exchanges allows to examine the order state after cancel. The state of the order is often sent to the client as response to CANCEL request. So you can examine the remaining amount and if there is lower value than specified in replaceOrderSize, you simply rejects place part of the operation.

When this happens, on next cycle (after 1 minute), the strategy can place a new order depends on updated state on the exchange (it eventually receive a execution report - trade)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants