GCT: general updates across codebase (#699)

* orderbook: export orderbook nodes for external strategy inspection

* orderbook: Add in methods for locking and unlocking multiple books at the same time e.g. book1.LockWith(book2); defer book1.UnlockWith(book2)

* include waiting functionality for depth change alert

* backtester: add word.

* log: include logger changes to impl with downstream integration

* engine: reduce params for loading exchange

* assort: rm verbose in tests, change wording in ob, expose sync.waitgroup for ext. sync options

* ticker: reduce map look ups and contention when using RW mutex when there are over 80% writes adds find last function to get the latest rate

* engine/syncmanager: add in waitgroup for step over for external package calls

* cleaup

* engine: linter fix

* currency/fx: include all references to fiat currencies to default

* orderbook: Add in fields to Unsafe type for strategies to detect potential out of sync book operations

* syncmanager: changed config variable to display correct time

* ordermanager: Add time when none provided

* currency/manager: update getasset param to get enabled assets for minor optimizations

* ftx: use get all wallet balances for a better accounts breakdown

* orderbook: unlock in reverse order

* bithumb: fixes bug on market buy and sell orders

* bithumb: fix bug for nonce is also time window sensitive

* bithumb: get orders add required parameter

* bithumb: Add asset type to account struct

* currency: improve log output when checking currency and it fails

* bithumb: Add error return on incomplete pair

* ticker:unexport all service related methods

* ticker/currency: fixes

* orderbook: fix comment

* engine: revert variable name in LoadExchange method

* sync_manager: fix panic when enabling disabling manager

* engine: fix naming convention of exported function and comments

* engine: update comment

* orderbook: fix comment for unsafe type
This commit is contained in:
Ryan O'Hara-Reid
2021-07-29 14:42:28 +10:00
committed by GitHub
parent 4f5ab42bd8
commit a2381310da
64 changed files with 842 additions and 562 deletions

View File

@@ -15,11 +15,11 @@ var (
defaultAllowance = time.Second * 30
)
// node defines a linked list node for an orderbook item
type node struct {
value Item
next *node
prev *node
// Node defines a linked list node for an orderbook item
type Node struct {
Value Item
Next *Node
Prev *Node
// Denotes time pushed to stack, this will influence cleanup routine when
// there is a pause or minimal actions during period
shelved time.Time
@@ -27,7 +27,7 @@ type node struct {
// stack defines a FILO list of reusable nodes
type stack struct {
nodes []*node
nodes []*Node
sema uint32
count int32
}
@@ -51,7 +51,7 @@ func getNow() now {
// Push pushes a node pointer into the stack to be reused the time is passed in
// to allow for inlining which sets the time at which the node is theoretically
// pushed to a stack.
func (s *stack) Push(n *node, tn now) {
func (s *stack) Push(n *Node, tn now) {
if !atomic.CompareAndSwapUint32(&s.sema, neutral, active) {
// Stack is in use, for now we can dereference pointer
n = nil
@@ -59,9 +59,9 @@ func (s *stack) Push(n *node, tn now) {
}
// Adds a time when its placed back on to stack.
n.shelved = time.Time(tn)
n.next = nil
n.prev = nil
n.value = Item{}
n.Next = nil
n.Prev = nil
n.Value = Item{}
// Allows for resize when overflow TODO: rethink this
s.nodes = append(s.nodes[:s.count], n)
@@ -71,17 +71,17 @@ func (s *stack) Push(n *node, tn now) {
// Pop returns the last pointer off the stack and reduces the count and if empty
// will produce a lovely fresh node
func (s *stack) Pop() *node {
func (s *stack) Pop() *Node {
if !atomic.CompareAndSwapUint32(&s.sema, neutral, active) {
// Stack is in use, for now we can allocate a new node pointer
return &node{}
return &Node{}
}
if s.count == 0 {
// Create an empty node when no nodes are in slice or when cleaning
// service is running
atomic.StoreUint32(&s.sema, neutral)
return &node{}
return &Node{}
}
s.count--
n := s.nodes[s.count]