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
Create new MarginTrading interface #3307
Comments
At a minimum level the connector should support these actions:
Other functionalities like isolated margin accounts are nice to have, but not necessary. For example the isolated margin functionality only makes sense if the client trades multiple assets at once, which for now it doesn't. And moreover each time a user would want to change the asset being traded, new account info would need to be provided for the individual margin account. So it's better to have simply a one universal cross margin account. Margin level needs to be periodically queried with the REST request Binance doesn't seem to provide any margin call specific query, it needs to be determined from the margin level. But to a strategy it should be provided as an event. Checking whether margin call occurred should be done within the connector as it depends on a fixed value of margin level. The same goes for interest rates. If interest rates become too high, the strategy may decide to liquidate its positions as keeping them would be unprofitable. But a strategy may also decide to not to care about interest rates if they stay roughly the same, therefore being interrupted on every update is not desirable. Instead there should be defined triggers within the connector which will notify the strategy through an event if an interest rate of an asset crosses a certain level. Borrowing and repaying funds should be in control of the strategy, not the connector. |
@mhrvth Well written and detailed, thanks.
We do have a strategy that trades multiple assets at once, Liquidity Mining strategy. I believe this will become more and more common (having strategies that trade broadly). Also our users could be using Hummingbot while doing their own trading on the same account (not uncommon). I think having isolated margin is a good option, it helps users manage risk better. When crypto markets tank, often they all tank together, having isolated margin prevents liquidation of the entire account.
An event trigger might be hard to implement as |
@mhrvth That's quite a lot to digest and I try to compare to mango.markets UX. I also need some clarification on some other endpoints.
Those two have optimal usages such that it shouldn't be up to the strategy (but to the gateway) to loan and repay collateral, as soon as needed. Mango's UI does not allow for such manual borrowing/repaying, as it automatically repays, if possible. Trades requiring borrowing, should do so automatically IMHO.
Does this query the L2 order book?
How might this be relevant to the trading algos?
Is this interest payment history or interest rate history? That being said, the particularity of endpoints is satisfying, as it guarantees that only absolutely needed data is queried. |
@MHHukiewitz to answer your questions: Being able to control loans gives strategies power to further optimize their performance. If a strategy knows the interest rate, it can accurately calculate its projected P/L, and if it's able to loan or repay its collateral it gives it power to further maximize its overall profit, or minimize overall loss. A strategy needs to be able to query the real state of the account at the exchange in general, because the client may have an incorrect information due to all kinds of errors (rounding, desynchronization, network ... ). Having an interest history can give strategies an option to predict future interest rates and plan their loans accordingly.
It queries meta information about the pair:
It's both interest and interest rate:
If an exchange is not able to provide some data, the method should return None or similar. Strategies would then need to check whether they can obtain the data. |
@cardosofede Is this indeed implemented now? |
Nope
…On Thu, 27 Apr 2023 at 08:38 Mike Hukiewitz ***@***.***> wrote:
@cardosofede <https://github.com/cardosofede> Is this indeed implemented
now?
—
Reply to this email directly, view it on GitHub
<#3307 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIZJOSDU2EABMMB6LLVU3PTXDJLCTANCNFSM44AB6VPA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
┆Issue is synchronized with this Clickup task by Unito
The text was updated successfully, but these errors were encountered: