-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#186): add proxy & rate limits example. Misc doc updates.
- Loading branch information
tiagosiebler
committed
Dec 22, 2023
1 parent
923b1b0
commit 48eaa47
Showing
17 changed files
with
216 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Deprecated Examples | ||
|
||
The examples in this folder use old/deprecated/obsolete APIs. They should all have a modern alternative. | ||
|
||
As of December 2023, use the V5 APIs & WebSockets. |
2 changes: 1 addition & 1 deletion
2
examples/rest-contract-private.ts → examples/deprecated/rest-contract-private.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/rest-copy-private.ts → examples/deprecated/rest-copy-private.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/rest-linear-public.ts → examples/deprecated/rest-linear-public.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/rest-raw-v3sign.ts → examples/deprecated/rest-raw-v3sign.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/rest-spot-public.ts → examples/deprecated/rest-spot-public.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ples/rest-unified-margin-public-cursor.ts → ...ated/rest-unified-margin-public-cursor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/ws-private-copytrading-v3.ts → ...s/deprecated/ws-private-copytrading-v3.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { RestClientV5 } from '../src/index'; | ||
|
||
// or | ||
// import { RestClientV5 } from 'bybit-api'; | ||
|
||
const key = process.env.API_KEY_COM; | ||
const secret = process.env.API_SECRET_COM; | ||
|
||
const client = new RestClientV5( | ||
{ | ||
key: key, | ||
secret: secret, | ||
parseAPIRateLimits: true, | ||
testnet: true, | ||
// Sometimes using a proxy introduces recv timestamp errors (due to the extra latency) | ||
// If that happens, you can try increasing the recv window (which is 5000ms by default) | ||
// recv_window: 10000, | ||
}, | ||
{ | ||
proxy: { | ||
host: 'proxyhost', | ||
port: Number('proxyport'), | ||
auth: { | ||
username: 'proxyuserifneeded', | ||
password: 'proxypassifneeded', | ||
}, | ||
}, | ||
}, | ||
); | ||
|
||
(async () => { | ||
try { | ||
const res = await client.getWalletBalance({ accountType: 'UNIFIED' }); | ||
|
||
console.log('response: ', JSON.stringify(res, null, 2)); | ||
|
||
// const orders = await client.batchSubmitOrders('linear', [ | ||
// { | ||
// symbol: 'ETHUSDT', | ||
// orderType: 'Limit', | ||
// side: 'Buy', | ||
// qty: '1', | ||
// orderIv: '6', | ||
// timeInForce: 'GTC', | ||
// orderLinkId: 'option-test-001', | ||
// mmp: false, | ||
// reduceOnly: false, | ||
// }, | ||
// { | ||
// symbol: 'ETHUSDT', | ||
// orderType: 'Limit', | ||
// side: 'Sell', | ||
// qty: '2', | ||
// price: '700', | ||
// timeInForce: 'GTC', | ||
// orderLinkId: 'option-test-001', | ||
// mmp: false, | ||
// reduceOnly: false, | ||
// }, | ||
// ]); | ||
|
||
// console.log('orders: ', JSON.stringify(orders, null, 2)); | ||
} catch (e) { | ||
console.error('request failed: ', e); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { | ||
APIResponseV3WithTime, | ||
CategoryListV5, | ||
RestClientV5, | ||
TickerLinearInverseV5, | ||
} from '../src/index'; | ||
|
||
// or | ||
// import { RestClientV5 } from 'bybit-api'; | ||
|
||
/** | ||
* If you don't plan on making any private api calls, | ||
* you can instance the REST client without any parameters | ||
*/ | ||
const client = new RestClientV5(); | ||
|
||
(async () => { | ||
try { | ||
// const klineResult = await client.getKline({ | ||
// category: 'linear', | ||
// interval: '15', | ||
// symbol: 'BTCUSDT', | ||
// }); | ||
// console.log('klineResult: ', klineResult); | ||
|
||
// const markPriceKlineResult = await client.getMarkPriceKline({ | ||
// category: 'linear', | ||
// interval: '15', | ||
// symbol: 'BTCUSDT', | ||
// }); | ||
// console.log('markPriceKlineResult: ', markPriceKlineResult); | ||
|
||
// const indexPriceKline = await client.getIndexPriceKline({ | ||
// category: 'linear', | ||
// interval: '15', | ||
// symbol: 'BTCUSDT', | ||
// }); | ||
// console.log('indexPriceKline: ', indexPriceKline); | ||
|
||
// const openInterest = await client.getOpenInterest({ | ||
// category: 'linear', | ||
// symbol: 'BTCUSDT', | ||
// intervalTime: '5min', | ||
// }); | ||
|
||
const tickers = await client.getTickers({ category: 'linear' }); | ||
// console.log( | ||
// JSON.stringify( | ||
// tickers.result.list.map((ticker) => ticker.symbol), | ||
// null, | ||
// 2, | ||
// ), | ||
// ); | ||
|
||
console.log('response', tickers); | ||
// openInterest.result.list.forEach((row) => { | ||
// console.log('int: ', { | ||
// timestamp: row.timestamp, | ||
// value: row.openInterest, | ||
// }); | ||
// }); | ||
// console.log('openInterest: ', openInterest.result.list); | ||
} catch (e) { | ||
console.error('request failed: ', e); | ||
} | ||
})(); |