ftx: fix ioc convert

This commit is contained in:
c9s 2022-02-18 14:10:21 +08:00
parent f6ebeeafc5
commit 17034b2467
2 changed files with 8 additions and 9 deletions

View File

@ -42,13 +42,19 @@ func toGlobalOrder(r order) (types.Order, error) {
if r.Ioc {
timeInForce = types.TimeInForceIOC
}
// order type definition: https://github.com/ftexchange/ftx/blob/master/rest/client.py#L122
orderType := types.OrderType(TrimUpperString(r.Type))
if orderType == types.OrderTypeLimit && r.PostOnly {
orderType = types.OrderTypeLimitMaker
}
o := types.Order{
SubmitOrder: types.SubmitOrder{
ClientOrderID: r.ClientId,
Symbol: toGlobalSymbol(r.Market),
Side: types.SideType(TrimUpperString(r.Side)),
// order type definition: https://github.com/ftexchange/ftx/blob/master/rest/client.py#L122
Type: types.OrderType(TrimUpperString(r.Type)),
Type: orderType,
Quantity: r.Size,
Price: r.Price,
TimeInForce: timeInForce,

View File

@ -102,27 +102,20 @@ func Test_toGlobalSymbol(t *testing.T) {
}
func Test_toLocalOrderTypeWithLimitMaker(t *testing.T) {
orderType, err := toLocalOrderType(types.OrderTypeLimitMaker)
assert.NoError(t, err)
assert.Equal(t, orderType, OrderTypeLimit)
assert.Equal(t, postOnly, true)
}
func Test_toLocalOrderTypeWithLimit(t *testing.T) {
orderType, err := toLocalOrderType(types.OrderTypeLimit)
assert.NoError(t, err)
assert.Equal(t, orderType, OrderTypeLimit)
assert.Equal(t, postOnly, false)
}
func Test_toLocalOrderTypeWithMarket(t *testing.T) {
orderType, err := toLocalOrderType(types.OrderTypeMarket)
assert.NoError(t, err)
assert.Equal(t, orderType, OrderTypeMarket)
assert.Equal(t, postOnly, false)
}