mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 07:26:48 +00:00
Asset update to fix minor stutter (#316)
This commit is contained in:
committed by
Adrian Gallagher
parent
b901c4b670
commit
20c24601fb
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/thrasher-/gocryptotrader/common"
|
||||
"github.com/thrasher-/gocryptotrader/currency"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/assets"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
|
||||
log "github.com/thrasher-/gocryptotrader/logger"
|
||||
)
|
||||
@@ -121,7 +121,7 @@ func (b *Bitstamp) WsHandleData() {
|
||||
currencyPair := strings.Split(wsResponse.Channel, "_")
|
||||
p := currency.NewPairFromString(strings.ToUpper(currencyPair[3]))
|
||||
|
||||
err = b.wsUpdateOrderbook(wsOrderBookTemp.Data, p, assets.AssetTypeSpot)
|
||||
err = b.wsUpdateOrderbook(wsOrderBookTemp.Data, p, asset.Spot)
|
||||
if err != nil {
|
||||
b.Websocket.DataHandler <- err
|
||||
continue
|
||||
@@ -144,7 +144,7 @@ func (b *Bitstamp) WsHandleData() {
|
||||
Amount: wsTradeTemp.Data.Amount,
|
||||
CurrencyPair: p,
|
||||
Exchange: b.GetName(),
|
||||
AssetType: assets.AssetTypeSpot,
|
||||
AssetType: asset.Spot,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ func (b *Bitstamp) WsHandleData() {
|
||||
|
||||
func (b *Bitstamp) generateDefaultSubscriptions() {
|
||||
var channels = []string{"live_trades_", "diff_order_book_"}
|
||||
enabledCurrencies := b.GetEnabledPairs(assets.AssetTypeSpot)
|
||||
enabledCurrencies := b.GetEnabledPairs(asset.Spot)
|
||||
subscriptions := []exchange.WebsocketChannelSubscription{}
|
||||
for i := range channels {
|
||||
for j := range enabledCurrencies {
|
||||
@@ -193,7 +193,7 @@ func (b *Bitstamp) Unsubscribe(channelToSubscribe exchange.WebsocketChannelSubsc
|
||||
return b.WebsocketConn.WriteJSON(req)
|
||||
}
|
||||
|
||||
func (b *Bitstamp) wsUpdateOrderbook(ob websocketOrderBook, p currency.Pair, assetType assets.AssetType) error {
|
||||
func (b *Bitstamp) wsUpdateOrderbook(ob websocketOrderBook, p currency.Pair, assetType asset.Item) error {
|
||||
if len(ob.Asks) == 0 && len(ob.Bids) == 0 {
|
||||
return errors.New("bitstamp_websocket.go error - no orderbook data")
|
||||
}
|
||||
@@ -251,7 +251,7 @@ func (b *Bitstamp) wsUpdateOrderbook(ob websocketOrderBook, p currency.Pair, ass
|
||||
}
|
||||
|
||||
func (b *Bitstamp) seedOrderBook() error {
|
||||
p := b.GetEnabledPairs(assets.AssetTypeSpot)
|
||||
p := b.GetEnabledPairs(asset.Spot)
|
||||
for x := range p {
|
||||
orderbookSeed, err := b.GetOrderbook(p[x].String())
|
||||
if err != nil {
|
||||
@@ -278,7 +278,7 @@ func (b *Bitstamp) seedOrderBook() error {
|
||||
newOrderBook.Asks = asks
|
||||
newOrderBook.Bids = bids
|
||||
newOrderBook.Pair = p[x]
|
||||
newOrderBook.AssetType = assets.AssetTypeSpot
|
||||
newOrderBook.AssetType = asset.Spot
|
||||
|
||||
err = b.Websocket.Orderbook.LoadSnapshot(&newOrderBook, b.GetName(), false)
|
||||
if err != nil {
|
||||
@@ -287,7 +287,7 @@ func (b *Bitstamp) seedOrderBook() error {
|
||||
|
||||
b.Websocket.DataHandler <- exchange.WebsocketOrderbookUpdate{
|
||||
Pair: p[x],
|
||||
Asset: assets.AssetTypeSpot,
|
||||
Asset: asset.Spot,
|
||||
Exchange: b.GetName(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/thrasher-/gocryptotrader/config"
|
||||
"github.com/thrasher-/gocryptotrader/currency"
|
||||
exchange "github.com/thrasher-/gocryptotrader/exchanges"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/assets"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/asset"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/orderbook"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/request"
|
||||
"github.com/thrasher-/gocryptotrader/exchanges/ticker"
|
||||
@@ -52,8 +52,8 @@ func (b *Bitstamp) SetDefaults() {
|
||||
b.API.CredentialsValidator.RequiresClientID = true
|
||||
|
||||
b.CurrencyPairs = currency.PairsManager{
|
||||
AssetTypes: assets.AssetTypes{
|
||||
assets.AssetTypeSpot,
|
||||
AssetTypes: asset.Items{
|
||||
asset.Spot,
|
||||
},
|
||||
UseGlobalFormat: true,
|
||||
RequestFormat: ¤cy.PairFormat{
|
||||
@@ -144,7 +144,7 @@ func (b *Bitstamp) Run() {
|
||||
}
|
||||
|
||||
// FetchTradablePairs returns a list of the exchanges tradable pairs
|
||||
func (b *Bitstamp) FetchTradablePairs(asset assets.AssetType) ([]string, error) {
|
||||
func (b *Bitstamp) FetchTradablePairs(asset asset.Item) ([]string, error) {
|
||||
pairs, err := b.GetTradingPairs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -166,16 +166,16 @@ func (b *Bitstamp) FetchTradablePairs(asset assets.AssetType) ([]string, error)
|
||||
// UpdateTradablePairs updates the exchanges available pairs and stores
|
||||
// them in the exchanges config
|
||||
func (b *Bitstamp) UpdateTradablePairs(forceUpdate bool) error {
|
||||
pairs, err := b.FetchTradablePairs(assets.AssetTypeSpot)
|
||||
pairs, err := b.FetchTradablePairs(asset.Spot)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return b.UpdatePairs(currency.NewPairsFromStrings(pairs), assets.AssetTypeSpot, false, forceUpdate)
|
||||
return b.UpdatePairs(currency.NewPairsFromStrings(pairs), asset.Spot, false, forceUpdate)
|
||||
}
|
||||
|
||||
// UpdateTicker updates and returns the ticker for a currency pair
|
||||
func (b *Bitstamp) UpdateTicker(p currency.Pair, assetType assets.AssetType) (ticker.Price, error) {
|
||||
func (b *Bitstamp) UpdateTicker(p currency.Pair, assetType asset.Item) (ticker.Price, error) {
|
||||
var tickerPrice ticker.Price
|
||||
tick, err := b.GetTicker(p.String(), false)
|
||||
if err != nil {
|
||||
@@ -199,7 +199,7 @@ func (b *Bitstamp) UpdateTicker(p currency.Pair, assetType assets.AssetType) (ti
|
||||
}
|
||||
|
||||
// FetchTicker returns the ticker for a currency pair
|
||||
func (b *Bitstamp) FetchTicker(p currency.Pair, assetType assets.AssetType) (ticker.Price, error) {
|
||||
func (b *Bitstamp) FetchTicker(p currency.Pair, assetType asset.Item) (ticker.Price, error) {
|
||||
tick, err := ticker.GetTicker(b.GetName(), p, assetType)
|
||||
if err != nil {
|
||||
return b.UpdateTicker(p, assetType)
|
||||
@@ -218,7 +218,7 @@ func (b *Bitstamp) GetFeeByType(feeBuilder *exchange.FeeBuilder) (float64, error
|
||||
}
|
||||
|
||||
// FetchOrderbook returns the orderbook for a currency pair
|
||||
func (b *Bitstamp) FetchOrderbook(p currency.Pair, assetType assets.AssetType) (orderbook.Base, error) {
|
||||
func (b *Bitstamp) FetchOrderbook(p currency.Pair, assetType asset.Item) (orderbook.Base, error) {
|
||||
ob, err := orderbook.Get(b.GetName(), p, assetType)
|
||||
if err != nil {
|
||||
return b.UpdateOrderbook(p, assetType)
|
||||
@@ -227,7 +227,7 @@ func (b *Bitstamp) FetchOrderbook(p currency.Pair, assetType assets.AssetType) (
|
||||
}
|
||||
|
||||
// UpdateOrderbook updates and returns the orderbook for a currency pair
|
||||
func (b *Bitstamp) UpdateOrderbook(p currency.Pair, assetType assets.AssetType) (orderbook.Base, error) {
|
||||
func (b *Bitstamp) UpdateOrderbook(p currency.Pair, assetType asset.Item) (orderbook.Base, error) {
|
||||
var orderBook orderbook.Base
|
||||
orderbookNew, err := b.GetOrderbook(p.String())
|
||||
if err != nil {
|
||||
@@ -303,7 +303,7 @@ func (b *Bitstamp) GetFundingHistory() ([]exchange.FundHistory, error) {
|
||||
}
|
||||
|
||||
// GetExchangeHistory returns historic trade data since exchange opening.
|
||||
func (b *Bitstamp) GetExchangeHistory(p currency.Pair, assetType assets.AssetType) ([]exchange.TradeHistory, error) {
|
||||
func (b *Bitstamp) GetExchangeHistory(p currency.Pair, assetType asset.Item) ([]exchange.TradeHistory, error) {
|
||||
return nil, common.ErrNotYetImplemented
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ func (b *Bitstamp) GetOrderHistory(getOrdersRequest *exchange.GetOrdersRequest)
|
||||
if quoteCurrency.String() != "" && baseCurrency.String() != "" {
|
||||
currPair = currency.NewPairWithDelimiter(baseCurrency.String(),
|
||||
quoteCurrency.String(),
|
||||
b.CurrencyPairs.Get(assets.AssetTypeSpot).ConfigFormat.Delimiter)
|
||||
b.CurrencyPairs.Get(asset.Spot).ConfigFormat.Delimiter)
|
||||
}
|
||||
orderDate := time.Unix(order.Date, 0)
|
||||
orders = append(orders, exchange.OrderDetail{
|
||||
|
||||
Reference in New Issue
Block a user