Skip to content

Commit

Permalink
Merge branch 'ranjanrak-order-auction'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhnvrm committed Jun 15, 2023
2 parents 91146a1 + 4fe848f commit f11d290
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mock_responses
Submodule mock_responses updated 2 files
+228 −220 order_info.json
+135 −31 orders.json
5 changes: 4 additions & 1 deletion orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Order struct {
ExchangeUpdateTimestamp models.Time `json:"exchange_update_timestamp"`
ExchangeTimestamp models.Time `json:"exchange_timestamp"`
Variety string `json:"variety"`
Modified bool `json:"modified"`
Meta map[string]interface{} `json:"meta"`

Exchange string `json:"exchange"`
Expand All @@ -45,6 +46,8 @@ type Order struct {
PendingQuantity float64 `json:"pending_quantity"`
CancelledQuantity float64 `json:"cancelled_quantity"`

AuctionNumber string `json:"auction_number"`

Tag string `json:"tag"`
Tags []string `json:"tags"`
}
Expand Down Expand Up @@ -74,7 +77,7 @@ type OrderParams struct {
IcebergLegs int `url:"iceberg_legs,omitempty"`
IcebergQty int `url:"iceberg_quantity,omitempty"`

AuctionNumber int `url:"auction_number,omitempty"`
AuctionNumber string `url:"auction_number,omitempty"`

Tag string `json:"tag" url:"tag,omitempty"`
}
Expand Down
15 changes: 12 additions & 3 deletions orders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ func (ts *TestSuite) TestGetOrders(t *testing.T) {
})
t.Run("test tag parsing", func(t *testing.T) {
require.Equal(t, "", orders[0].Tag)
require.Equal(t, "connect test order1", orders[1].Tag)
require.Equal(t, []string{"connect test order2", "XXXXX"}, orders[2].Tags)
require.Equal(t, "connect test order1", orders[4].Tag)
require.Equal(t, []string{"connect test order2", "XXXXX"}, orders[5].Tags)
})
t.Run("test ice-berg and TTL orders", func(t *testing.T) {
require.Equal(t, "iceberg", orders[3].Variety)
require.Equal(t, false, orders[3].Modified)
require.Equal(t, "TTL", orders[3].Validity)
require.Equal(t, 200.0, orders[3].Meta["iceberg"].(map[string]interface{})["leg_quantity"])
require.Equal(t, 1000.0, orders[3].Meta["iceberg"].(map[string]interface{})["total_quantity"])
})
t.Run("test auction order", func(t *testing.T) {
require.Equal(t, "auction", orders[6].Variety)
require.Equal(t, "22", orders[6].AuctionNumber)
require.Equal(t, false, orders[6].Modified)
})
}

func (ts *TestSuite) TestGetTrades(t *testing.T) {
Expand All @@ -54,6 +60,9 @@ func (ts *TestSuite) TestGetOrderHistory(t *testing.T) {
if order.OrderID == "" {
t.Errorf("Error while fetching order id in order history. %v", err)
}
if order.Modified {
t.Errorf("Error for not modified order. %v", err)
}
}
}

Expand Down Expand Up @@ -155,7 +164,7 @@ func (ts *TestSuite) TestPlaceAuctionOrder(t *testing.T) {
TransactionType: "test_auction",
Quantity: 100,
Price: 100,
AuctionNumber: 7359,
AuctionNumber: "7359",
Tag: "test_auction",
}
orderResponse, err := ts.KiteConnect.PlaceOrder("auction", params)
Expand Down

0 comments on commit f11d290

Please sign in to comment.