Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinTrinque committed Apr 30, 2021
1 parent 99e77fc commit 97f73bc
Show file tree
Hide file tree
Showing 21 changed files with 484 additions and 693 deletions.
10 changes: 5 additions & 5 deletions api/mocks/governance_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions execution/2500_GTT_amended_to_GTC_expires_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ func TestGTTAmendToGTCAmendInPlace_OrderGetExpired(t *testing.T) {
// now we edit the order t make it GTC so it should not expire
amendment := &types.OrderAmendment{
OrderId: o1.Id,
PartyId: "aaa",
TimeInForce: types.Order_TIME_IN_FORCE_GTC,
}

amendConf, err := tm.market.AmendOrder(ctx, amendment)
amendConf, err := tm.market.AmendOrder(ctx, amendment, "aaa")
require.NotNil(t, amendConf)
require.NoError(t, err)
assert.Equal(t, types.Order_STATUS_ACTIVE, amendConf.Order.Status)
Expand Down
9 changes: 3 additions & 6 deletions execution/amends_test_flip_gtt_gtc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ func TestOrderBookAmends_FlipToGTT(t *testing.T) {
// now we edit the order t make it GTC so it should not expire
amendment := &types.OrderAmendment{
OrderId: o1.Id,
PartyId: "aaa",
TimeInForce: types.Order_TIME_IN_FORCE_GTT,
ExpiresAt: &types.Timestamp{
Value: now.Add(10 * time.Second).UnixNano(),
},
}

amendConf, err := tm.market.AmendOrder(ctx, amendment)
amendConf, err := tm.market.AmendOrder(ctx, amendment, "aaa")
require.NotNil(t, amendConf)
require.NoError(t, err)
assert.Equal(t, types.Order_STATUS_ACTIVE, amendConf.Order.Status)
Expand All @@ -47,14 +46,13 @@ func TestOrderBookAmends_FlipToGTT(t *testing.T) {
// now we edit the order t make it GTC so it should not expire
amendment2 := &types.OrderAmendment{
OrderId: o1.Id,
PartyId: "aaa",
TimeInForce: types.Order_TIME_IN_FORCE_GTT,
ExpiresAt: &types.Timestamp{
Value: now.Add(20 * time.Second).UnixNano(),
},
}

amendConf2, err := tm.market.AmendOrder(ctx, amendment2)
amendConf2, err := tm.market.AmendOrder(ctx, amendment2, "aaa")
require.NotNil(t, amendConf2)
require.NoError(t, err)
assert.Equal(t, types.Order_STATUS_ACTIVE, amendConf2.Order.Status)
Expand All @@ -63,11 +61,10 @@ func TestOrderBookAmends_FlipToGTT(t *testing.T) {
// now we edit the order t make it GTC so it should not expire
amendment3 := &types.OrderAmendment{
OrderId: o1.Id,
PartyId: "aaa",
TimeInForce: types.Order_TIME_IN_FORCE_GTC,
}

amendConf3, err := tm.market.AmendOrder(ctx, amendment3)
amendConf3, err := tm.market.AmendOrder(ctx, amendment3, "aaa")
require.NotNil(t, amendConf3)
require.NoError(t, err)
assert.Equal(t, types.Order_STATUS_ACTIVE, amendConf3.Order.Status)
Expand Down
6 changes: 3 additions & 3 deletions execution/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ func (e *Engine) SubmitOrder(ctx context.Context, order *types.Order) (*types.Or

// AmendOrder takes order amendment details and attempts to amend the order
// if it exists and is in a editable state.
func (e *Engine) AmendOrder(ctx context.Context, orderAmendment *types.OrderAmendment) (confirmation *types.OrderConfirmation, returnedErr error) {
func (e *Engine) AmendOrder(ctx context.Context, orderAmendment *types.OrderAmendment, party string) (confirmation *types.OrderConfirmation, returnedErr error) {
defer func() {
e.notifyFailureOnError(ctx, returnedErr, orderAmendment.PartyId, orderAmendment)
e.notifyFailureOnError(ctx, returnedErr, party, orderAmendment)
}()

if e.log.IsDebug() {
Expand All @@ -479,7 +479,7 @@ func (e *Engine) AmendOrder(ctx context.Context, orderAmendment *types.OrderAmen

// we're passing a pointer here, so we need the wasActive var to be certain we're checking the original
// order status. It's possible order.Status will reflect the new status value if we don't
conf, err := mkt.AmendOrder(ctx, orderAmendment)
conf, err := mkt.AmendOrder(ctx, orderAmendment, party)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 97f73bc

Please sign in to comment.