-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): added examples, finished adding all types, minor changes
- Loading branch information
Showing
15 changed files
with
417 additions
and
126 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 |
---|---|---|
|
@@ -23,3 +23,5 @@ bundleReport.html | |
.history/ | ||
dist | ||
coverage | ||
localtest.sh | ||
|
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,25 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function getFuturesBalances() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
// GET specific ticker | ||
const ticker = await gateRestClient.getFuturesAccount({ settle: 'usdt' }); | ||
console.log('Response: ', ticker); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
getFuturesBalances(); |
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,35 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function getFuturesOrders() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
// get open orders | ||
const orders = await gateRestClient.getFuturesOrders({ | ||
settle: 'usdt', | ||
status: 'open', | ||
}); | ||
console.log('Response: ', orders); | ||
|
||
// get finished orders | ||
const orders1 = await gateRestClient.getFuturesOrders({ | ||
settle: 'usdt', | ||
status: 'finished', | ||
}); | ||
console.log('Response: ', orders1); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
getFuturesOrders(); |
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,34 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function getFuturesTicker() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
// GET specific ticker | ||
const ticker = await gateRestClient.getFuturesTickers({ | ||
settle: 'usdt', | ||
}); | ||
console.log('Response: ', ticker); | ||
|
||
/* GET all tickers */ | ||
const allTickers = await gateRestClient.getFuturesTickers({ | ||
settle: 'usdt', | ||
contract: 'BTC_USDT', | ||
}); | ||
console.log('Response: ', allTickers); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
getFuturesTicker(); |
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,31 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function submitFuturesOrder() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
const result = await gateRestClient.submitFuturesOrder({ | ||
settle: 'usdt', | ||
contract: 'BTC_USDT', | ||
size: 0.1, // positive for long, negative for short | ||
price: '45000', | ||
tif: 'gtc', | ||
}); | ||
|
||
console.log('Response: ', result); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
submitFuturesOrder(); |
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,29 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function submitFuturesOrder() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
const result = await gateRestClient.submitFuturesOrder({ | ||
settle: 'usdt', | ||
contract: 'BTC_USDT', | ||
size: 0.1, // positive for long, negative for short | ||
}); | ||
|
||
console.log('Response: ', result); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
submitFuturesOrder(); |
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,25 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function getSpotBalances() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
// GET specific ticker | ||
const ticker = await gateRestClient.getSpotAccounts(); | ||
console.log('Response: ', ticker); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
getSpotBalances(); |
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,35 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function getSpotOrders() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
// get open orders | ||
const orders = await gateRestClient.getSpotOrders({ | ||
currency_pair: 'BTC_USDT', | ||
status: 'open', | ||
}); | ||
console.log('Response: ', orders); | ||
|
||
// get finished orders | ||
const orders1 = await gateRestClient.getSpotOrders({ | ||
currency_pair: 'BTC_USDT', | ||
status: 'finished', | ||
}); | ||
console.log('Response: ', orders1); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
getSpotOrders(); |
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,31 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function getSpotTicker() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
// GET specific ticker | ||
const ticker = await gateRestClient.getSpotTicker({ | ||
currency_pair: 'BTC_USDT', | ||
}); | ||
console.log('Response: ', ticker); | ||
|
||
/* GET all tickers */ | ||
const allTickers = await gateRestClient.getSpotTicker(); | ||
console.log('Response: ', allTickers); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
getSpotTicker(); |
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,32 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function submitSpotOrder() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
const result = await gateRestClient.submitSpotOrder({ | ||
currency_pair: 'BTC_USDT', | ||
side: 'buy', | ||
type: 'limit', | ||
amount: '0.10', | ||
price: '45000', | ||
time_in_force: 'gtc', | ||
}); | ||
|
||
console.log('Response: ', result); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
submitSpotOrder(); |
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,31 @@ | ||
import { RestClient } from '../../src'; | ||
|
||
const account = { | ||
key: process.env.API_KEY || 'yourApiHere', | ||
secret: process.env.API_SECRET || 'yourSecretHere', | ||
}; | ||
|
||
const gateRestClient = new RestClient({ | ||
apiKey: account.key, | ||
apiSecret: account.secret, | ||
}); | ||
|
||
async function submitSpotOrder() { | ||
try { | ||
console.log('Using API keys:', account); | ||
|
||
const result = await gateRestClient.submitSpotOrder({ | ||
currency_pair: 'BTC_USDT', | ||
side: 'buy', | ||
type: 'market', | ||
amount: '10', | ||
time_in_force: 'ioc', | ||
}); | ||
|
||
console.log('Response: ', result); | ||
} catch (e) { | ||
console.error(`Error in execution: `, e); | ||
} | ||
} | ||
|
||
submitSpotOrder(); |
Oops, something went wrong.