thrasher-corp / gocryptotrader

A cryptocurrency trading bot and framework supporting multiple exchanges written in Golang.
MIT License
2.95k stars 793 forks source link

Deribit: bug fixes, test fixes and implement GetCurrencyTradeURL #1558

Closed gloriousCode closed 1 month ago

gloriousCode commented 1 month ago

PR Description

These are the kinds of bugs that can only pop up after proper use, it was still an excellent PR Sam 🕊️

This PR does the following:

I made sure that getAssetPairByInstrument was performant before using it

func BenchmarkGetAssetPairByInstrumentFutures(b *testing.B) {
    b.ReportAllocs()
    for i := 0; i < b.N; i++ {
        _, _, err := d.getAssetPairByInstrument("DOGE_USDC-PERPETUAL")
        if err != nil {
            b.Fatal(err)
        }
    }
}

func BenchmarkGetAssetPairByInstrumentOptions(b *testing.B) {
    b.ReportAllocs()
    for i := 0; i < b.N; i++ {
        _, _, err := d.getAssetPairByInstrument("MATIC_USDC-3JUN24-0D64-P")
        if err != nil {
            b.Fatal(err)
        }
    }
}

func BenchmarkGetAssetPairByInstrumentSpot(b *testing.B) {
    b.ReportAllocs()
    for i := 0; i < b.N; i++ {
        _, _, err := d.getAssetPairByInstrument("DOGE_USDC")
        if err != nil {
            b.Fatal(err)
        }
    }
}
BenchmarkGetAssetPairByInstrumentFutures-10     11103615           108.5 ns/op        36 B/op          2 allocs/op
BenchmarkGetAssetPairByInstrumentOptions-10      7306069           139.4 ns/op        68 B/op          2 allocs/op
BenchmarkGetAssetPairByInstrumentSpot-10        12750432            96.06 ns/op       20 B/op          2 allocs/op

Type of change

How has this been tested

Checklist

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 73.60406% with 52 lines in your changes missing coverage. Please review.

Project coverage is 38.20%. Comparing base (c37a115) to head (bd5d4c9). Report is 5 commits behind head on master.

:exclamation: Current head bd5d4c9 differs from pull request most recent head 171915c

Please upload reports for the commit 171915c to get more accurate results.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558/graphs/tree.svg?width=650&height=150&src=pr&token=41784B23TS&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp)](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp) ```diff @@ Coverage Diff @@ ## master #1558 +/- ## ========================================== + Coverage 37.78% 38.20% +0.41% ========================================== Files 409 419 +10 Lines 147697 152314 +4617 ========================================== + Hits 55807 58191 +2384 - Misses 84031 86023 +1992 - Partials 7859 8100 +241 ``` | [Files](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp) | Coverage Δ | | |---|---|---| | [exchanges/kline/kline.go](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558?src=pr&el=tree&filepath=exchanges%2Fkline%2Fkline.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp#diff-ZXhjaGFuZ2VzL2tsaW5lL2tsaW5lLmdv) | `91.78% <100.00%> (+0.05%)` | :arrow_up: | | [exchanges/orderbook/orderbook.go](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558?src=pr&el=tree&filepath=exchanges%2Forderbook%2Forderbook.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp#diff-ZXhjaGFuZ2VzL29yZGVyYm9vay9vcmRlcmJvb2suZ28=) | `92.26% <100.00%> (ø)` | | | [exchanges/deribit/deribit.go](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558?src=pr&el=tree&filepath=exchanges%2Fderibit%2Fderibit.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp#diff-ZXhjaGFuZ2VzL2RlcmliaXQvZGVyaWJpdC5nbw==) | `45.89% <87.50%> (ø)` | | | [exchanges/deribit/deribit\_websocket.go](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558?src=pr&el=tree&filepath=exchanges%2Fderibit%2Fderibit_websocket.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp#diff-ZXhjaGFuZ2VzL2RlcmliaXQvZGVyaWJpdF93ZWJzb2NrZXQuZ28=) | `42.68% <64.15%> (ø)` | | | [exchanges/deribit/deribit\_wrapper.go](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558?src=pr&el=tree&filepath=exchanges%2Fderibit%2Fderibit_wrapper.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp#diff-ZXhjaGFuZ2VzL2RlcmliaXQvZGVyaWJpdF93cmFwcGVyLmdv) | `43.68% <72.27%> (ø)` | | ... and [70 files with indirect coverage changes](https://app.codecov.io/gh/thrasher-corp/gocryptotrader/pull/1558/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=thrasher-corp)