Skip to content

Commit a29a98d

Browse files
committed
Minor optimizations
1 parent dbb7437 commit a29a98d

File tree

9 files changed

+34
-34
lines changed

9 files changed

+34
-34
lines changed

pkg/conf/conf.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import (
66

77
log "github.com/sirupsen/logrus"
88

9-
"github.com/spf13/viper"
10-
11-
// Loads yaml config files
129
_ "embed"
10+
11+
"github.com/spf13/viper"
1312
)
1413

1514
//go:embed dev.env
@@ -30,18 +29,18 @@ var mapper = map[EnvName]string{
3029
DEV: dev,
3130
}
3231

33-
// configuration - structure that contains configuration information from config variables
34-
type configuration struct {
32+
// Configuration - structure that contains Configuration information from config variables
33+
type Configuration struct {
3534
DBDsn string
3635
UpdateFees bool
3736
RestPort string
3837
}
3938

40-
var config *configuration
39+
var config *Configuration
4140
var envName EnvName
4241

4342
// LoadConfig - loads configurations from config variables into Environment struct
44-
func LoadConfig(conf string) (*configuration, error) {
43+
func LoadConfig(conf string) (*Configuration, error) {
4544
envName = EnvName(conf)
4645
switch envName {
4746
case DEV:
@@ -58,7 +57,7 @@ func LoadConfig(conf string) (*configuration, error) {
5857
log.Fatal("Environment variable not supplied")
5958
}
6059

61-
config = &configuration{
60+
config = &Configuration{
6261
DBDsn: fmt.Sprintf(
6362
"host=%s user=%s password=%s dbname=%s port=%s sslmode=disable",
6463
viper.GetString("POSTGRES_HOST"),
@@ -75,15 +74,15 @@ func LoadConfig(conf string) (*configuration, error) {
7574
}
7675

7776
// Get config
78-
func Get() *configuration {
77+
func Get() *Configuration {
7978
if config == nil {
8079
log.Fatal("Env not initialized")
8180
}
8281
return config
8382
}
8483

8584
// LoadTestConfig - Helper for calling in tests
86-
func LoadTestConfig() (*configuration, error) {
85+
func LoadTestConfig() (*Configuration, error) {
8786
return LoadConfig(string(DEV))
8887
}
8988

pkg/fix/fix.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,62 @@ import (
1313
)
1414

1515
// FixServer implements the main quickfix interface
16-
type FixServer struct {
16+
type Server struct {
1717
*quickfix.MessageRouter
1818
}
1919

20-
func New() *FixServer {
21-
server := &FixServer{}
20+
func New() *Server {
21+
server := &Server{}
2222
server.AddRoute(marketdatarequest.Route(server.NewMarketDataReq))
2323
server.AddRoute(newordersingle.Route(server.NewOrder))
2424
server.AddRoute(ordercancelrequest.Route(server.CancelOrder))
2525
server.AddRoute(neworderlist.Route(server.NewOrderList))
2626
return server
2727
}
2828

29-
func (s *FixServer) OnCreate(sessionID quickfix.SessionID) {
29+
func (s *Server) OnCreate(sessionID quickfix.SessionID) {
3030
log.Println("Session created:", sessionID)
3131
}
3232

33-
func (s *FixServer) OnLogon(sessionID quickfix.SessionID) {
33+
func (s *Server) OnLogon(sessionID quickfix.SessionID) {
3434
fmt.Println("Session logged on:", sessionID)
3535
}
3636

37-
func (s *FixServer) OnLogout(sessionID quickfix.SessionID) {
37+
func (s *Server) OnLogout(sessionID quickfix.SessionID) {
3838
fmt.Println("Session logged out:", sessionID)
3939
}
4040

41-
func (s *FixServer) ToAdmin(message quickfix.Message, sessionID quickfix.SessionID) {
41+
func (s *Server) ToAdmin(message quickfix.Message, sessionID quickfix.SessionID) {
4242
fmt.Println("Sending admin message to", sessionID, ":", message)
4343
}
4444

45-
func (s *FixServer) ToApp(message quickfix.Message, sessionID quickfix.SessionID) error {
45+
func (s *Server) ToApp(message quickfix.Message, sessionID quickfix.SessionID) error {
4646
fmt.Println("Sending app message to", sessionID, ":", message)
4747
return nil
4848
}
4949

50-
func (s *FixServer) FromAdmin(message quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
50+
func (s *Server) FromAdmin(message quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
5151
fmt.Println("Receiving admin message from", sessionID, ":", message)
5252
return quickfix.InvalidMessageType()
5353
}
5454

55-
func (s *FixServer) FromApp(message quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
55+
func (s *Server) FromApp(message quickfix.Message, sessionID quickfix.SessionID) quickfix.MessageRejectError {
5656
fmt.Println("Receiving app message from", sessionID, ":", message)
5757
return quickfix.InvalidMessageType()
5858
}
5959

60-
func (s *FixServer) NewOrder(msg newordersingle.NewOrderSingle, id quickfix.SessionID) quickfix.MessageRejectError {
60+
func (s *Server) NewOrder(msg newordersingle.NewOrderSingle, id quickfix.SessionID) quickfix.MessageRejectError {
6161
return nil
6262
}
6363

64-
func (s *FixServer) CancelOrder(msg ordercancelrequest.OrderCancelRequest, id quickfix.SessionID) quickfix.MessageRejectError {
64+
func (s *Server) CancelOrder(msg ordercancelrequest.OrderCancelRequest, id quickfix.SessionID) quickfix.MessageRejectError {
6565
return nil
6666
}
6767

68-
func (s *FixServer) NewOrderList(msg neworderlist.NewOrderList, id quickfix.SessionID) quickfix.MessageRejectError {
68+
func (s *Server) NewOrderList(msg neworderlist.NewOrderList, id quickfix.SessionID) quickfix.MessageRejectError {
6969
return nil
7070
}
7171

72-
func (s *FixServer) NewMarketDataReq(msg marketdatarequest.MarketDataRequest, id quickfix.SessionID) quickfix.MessageRejectError {
72+
func (s *Server) NewMarketDataReq(msg marketdatarequest.MarketDataRequest, id quickfix.SessionID) quickfix.MessageRejectError {
7373
return nil
7474
}

pkg/services/matching_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
log "github.com/sirupsen/logrus"
1010
)
1111

12-
// Main entry point for processing a trade order.
12+
// ProcessTradeOrder Main entry point for processing a trade order.
1313
// - For BUY side, the amount must be alocated in quote currency.
1414
// - For SELL side the amount must be allocared in base currency
1515
func ProcessTradeOrder(

pkg/services/test_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type MatchingServiceTestCase struct {
2424
steps []TestStep
2525
}
2626

27-
// // shorthand methods
27+
// Acc shorthand methods
2828
func Acc(v string) (models.AppEntityId, models.TradingAccountId) {
2929
appEntityId := CreateAppEntity(models.AppEntityExternalId(v))
3030
models.CreatePaymentAccount(appEntityId, models.CurrencyName("BTC"))

pkg/static/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</style>
1919
</head>
2020
<body>
21+
<!--suppress HtmlUnknownTag -->
2122
<redoc spec-url='/static/api.yaml'></redoc>
2223
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script>
2324
</body>

sql/0190_get_crossing_limit_orders.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ BEGIN
3535
AND t.trading_account_id != trade_account_id_param
3636
AND t.order_type = 'LIMIT'::order_type
3737
-- order first by price then by date created
38-
ORDER BY t.price ASC, t.created_at ASC;
38+
ORDER BY t.price, t.created_at;
3939
ELSE
4040
RETURN QUERY SELECT b.id, b.pub_id, b.trade_order_id FROM book_order b
4141
INNER JOIN trade_order t
@@ -45,7 +45,7 @@ BEGIN
4545
AND t.trading_account_id != trade_account_id_param
4646
AND t.order_type = 'LIMIT'::order_type
4747
-- order first by price then by date created
48-
ORDER BY t.price DESC, t.created_at ASC;
48+
ORDER BY t.price DESC, t.created_at;
4949
END IF;
5050
ELSE
5151
-- handle limit order
@@ -59,7 +59,7 @@ BEGIN
5959
AND t.order_type = 'LIMIT'::order_type
6060
AND t.price <= price_param
6161
-- order first by price then by date created
62-
ORDER BY t.price ASC, t.created_at ASC;
62+
ORDER BY t.price, t.created_at;
6363
ELSE
6464
RETURN QUERY SELECT b.id, b.pub_id, b.trade_order_id FROM book_order b
6565
INNER JOIN trade_order t
@@ -70,7 +70,7 @@ BEGIN
7070
AND t.order_type = 'LIMIT'::order_type
7171
AND t.price >= price_param
7272
-- order first by price then by date created
73-
ORDER BY t.price DESC, t.created_at ASC;
73+
ORDER BY t.price DESC, t.created_at;
7474
END IF;
7575
END IF;
7676
END;

sql/0210_get_best_limit_price.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ BEGIN
1818
WHERE side = side_param
1919
AND instrument_id = instrument_id_param
2020
AND price > 0
21-
ORDER BY price ASC
21+
ORDER BY price
2222
LIMIT 1
2323
INTO acc;
2424
ELSEIF side_param = 'BUY'::order_side THEN

sql/0290_process_trade_order.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ BEGIN
208208
AND t.trading_account_id != trading_account_instance.id
209209
AND t.side = opposite_side_var
210210
AND t.order_type = 'MARKET'::order_type
211-
ORDER BY t.created_at ASC
211+
ORDER BY t.created_at
212212

213213
LOOP
214214
trade_price_var = get_trade_price(

sql/0340_get_market_orders.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ BEGIN
1717
AND side = side_param
1818
AND order_type = 'MARKET'::order_type
1919
-- order first by price then by date created
20-
ORDER BY created_at ASC;
20+
ORDER BY created_at;
2121
ELSE
2222
RETURN QUERY SELECT * FROM book_order
2323
WHERE instrument_id = instrument_id_param
2424
AND side = side_param
2525
AND order_type = 'MARKET'::order_type
2626
-- order first by price then by date created
27-
ORDER BY created_at ASC;
27+
ORDER BY created_at;
2828
END IF;
2929
END;
3030
$$;

0 commit comments

Comments
 (0)