Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

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

- name: Install dependencies
Expand All @@ -24,12 +24,12 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y openvpn

- name: Download IVPN config
run: |
wget -O ivpn-config.zip "https://api.ivpn.net/v5/config/ivpn-openvpn-config.zip?country=NL&city=Amsterdam&proto=udp&port=2049"
unzip ivpn-config.zip

- name: Start IVPN connection
run: |
echo "${{ secrets.IVPN_ACCOUNT_NUMBER }}" > auth.txt
Expand All @@ -39,12 +39,18 @@ jobs:

- name: Run typecheck
run: npm run typecheck
- name: Lint and Prettier
run: npm run lint && npm run prettier:check
- name: Static Tests
run: npm run static-tests
- name: All Tests
run: npm test

- name: Run checks
run: npm run ci
# - name: Run checks
# run: npm run ci

- name: Cleanup VPN
if: always()
run: |
sudo killall openvpn || true
rm -f auth.txt
rm -f auth.txt
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"tabWidth": 4,
"arrowParens": "avoid",
"overrides": [
{
Expand Down
33 changes: 33 additions & 0 deletions examples/create-order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Binance from 'index'

const client = Binance({
apiKey: 'your_api_key_here',
apiSecret: 'your_api_secret_here',
})


async function main() {
try {
const order = await client.order({
symbol: 'LTCUSDT',
side: 'BUY',
type: 'LIMIT',
quantity: 0.1,
price:90,
timeInForce: 'GTC'
})
console.log(order.id)

// will cancel the order
const result = await client.cancelOrder({
symbol: 'LTCUSDT',
orderId: order.id,
})
console.log(result)
} catch (error) {
console.error(error)
}
}

main()
// node --require @babel/register examples/create-order.js
16 changes: 16 additions & 0 deletions examples/fetch-orderbook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Binance from 'index'


const client = Binance({
})

async function main() {
const spotOb = await client.book({ symbol: 'BTCUSDT' })
console.log('Spot Orderbook:', spotOb)

const futuresOb = await client.futuresBook({ symbol: 'BTCUSDT' })
console.log('Futures Orderbook:', futuresOb)
}

main()
// node --require @babel/register examples/fetch-orderbook.js
16 changes: 16 additions & 0 deletions examples/fetch-prices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Binance from 'index'


const client = Binance({
})

async function main() {
const spotPrices = await client.prices()
console.log('Spot Prices:', spotPrices)

const futuresPrices = await client.futuresPrices()
console.log('Futures Prices:', futuresPrices)
}

main()
// node --require @babel/register examples/fetch-prices.js
94 changes: 93 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
"cover": "nyc ava",
"report": "npm run cover && nyc report --reporter=text-lcov | coveralls",
"lint": "eslint src",
"static-tests": "ava test/static-tests.js",
"prettier": "prettier --write '{src,test}/**/*.{ts,js}'",
"prettier:check": "prettier -l '{src,test}/**/*.{ts,js}'",
"ci": "npm run lint && npm run prettier:check && npm run test",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"publishPackage": "npm run build && sh publish.sh && git push && git push --tags && npm publish"
},
"dependencies": {
"https-proxy-agent": "^5.0.0",
Expand All @@ -43,6 +45,7 @@
"eslint": "^6.7.1",
"eslint-config-prettier": "^6.7.0",
"eslint-config-zavatta": "^6.0.3",
"nock": "^14.0.10",
"nyc": "^14.1.1",
"prettier": "^3.5.3",
"ts-node": "^10.9.1",
Expand Down
21 changes: 21 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#!/bin/bash
set -e

# release defaults to patch (last number in semver)
RELEASE="patch" && [ -n "$1" ] && RELEASE=$1

# cut the release
VERSION=$(npm --no-git-tag-version version $RELEASE | sed 's/v//')

git add package.json
git commit -m "release: cut the $VERSION release"

# tag the release
git tag $VERSION
git tag -l

echo -e "\033[1;92m You are ready to publish!"
echo -e "\033[1;95m git push"
echo -e "\033[1;95m git push --tags"
echo -e "\033[1;95m npm publish"
Loading
Loading