Optimisation: large structs/huge param fixes (part 2) (#262)

* updated golangci config to enable hugeparam linter

* ModifyOrder struct usage converted to a pointer

* OrderBook conversion to struct

* More conversion of large structs to pointers

* updated golangci config to enable hugeparam linter

* ModifyOrder struct usage converted to a pointer

* OrderBook conversion to struct

* More conversion of large structs to pointers

* disabled hugeParam check for golang again

* changed based on suggested feedback and fix for no default provider

* fixed typing
This commit is contained in:
Andrew
2019-03-26 15:40:46 +11:00
committed by Adrian Gallagher
parent 5683fdd917
commit dc236c251e
87 changed files with 234 additions and 232 deletions

View File

@@ -540,7 +540,7 @@ func (g *Gemini) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
if err != nil {
return 0, err
}
fee = calculateTradingFee(notionVolume, feeBuilder.PurchasePrice, feeBuilder.Amount, feeBuilder.IsMaker)
fee = calculateTradingFee(&notionVolume, feeBuilder.PurchasePrice, feeBuilder.Amount, feeBuilder.IsMaker)
case exchange.CryptocurrencyWithdrawalFee:
// TODO: no free transactions after 10; Need database to know how many trades have been done
// Could do via trade history, but would require analysis of response and dates to determine level of fee
@@ -554,7 +554,7 @@ func (g *Gemini) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) {
return fee, nil
}
func calculateTradingFee(notionVolume NotionalVolume, purchasePrice, amount float64, isMaker bool) float64 {
func calculateTradingFee(notionVolume *NotionalVolume, purchasePrice, amount float64, isMaker bool) float64 {
var volumeFee float64
if isMaker {
volumeFee = (float64(notionVolume.MakerFee) / 100)

View File

@@ -468,7 +468,7 @@ func TestCancelAllExchangeOrders(t *testing.T) {
}
func TestModifyOrder(t *testing.T) {
_, err := Session[1].ModifyOrder(exchange.ModifyOrder{})
_, err := Session[1].ModifyOrder(&exchange.ModifyOrder{})
if err == nil {
t.Error("Test failed - ModifyOrder() error")
}

View File

@@ -43,11 +43,11 @@ func (g *Gemini) WsConnect() error {
go g.WsHandleData()
return g.WsSubscribe(dialer)
return g.WsSubscribe(&dialer)
}
// WsSubscribe subscribes to the full websocket suite on gemini exchange
func (g *Gemini) WsSubscribe(dialer websocket.Dialer) error {
func (g *Gemini) WsSubscribe(dialer *websocket.Dialer) error {
enabledCurrencies := g.GetEnabledCurrencies()
for i, c := range enabledCurrencies {
val := url.Values{}
@@ -153,13 +153,13 @@ func (g *Gemini) WsHandleData() {
}
}
var newOrderbook orderbook.Base
newOrderbook.Asks = asks
newOrderbook.Bids = bids
newOrderbook.AssetType = "SPOT"
newOrderbook.Pair = resp.Currency
var newOrderBook orderbook.Base
newOrderBook.Asks = asks
newOrderBook.Bids = bids
newOrderBook.AssetType = "SPOT"
newOrderBook.Pair = resp.Currency
err := g.Websocket.Orderbook.LoadSnapshot(newOrderbook,
err := g.Websocket.Orderbook.LoadSnapshot(&newOrderBook,
g.GetName(),
false)
if err != nil {

View File

@@ -179,7 +179,7 @@ func (g *Gemini) SubmitOrder(p currency.Pair, side exchange.OrderSide, orderType
// ModifyOrder will allow of changing orderbook placement and limit to
// market conversion
func (g *Gemini) ModifyOrder(action exchange.ModifyOrder) (string, error) {
func (g *Gemini) ModifyOrder(action *exchange.ModifyOrder) (string, error) {
return "", common.ErrFunctionNotSupported
}