Skip to content

Commit

Permalink
Bittrex
Browse files Browse the repository at this point in the history
  • Loading branch information
martonp committed Oct 26, 2023
1 parent a5151ea commit cd95fc8
Show file tree
Hide file tree
Showing 9 changed files with 1,784 additions and 7 deletions.
9 changes: 3 additions & 6 deletions client/mm/libxc/binance.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,21 +432,19 @@ func (bnc *binance) Trade(ctx context.Context, baseID, quoteID uint32, sell bool
v.Add("quantity", strconv.FormatFloat(amt, 'f', market.BaseAssetPrecision, 64))
v.Add("price", strconv.FormatFloat(price, 'f', market.QuoteAssetPrecision, 64))

bnc.tradeUpdaterMtx.RLock()
bnc.tradeUpdaterMtx.Lock()
defer bnc.tradeUpdaterMtx.Unlock()

_, found = bnc.tradeUpdaters[subscriptionID]
if !found {
bnc.tradeUpdaterMtx.RUnlock()
return "", fmt.Errorf("no trade updater with ID %v", subscriptionID)
}
bnc.tradeUpdaterMtx.RUnlock()

err = bnc.postAPI(ctx, "/api/v3/order", v, nil, true, true, &struct{}{})
if err != nil {
return "", err
}

bnc.tradeUpdaterMtx.Lock()
defer bnc.tradeUpdaterMtx.Unlock()
bnc.tradeInfo[tradeID] = &tradeInfo{
updaterID: subscriptionID,
baseID: baseID,
Expand Down Expand Up @@ -1360,7 +1358,6 @@ func (bnc *binance) VWAP(baseID, quoteID uint32, sell bool, qty uint64) (avgPric
remaining -= binQty
weightedSum += binQty * extrema
}

if !filled {
return 0, 0, false, nil
}
Expand Down
Loading

0 comments on commit cd95fc8

Please sign in to comment.