Skip to content

Commit 518296e

Browse files
authored
Merge pull request #680 from carlosmiei/add-proxy-support
feat(client): add demo trading and other fixes
2 parents f9810c5 + df601c4 commit 518296e

26 files changed

Lines changed: 4899 additions & 4107 deletions

.github/workflows/ci.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
- uses: actions/cache@v4
1616
with:
17-
path: '**/node_modules'
17+
path: "**/node_modules"
1818
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
1919

2020
- name: Install dependencies
@@ -24,12 +24,12 @@ jobs:
2424
run: |
2525
sudo apt-get update
2626
sudo apt-get install -y openvpn
27-
27+
2828
- name: Download IVPN config
2929
run: |
3030
wget -O ivpn-config.zip "https://api.ivpn.net/v5/config/ivpn-openvpn-config.zip?country=NL&city=Amsterdam&proto=udp&port=2049"
3131
unzip ivpn-config.zip
32-
32+
3333
- name: Start IVPN connection
3434
run: |
3535
echo "${{ secrets.IVPN_ACCOUNT_NUMBER }}" > auth.txt
@@ -39,12 +39,18 @@ jobs:
3939
4040
- name: Run typecheck
4141
run: npm run typecheck
42+
- name: Lint and Prettier
43+
run: npm run lint && npm run prettier:check
44+
- name: Static Tests
45+
run: npm run static-tests
46+
- name: All Tests
47+
run: npm test
4248

43-
- name: Run checks
44-
run: npm run ci
49+
# - name: Run checks
50+
# run: npm run ci
4551

4652
- name: Cleanup VPN
4753
if: always()
4854
run: |
4955
sudo killall openvpn || true
50-
rm -f auth.txt
56+
rm -f auth.txt

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"semi": false,
44
"singleQuote": true,
55
"trailingComma": "all",
6-
"tabWidth": 2,
6+
"tabWidth": 4,
77
"arrowParens": "avoid",
88
"overrides": [
99
{

examples/create-order.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Binance from 'index'
2+
3+
const client = Binance({
4+
apiKey: 'your_api_key_here',
5+
apiSecret: 'your_api_secret_here',
6+
})
7+
8+
9+
async function main() {
10+
try {
11+
const order = await client.order({
12+
symbol: 'LTCUSDT',
13+
side: 'BUY',
14+
type: 'LIMIT',
15+
quantity: 0.1,
16+
price:90,
17+
timeInForce: 'GTC'
18+
})
19+
console.log(order.id)
20+
21+
// will cancel the order
22+
const result = await client.cancelOrder({
23+
symbol: 'LTCUSDT',
24+
orderId: order.id,
25+
})
26+
console.log(result)
27+
} catch (error) {
28+
console.error(error)
29+
}
30+
}
31+
32+
main()
33+
// node --require @babel/register examples/create-order.js

examples/fetch-orderbook.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Binance from 'index'
2+
3+
4+
const client = Binance({
5+
})
6+
7+
async function main() {
8+
const spotOb = await client.book({ symbol: 'BTCUSDT' })
9+
console.log('Spot Orderbook:', spotOb)
10+
11+
const futuresOb = await client.futuresBook({ symbol: 'BTCUSDT' })
12+
console.log('Futures Orderbook:', futuresOb)
13+
}
14+
15+
main()
16+
// node --require @babel/register examples/fetch-orderbook.js

examples/fetch-prices.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Binance from 'index'
2+
3+
4+
const client = Binance({
5+
})
6+
7+
async function main() {
8+
const spotPrices = await client.prices()
9+
console.log('Spot Prices:', spotPrices)
10+
11+
const futuresPrices = await client.futuresPrices()
12+
console.log('Futures Prices:', futuresPrices)
13+
}
14+
15+
main()
16+
// node --require @babel/register examples/fetch-prices.js

package-lock.json

Lines changed: 93 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
"cover": "nyc ava",
1515
"report": "npm run cover && nyc report --reporter=text-lcov | coveralls",
1616
"lint": "eslint src",
17+
"static-tests": "ava test/static-tests.js",
1718
"prettier": "prettier --write '{src,test}/**/*.{ts,js}'",
1819
"prettier:check": "prettier -l '{src,test}/**/*.{ts,js}'",
1920
"ci": "npm run lint && npm run prettier:check && npm run test",
20-
"typecheck": "tsc --noEmit"
21+
"typecheck": "tsc --noEmit",
22+
"publishPackage": "npm run build && sh publish.sh && git push && git push --tags && npm publish"
2123
},
2224
"dependencies": {
2325
"https-proxy-agent": "^5.0.0",
@@ -43,6 +45,7 @@
4345
"eslint": "^6.7.1",
4446
"eslint-config-prettier": "^6.7.0",
4547
"eslint-config-zavatta": "^6.0.3",
48+
"nock": "^14.0.10",
4649
"nyc": "^14.1.1",
4750
"prettier": "^3.5.3",
4851
"ts-node": "^10.9.1",

publish.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
#!/bin/bash
3+
set -e
4+
5+
# release defaults to patch (last number in semver)
6+
RELEASE="patch" && [ -n "$1" ] && RELEASE=$1
7+
8+
# cut the release
9+
VERSION=$(npm --no-git-tag-version version $RELEASE | sed 's/v//')
10+
11+
git add package.json
12+
git commit -m "release: cut the $VERSION release"
13+
14+
# tag the release
15+
git tag $VERSION
16+
git tag -l
17+
18+
echo -e "\033[1;92m You are ready to publish!"
19+
echo -e "\033[1;95m git push"
20+
echo -e "\033[1;95m git push --tags"
21+
echo -e "\033[1;95m npm publish"

0 commit comments

Comments
 (0)