Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Linear (USDT) on the updated typescript version. #75

Merged
merged 109 commits into from
Feb 16, 2021

Conversation

peepo5
Copy link
Contributor

@peepo5 peepo5 commented Jan 21, 2021

Changelog

Summary

  • Introducing All Linear Endpoints (USDT Pairs) to the project for both rest clients and websocket client. Initiated through a seperate client (LinearClient) and stored in linear-client.ts. Most endpoints are the same as inverse, however some have different paramaters & results and some are linear specific endpoints.
    • Market Data Endpoints Added.
    • Account Data Endpoints Added.
    • Other Endpoints are contained within shared-endpoints.ts
  • Introduce Shared Endpoints that are used by both Linear and Inverse Client (Through extend to sharedendpoints.ts).
  • Transferred shared endpoints from inverse-client.ts to shared-endpoints.ts
  • Other Misc Changes (e.g Commenting, small functions).
  • Websocket Clients for Linear and shared endpoints added. Not a breaking change. Parameter "linear" can passed into websocket client if you want to use linear, however it defaults to inverse client.
  • Refactored websocket state into flexible wsStore. All websocket-specific state is now stored here.
  • Existing inverse websocket functionality is unchanged.

Breaking Changes

  • RestClient renamed to InverseClient. Only import needs rename as existing functionality is unchanged.
    • rest-client.ts renamed to inverse-client.ts
  • Depreciations of old endpoints
    • A number of endpoints were marked deprecated by bybit with a deadline for December 2020.
    • These have now been removed.
  • Websocket connection on init
    • Previous behaviour: websocket is automatically connected when websocket-client() instance is made.
    • New behaviour: websocket is automatically connected when a topic is subscribed to.
    • If the previous behaviour is necessary, earlier connections can be forced using the websocketClient.connectAll() method.

Deprecations

These are a consequence of module improvements (mainly open-api calls, to v2):

  • getActiveOrder() deprecated. Use getActiveOrderList() instead.
    • Same params & response.
  • replaceActiveOrderOld() deprecated. Use replaceActiveOrder() instead.
    • Same params & response.
  • placeConditionalOrderOld() deprecated. Use placeConditionalOrder() instead.
    • Same params & response.
  • getConditionalOrderOld() deprecated. Use getConditionalOrder() instead.
    • Same params & response.
  • cancelConditionalOrderOld() deprecated. Use cancelConditionalOrder() instead.
    • Same params & response.
  • replaceConditionalOrderOld() deprecated. Use replaceConditionalOrder() instead.
    • Same params & response.
  • replaceConditionalOrderOld() deprecated. Use replaceConditionalOrder() instead.
    • Same params & response.

Endpoint Updates

  • setTradingStop() updated from open-api to v2.
  • getLastFundingRate() updated from open-api to v2.
  • getMyLastFundingFee() updated from open-api to v2.
  • getPredictedFunding() updated from open-api to v2.
  • getApiKeyInfo() updated from open-api to v2.

Testing locally

// go to anywhere you want to save a copy of the repo locally, ideally outside your current project, and clone it
git clone git@github.com:peepopoggers/bybit-api.git

// build it
cd bybit-api
npm install
npm run tsc

// link it
npm link

// cd into your project
cd pathtoyourproject

// link it to your local bybit module
npm link bybit-api

TODO list

The following should work as before, except for any breaking changes documented above:

  • Inverse REST API, implementation, function names and params.
  • Inverse REST working as expected in testnet.
  • Inverse REST working as expected in mainnet.
  • Inverse WebSockets, implementation and usage.
  • Inverse WebSockets working as expected in testnet.
  • Inverse WebSockets working as expected in mainnet.

The following should be fully functional:

  • Linear REST API. Implementation should be similar to Inverse, except for minimal params.
  • Linear REST working as expected in testnet.
  • Linear REST working as expected in mainnet.
  • Inverse WebSockets, Implementation should be similar to Inverse, except for minimal params.
  • Inverse WebSockets working as expected in testnet.
  • Inverse WebSockets working as expected in mainnet.

Final checks:

  • Validate all of inverse endpoints for breaking changes. Any changes in behaviour should be documented.
  • Validate all of inverse endpoints for breaking changes. Any changes in behaviour should be documented.
  • Validate all of inverse endpoints for validity (params, endpoints, method order matches bybit documentation).
  • Validate all of linear endpoints for validity (params, endpoints, method order matches bybit documentation).
  • Readme has been updated based on new usage for inverse and linear, REST & WS.
  • Adding documentation for linear endpoints, and depreciating old endpoints from docs.
  • Updating documentation for new naming scheme and linear endpoints.

Copy link
Owner

@tiagosiebler tiagosiebler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally quite like the direction this is taking, nice work! Some comments although mostly minor nitpicks. My biggest caution is introducing changes to existing functionality while adding something new, although a one-line change is relatively minor.

If some of the RestClient (InverseClient) endpoints need to change I would prefer that happens in a separate smaller PR. Otherwise it's looking great, thanks for working on this!

src/shared-endpoints.ts Outdated Show resolved Hide resolved
src/shared-endpoints.ts Outdated Show resolved Hide resolved
src/util/requestWrapper.ts Outdated Show resolved Hide resolved
src/util/requestWrapper.ts Outdated Show resolved Hide resolved
src/websocket-client.ts Outdated Show resolved Hide resolved
src/websocket-client.ts Outdated Show resolved Hide resolved
src/shared-endpoints.ts Outdated Show resolved Hide resolved
Copy link
Contributor Author

@peepo5 peepo5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed some old open-api endpoints.

tiagosiebler and others added 2 commits February 7, 2021 17:01
@tiagosiebler
Copy link
Owner

Inverse is looking good. Tested on my side too with testnet and mainnet, both are consistent (with the expected breaking change to LinearClient). Still have to check linear.

Copy link
Owner

@tiagosiebler tiagosiebler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few really silly formatting requests (sorry), otherwise looking great and almost finished!

README.md Outdated Show resolved Hide resolved
src/linear-client.ts Outdated Show resolved Hide resolved
src/linear-client.ts Outdated Show resolved Hide resolved
src/linear-client.ts Outdated Show resolved Hide resolved
peepo5 and others added 4 commits February 14, 2021 17:26
Co-authored-by: Tiago <tiagosiebler@users.noreply.github.com>
Co-authored-by: Tiago <tiagosiebler@users.noreply.github.com>
Co-authored-by: Tiago <tiagosiebler@users.noreply.github.com>
Co-authored-by: Tiago <tiagosiebler@users.noreply.github.com>
src/linear-client.ts Outdated Show resolved Hide resolved
Co-authored-by: Tiago <tiagosiebler@users.noreply.github.com>
tiagosiebler
tiagosiebler previously approved these changes Feb 14, 2021
Copy link
Owner

@tiagosiebler tiagosiebler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really happy with this! Only thing left is to finish final testing of linear REST on mainnet. Nice work!

Copy link
Owner

@tiagosiebler tiagosiebler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great!

@tiagosiebler tiagosiebler merged commit 7837fc7 into tiagosiebler:master Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants