Closed jeonghoyeo7 closed 1 year ago
Hello @adshao . Could you take a time to review this PR? Thank you!
Hello @adshao . Could you take a time to review this PR? Thank you!
Thank you for the work, please check my review comments.
Thank you for your review and comments.
In summary, from https://binance-docs.github.io/apidocs/futures/en/#change-multi-assets-mode-trade, where it is seen as
POST /fapi/v1/multiAssetsMargin (HMAC SHA256)
has the parameter as below.
multiAssetsMargin | STRING | YES | "true": Multi-Assets Mode; "false": Single-Asset Mode
Following the above link, it seems multiAssetsMargin
, which will become s.multiAssetsMargin
, should be a string.
Thank you for your review and comments.
In summary, from https://binance-docs.github.io/apidocs/futures/en/#change-multi-assets-mode-trade, where it is seen as
POST /fapi/v1/multiAssetsMargin (HMAC SHA256)
has the parameter as below. multiAssetsMargin | STRING | YES | "true": Multi-Assets Mode; "false": Single-Asset ModeFollowing the above link, it seems
multiAssetsMargin
, which will becomes.multiAssetsMargin
, should be a string.
setFormParams will automatically convert bool
to string
before submitting the form.
Thanks for further explanation.
As I reviewed ChangePositionModeService
and DualSide
function, ChangePositionModeService
has the same case as MultiAssetModeService
in that they have the same type parameter of string.
Is setFormParams
applied only to MultiAssetModeService
or both cases? Then, does the following code need to be modified from
func (s *ChangePositionModeService) DualSide(dualSide bool) *ChangePositionModeService {
if dualSide {
s.dualSide = "true"
} else {
s.dualSide = "false"
}
return s
}
to
func (s *ChangePositionModeService) DualSide(dualSide bool) *ChangePositionModeService {
s.dualSide = dualSide
return s
}
? But, after reviewing
r.setFormParams(params{
"dualSidePosition": s.dualSide,
})
```,
the existing part related to ChangePositionModeService looks correct.
It seems because of the following part,
r.setFormParams(params{ "multiAssetsMargin": s.multiAssetsMargin, })
`s.multiAssetsMargin` seems to be required to be string.
Thanks for further explanation.
As I reviewed
ChangePositionModeService
andDualSide
function,ChangePositionModeService
has the same case asMultiAssetModeService
in that they have the same type parameter of string.Is
setFormParams
applied only toMultiAssetModeService
or both cases? Then, does the following code need to be modified fromfunc (s *ChangePositionModeService) DualSide(dualSide bool) *ChangePositionModeService { if dualSide { s.dualSide = "true" } else { s.dualSide = "false" } return s }
to
func (s *ChangePositionModeService) DualSide(dualSide bool) *ChangePositionModeService { s.dualSide = dualSide return s }
? But, after reviewing
r.setFormParams(params{ "dualSidePosition": s.dualSide, }) ```, the existing part related to ChangePositionModeService looks correct. It seems because of the following part,
r.setFormParams(params{ "multiAssetsMargin": s.multiAssetsMargin, })
`s.multiAssetsMargin` seems to be required to be string.
I think
DualSide
was added beforesetFormParams
supportingbool
directly. You can just verify it in your unit tests.
@adshao Thanks a lot for your comment.
I revised the multiAssetMode related as your suggestion.
And also, I further changed ChangePositionModeService
for DualSide
similarly.
type ChangePositionModeService struct {
c *Client
dualSide bool
}
// Change user's position mode: true - Hedge Mode, false - One-way Mode
func (s *ChangePositionModeService) DualSide(dualSide bool) *ChangePositionModeService {
s.dualSide = dualSide
return s
}
I found setFormParams
is also applied to this by
r.setFormParams(params{
"dualSidePosition": s.dualSide,
})
I checked the related unit tests are all passed.
I found the endpoint
/fapi/v1/multiAssetsMargin
is not supported yet to get or change the multi-asset mode of a user. I added the related services accordingly in the following files inv2/futures
.