engine/gRPC: Add update account info to grpc interface (#602)

* Add update account info to grpc interface

* Fix lbank tests

* Review corrections

* Review corrections

* Fix linter
This commit is contained in:
Mikhail Shogin
2020-11-30 01:29:31 +01:00
committed by GitHub
parent b7d99f741d
commit ba4ac4f3d6
13 changed files with 416 additions and 100 deletions

View File

@@ -26,9 +26,9 @@ type TickerResponse struct {
// MarketDepthResponse stores arrays for asks, bids and a timestamp for a currecy pair
type MarketDepthResponse struct {
ErrCapture `json:",omitempty"`
Asks [][]float64 `json:"asks"`
Bids [][]float64 `json:"bids"`
Timestamp int64 `json:"timestamp"`
Asks [][]string `json:"asks"`
Bids [][]string `json:"bids"`
Timestamp int64 `json:"timestamp"`
}
// TradeResponse stores date_ms, amount, price, type, tid for a currency pair

View File

@@ -248,19 +248,38 @@ func (l *Lbank) UpdateOrderbook(p currency.Pair, assetType asset.Item) (*orderbo
if err != nil {
return nil, err
}
a, err := l.GetMarketDepths(fpair.String(), "60", "1")
if err != nil {
return orderBook, err
}
for i := range a.Asks {
price, convErr := strconv.ParseFloat(a.Asks[i][0], 64)
if convErr != nil {
return orderBook, convErr
}
amount, convErr := strconv.ParseFloat(a.Asks[i][1], 64)
if convErr != nil {
return orderBook, convErr
}
orderBook.Asks = append(orderBook.Asks, orderbook.Item{
Price: a.Asks[i][0],
Amount: a.Asks[i][1]})
Price: price,
Amount: amount,
})
}
for i := range a.Bids {
price, convErr := strconv.ParseFloat(a.Bids[i][0], 64)
if convErr != nil {
return orderBook, convErr
}
amount, convErr := strconv.ParseFloat(a.Bids[i][1], 64)
if convErr != nil {
return orderBook, convErr
}
orderBook.Bids = append(orderBook.Bids, orderbook.Item{
Price: a.Bids[i][0],
Amount: a.Bids[i][1]})
Price: price,
Amount: amount,
})
}
orderBook.Pair = p
orderBook.ExchangeName = l.Name