mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-21 07:26:48 +00:00
* Initial REST managed order updating
* Apply gloriousCode's changes.go patch
* Update internal order ID handling
* Check error
* Replace string with string pointer
* Avoid nil pointers in upsert
* Update test for UpdateOrderFromDetail()
* Add tests for orders.go
* Remove unnecessary newline
* Address comments
* Add missing nil check
* Add tests for new functions in order_manager.go
* Remove empty line
* Change log level for updates from Info to Debug (keep added orders at Info)
* Initialize orders before running the timer
* [TEMP] Add verbosity for debugging
* Nil checking on exchangeManager in GetExchanges()
- exchangeManager.GetExchanges() and iExchangeManager.GetExchanges() return an error on nil
- bot.GetExchanges() wraps exchangeManager.GetExchanges() and returns an empty slice
* Revert b5afe1a46b
* Do not start the order manager runner thread
Instead, mark the order manager as running
* Remove redundant error.Is() and remove print wrapper on msg
* Add atomic blocker and waitgroup on processOrders()
* Disable unnecessary orderManager runner thread for rpcserver_test
* Remove redundant err from orderStore.getActiveOrders()
* [FIX] Populate requiresProcessing using UpsertResponse data instead of REST return data
.. because the data returned by the REST calls do not include the internal user ID's
* [TEST] Verify that processOrders() actually processes queried order data
* Remove leftover warning and add nil check on wg.Done()
* Apply suggestions from code review
Log category changes - as suggested
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
* Return when no exchanges available
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/thrasher-corp/gocryptotrader/common"
|
||||
"github.com/thrasher-corp/gocryptotrader/currency"
|
||||
"github.com/thrasher-corp/gocryptotrader/exchanges/validate"
|
||||
@@ -208,6 +209,9 @@ func (d *Detail) UpdateOrderFromDetail(m *Detail) {
|
||||
if d.ID == "" {
|
||||
d.ID = m.ID
|
||||
}
|
||||
if d.InternalOrderID == "" {
|
||||
d.InternalOrderID = m.InternalOrderID
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateOrderFromModify Will update an order detail (used in order management)
|
||||
@@ -405,6 +409,40 @@ func (d *Detail) MatchFilter(f *Filter) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsActive returns true if an order has a status that indicates it is
|
||||
// currently available on the exchange
|
||||
func (d *Detail) IsActive() bool {
|
||||
if d.Amount <= 0 || d.Amount <= d.ExecutedAmount {
|
||||
return false
|
||||
}
|
||||
return d.Status == Active || d.Status == Open || d.Status == PartiallyFilled || d.Status == New ||
|
||||
d.Status == AnyStatus || d.Status == PendingCancel || d.Status == Hidden || d.Status == UnknownStatus ||
|
||||
d.Status == AutoDeleverage || d.Status == Pending
|
||||
}
|
||||
|
||||
// IsInactive returns true if an order has a status that indicates it is
|
||||
// currently not available on the exchange
|
||||
func (d *Detail) IsInactive() bool {
|
||||
if d.Amount <= 0 || d.Amount <= d.ExecutedAmount {
|
||||
return true
|
||||
}
|
||||
return d.Status == Filled || d.Status == Cancelled || d.Status == InsufficientBalance || d.Status == MarketUnavailable ||
|
||||
d.Status == Rejected || d.Status == PartiallyCancelled || d.Status == Expired || d.Status == Closed
|
||||
}
|
||||
|
||||
// GenerateInternalOrderID sets a new V4 order ID or a V5 order ID if
|
||||
// the V4 function returns an error
|
||||
func (d *Detail) GenerateInternalOrderID() {
|
||||
if d.InternalOrderID == "" {
|
||||
var id uuid.UUID
|
||||
id, err := uuid.NewV4()
|
||||
if err != nil {
|
||||
id = uuid.NewV5(uuid.UUID{}, d.ID)
|
||||
}
|
||||
d.InternalOrderID = id.String()
|
||||
}
|
||||
}
|
||||
|
||||
// Copy will return a copy of Detail
|
||||
func (d *Detail) Copy() Detail {
|
||||
c := *d
|
||||
|
||||
Reference in New Issue
Block a user