1.3.0-beta.1: introduce typescript, webpack, better overall browser support, deprecate assert calls

This commit is contained in:
tiagosiebler
2020-12-13 17:19:18 +00:00
parent 6f30c2d659
commit 0606525e96
18 changed files with 3351 additions and 660 deletions

View File

@@ -24,6 +24,12 @@ Most methods accept JS objects. These can be populated using parameters specifie
- [Bybit API Inverse Documentation](https://bybit-exchange.github.io/docs/inverse/#t-introduction).
- [Bybit API Linear Documentation (not supported yet)](https://bybit-exchange.github.io/docs/linear/#t-introduction)
## Structure
This project uses typescript. Resources are stored in 3 key structures:
- [src](./src) - the whole connector written in typescript
- [lib](./lib) - the javascript version of the project (compiled from typescript). This should not be edited directly, as it will be overwritten with each release.
- [dist](./dist) - the packed bundle of the project for use in browser environments.
### Inverse Contracts
#### Rest client
```javascript
@@ -31,8 +37,39 @@ const {RestClient} = require('bybit-api');
const API_KEY = 'xxx';
const PRIVATE_KEY = 'yyy';
const useLivenet = false;
const client = new RestClient(API_KEY, PRIVATE_KEY);
const restInverseOptions = {
// override the max size of the request window (in ms)
recv_window?: number;
// how often to sync time drift with bybit servers
sync_interval_ms?: number | string;
// Default: false. Disable above sync mechanism if true.
disable_time_sync?: boolean;
// Default: false. If true, we'll throw errors if any params are undefined
strict_param_validation?: boolean;
// Optionally override API protocol + domain
// e.g 'https://api.bytick.com'
baseUrl?: string;
// Default: true. whether to try and post-process request exceptions.
parse_exceptions?: boolean;
};
const client = new RestClient(
API_KEY,
PRIVATE_KEY,
// optional, uses testnet by default. Set to 'true' to use livenet.
useLivenet,
// restInverseOptions,
// requestLibraryOptions
);
client.changeUserLeverage({leverage: 4, symbol: 'ETHUSD'})
.then(result => {