-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Binance: margin trading #4475
base: develop
Are you sure you want to change the base?
Binance: margin trading #4475
Conversation
If this approach is accepted then I would like to add support for margin trading to BinanceStreamingExchange. But I do not see examples where connect method accepts custom product subscription classes. And this is required because there should be two additional subscription types for two additional channels: margin trades and isolated margin trades |
AUTO_REPAY; | ||
|
||
@JsonCreator | ||
public static MarginSideEffectType getSideEffectType(String s) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method seams pointless as jacksons standard error handling will do a much at reporting an unknown value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but this is how it's implemented for other Binance enums. So I just copied the same approach
return true; | ||
} catch (BinanceException e) { | ||
throw BinanceErrorAdapter.adapt(e); | ||
} | ||
} | ||
|
||
private MarginAccountType getMarginAccountTypeFromOrderId(String orderId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using order id to smuggle the margin accounts id look hacky
is this some kind of convention that comes from binance?
could you point to the documentation where its described?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a part of official documentation. It's a hack added by me to allow using regular cancelOrder/getOrder API for margin orders without any special parameter types. And it's optional though
# Conflicts: # xchange-binance/src/main/java/org/knowm/xchange/binance/service/BinanceTradeService.java
streaming of margin trading and account data
Adds new order flags to send margin order instead of spot one.
To cancel/retrieve margin order either custom order param structures could be used or account type could be included in order ID (if Include_Margin_Account_Type_In_OrderId exchange parameter is set to true)