Skip to content

Commit

Permalink
Revert twap trade beyond end (#213)
Browse files Browse the repository at this point in the history
* revert stopping twap algo in case of trade beyond end

* fix test
  • Loading branch information
avsek477 authored Sep 15, 2022
1 parent 9856968 commit 2ab9459
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/twap/events/self_interval_tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ const onSelfIntervalTick = async (instance = {}, origin) => {
(amount > 0 && (currentSumAmount > amount)) ||
(amount < 0 && (currentSumAmount < amount))
) {
tickSignal.meta.currentSumAmount = currentSumAmount
debug('next tick would exceed total order amount, refusing')
return emit('exec:stop', null, { origin: tickSignal })
return
}
}

Expand Down
5 changes: 2 additions & 3 deletions test/lib/host/init_ao_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ describe('host:init_ao_state', () => {
})

it('provides necessary default data', () => {
const state = initAOState({ name: 'test', id: 'some-id' }, 42)

const state = initAOState({ name: 'test', id: 'some-id' }, { arg1: 42 })
assert.ok(_isArray(state.channels) && _isEmpty(state.channels))
assert.ok(_isObject(state.orders) && _isEmpty(state.orders))
assert.ok(_isObject(state.cancelledOrders) && _isEmpty(state.cancelledOrders))
assert.ok(_isObject(state.allOrders) && _isEmpty(state.allOrders))
assert.ok(state.ev instanceof AsyncEventEmitter)
assert.ok(_isString(state.label) && !_isEmpty(state.name))
assert.strictEqual(state.args, 42)
assert.deepStrictEqual(state.args, { arg1: 42, meta: { algoOrderId: 'some-id' } })
assert.strictEqual(state.id, 'some-id')
})
})

0 comments on commit 2ab9459

Please sign in to comment.