Skip to content

Commit 2c32341

Browse files
authored
Merge pull request #180 from ProofSuite/v1.0.1
V1.0.1
2 parents e49fc82 + 4cdf027 commit 2c32341

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

services/info.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package services
22

33
import (
4+
"log"
45
"math/big"
56
"time"
67

@@ -187,7 +188,10 @@ func (s *InfoService) GetExchangeStats() (*types.ExchangeStats, error) {
187188
for _, t := range tradeData {
188189
if t.AddressCode() == p.AddressCode() {
189190
totalTrades = totalTrades + int(t.Count.Int64())
190-
totalVolume = totalVolume + t.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
191+
192+
if exchangeRate := rates[p.BaseTokenSymbol]; exchangeRate != 0 {
193+
totalVolume = totalVolume + t.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
194+
}
191195

192196
pairTradeCounts[p.Name()] = int(t.Count.Int64())
193197
tokenTradeCounts[p.BaseTokenSymbol] = tokenTradeCounts[p.BaseTokenSymbol] + int(t.Count.Int64())
@@ -197,15 +201,19 @@ func (s *InfoService) GetExchangeStats() (*types.ExchangeStats, error) {
197201
for _, o := range bidsData {
198202
if o.AddressCode() == p.AddressCode() {
199203
// change and replace by equivalent dollar volume instead of order count
200-
totalBuyOrderAmount = totalBuyOrderAmount + o.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
204+
if exchangeRate := rates[p.BaseTokenSymbol]; exchangeRate != 0 {
205+
totalBuyOrderAmount = totalBuyOrderAmount + o.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
206+
}
201207
totalBuyOrders = totalBuyOrders + int(o.OrderCount.Int64())
202208
}
203209
}
204210

205211
for _, o := range asksData {
206212
if o.AddressCode() == p.AddressCode() {
207213
// change and replace by equivalent dollar volume instead of order count
208-
totalSellOrderAmount = totalSellOrderAmount + o.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
214+
if exchangeRate := rates[p.BaseTokenSymbol]; exchangeRate != 0 {
215+
totalSellOrderAmount = totalSellOrderAmount + o.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
216+
}
209217
totalSellOrders = totalSellOrders + int(o.OrderCount.Int64())
210218
}
211219
}
@@ -235,6 +243,8 @@ func (s *InfoService) GetExchangeStats() (*types.ExchangeStats, error) {
235243
TradeSuccessRatio: tradeSuccessRatio,
236244
}
237245

246+
log.Printf("%+v\n", stats)
247+
238248
return stats, nil
239249
}
240250

@@ -412,7 +422,10 @@ func (s *InfoService) GetExchangeData() (*types.ExchangeData, error) {
412422
pairData.AverageTradeAmount = math.Div(t.Volume, t.Count)
413423

414424
totalTrades = totalTrades + int(t.Count.Int64())
415-
totalVolume = totalVolume + t.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
425+
426+
if exchangeRate := rates[p.BaseTokenSymbol]; exchangeRate != 0 {
427+
totalVolume = totalVolume + t.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
428+
}
416429

417430
pairTradeCounts[p.Name()] = int(t.Count.Int64())
418431
tokenTradeCounts[p.BaseTokenSymbol] = tokenTradeCounts[p.BaseTokenSymbol] + int(t.Count.Int64())
@@ -426,8 +439,10 @@ func (s *InfoService) GetExchangeData() (*types.ExchangeData, error) {
426439
pairData.BidPrice = o.BestPrice
427440
pairData.AverageOrderAmount = math.Div(pairData.OrderVolume, pairData.OrderCount)
428441

429-
// change and replace by equivalent dollar volume instead of order count
430-
totalBuyOrderAmount = totalBuyOrderAmount + o.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
442+
if exchangeRate := rates[p.BaseTokenSymbol]; exchangeRate != 0 {
443+
totalBuyOrderAmount = totalBuyOrderAmount + o.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
444+
}
445+
431446
totalBuyOrders = totalBuyOrders + int(o.OrderCount.Int64())
432447
}
433448
}
@@ -439,8 +454,10 @@ func (s *InfoService) GetExchangeData() (*types.ExchangeData, error) {
439454
pairData.AskPrice = o.BestPrice
440455
pairData.AverageOrderAmount = math.Div(pairData.OrderVolume, pairData.OrderCount)
441456

442-
// change and replace by equivalent dollar volume instead of order count
443-
totalSellOrderAmount = totalSellOrderAmount + o.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
457+
if exchangeRate := rates[p.BaseTokenSymbol]; exchangeRate != 0 {
458+
totalSellOrderAmount = totalSellOrderAmount + o.ConvertedVolume(&p, rates[p.BaseTokenSymbol])
459+
}
460+
444461
totalSellOrders = totalSellOrders + int(o.OrderCount.Int64())
445462

446463
//TODO change price into orderbook price

start-local-rinkeby.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ AMP_MONGODB_URL=localhost; \
33
AMP_MONGODB_DBNAME=proofdex; \
44
AMP_EXCHANGE_CONTRACT_ADDRESS=0x9c446449fbc378941586Ef7a2196B13CC12AEBcd; \
55
AMP_ETHEREUM_NODE_HTTP_URL=https://rinkeby.infura.io; \
6-
AMP_ETHEREUM_NODE_WS_URL=wss://rinkeby.infura.io/_ws; \
6+
AMP_ETHEREUM_NODE_WS_URL=wss://rinkeby.infura.io/ws; \
77
AMP_ENABLE_TLS=false; \
88
fresh

tmp/runner-build

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)