gocryptotrader
gocryptotrader copied to clipboard
depth: Add methods to derive liquidity allowances on orderbooks by volume and slippage
gctcli:
- Merge getOrderbookCommand, whaleBombCommand, getOrderbookStreamCommand, getExchangeOrderbookStreamCommand to orderbookcommand
- Link RPCServer to GetOrderbookMovement, GetOrderbookAmountByNominal, GetOrderbookAmountByImpact and add to orderbookcommand
calculator.go:
- Add test and update WhaleBomb() as this was potentially wiping out request price on tranche in either direction. Assign actual impact pct.
- Refactor SimulateOrder()
- Remove duplication orderSummary ([]Item) and associated methods
- Update buy and sell to DeploymentAction to already include required datatypes for callers
depth.go:
-
Add method GetBaseFromNominalSlippage() to derive max base when hitting the bids to the desired nominal slippage target from a reference price
-
Add method GetQuoteFromNominalSlippage() to derive max quotation when lifting the asks to the desired nominal slippage target from a reference price
-
Add method GetBaseFromImpactSlippage() to derive max base when hitting the bids to the desired impact slippage target from a reference price
-
Add method GetQuoteFromImpactSlippage() to derive max quotation when lifting the asks to the desired impact slippage target from a reference price
-
Add method GetMovementByBase() to derive the impact/nominal percentage and costings in a quotation by the potential base amount hitting the bids from the reference price
-
Add method GetMovementByQuote() to derive the impact/nominal percentage and costings in a quotation by the potential quote amount lifting the asks from the reference price
- include from mid price reference method
- include best price reference method
-
Add supplemtary methods GetMidPrice() GetBestBid(), GetBestAsk() to get price reference
~~NOTES: Nominal slippage results are not accurate by my calculations, I need help here.~~ It's accurate now.
Please delete options that are not relevant and add an x
in []
as item is complete.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
How has this been tested
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and also consider improving test coverage whilst working on a certain feature or package.
- [ ] go test ./... -race
- [ ] golangci-lint run
- [ ] Test X
Checklist
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally and on Github Actions/AppVeyor with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
Thanks for making those changes! I just ran a test to make sure I was understanding the calculations correctly. I called
getSlippageByVolume
with a drop in price from 100->90 and I would have expected a slippage value of 10%, however, it returned9.999999999999998
. The function(math.CalculatePercentageGainOrLoss(90.0, 100.0)
returns 10. I know you have done tests on your method of doing the calculations and it is more accurate in some cases, just thought I'd point this out
Yeah, that was a super wrong implementation. I have fixed that now and added more robust tests.