Skip to content

Commit b9fe397

Browse files
committed
first commit
0 parents  commit b9fe397

File tree

311 files changed

+302710
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

311 files changed

+302710
-0
lines changed

Diff for: .env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
API_KEY = treuYiilKTnxkkWxvfEXxe9J8rpOibDUVf1G40gioDFOKnf9MLCmyAbP660O9r64
2+
API_SECRET = AlP2KJPaJNTS2Ypn2edKqURZDZEs2fwah5YIXlbvEpVfm3pb2mGmLFrZxGNpbW93

Diff for: index.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
require('dotenv').config;
2+
3+
const ccxt = require('ccxt');
4+
const axios = require('axios');
5+
6+
7+
const tick = async() => {
8+
const { asset, base, spread, allocation } = config;
9+
const market = `${asset}/${base}`;
10+
11+
const order = await binanceClient.fetchOpenOrders(market);
12+
order.forEach(async order => {
13+
await binanceClient.cancelOrder(order.id);
14+
});
15+
16+
const results = await Promise.all([
17+
axios.get('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd'),
18+
axios.get('https://api.coingecko.com/api/v3/simple/price?ids=tether&vs_currencies=usd')
19+
]);
20+
21+
const marketPrice = results[0].data.bitcoin.usd / results[1].data.tether.usd;
22+
const sellPrice = marketPrice * (1 + spread);
23+
const buyPrice = marketPrice * (1 - spread);
24+
const balances = await binanceClient.fetchBalance();
25+
const assetBalance = balances.free[asset];
26+
const baseBalance = balances.free[base];
27+
const sellVolume = assetBalance * allocation;
28+
const buyVolume = (baseBalance * allocation) / marketPrice;
29+
30+
await binanceClient.createLimitSellOrder(market, sellVolume, sellPrice);
31+
await binanceClient.createLimitBuyOrder(market, buyVolume, buyPrice);
32+
33+
console.log(
34+
`New tick for ${market}...
35+
Created limit sell order for ${sellVolume}@${sellPrice}
36+
Create limit buy order for ${buyVolume}@${buyPrice}
37+
`);
38+
};
39+
40+
41+
const run = () => {
42+
const config = {
43+
asset: 'BTC',
44+
base: 'USDT',
45+
allocation: 0.1,
46+
spread: 0.2,
47+
tickInterval: 2000
48+
};
49+
50+
const binanceClient = new ccxt.binance({
51+
apiKey: process.env.API_ENV,
52+
secret: process.env.API_SECRET
53+
});
54+
tick(config, binanceClient);
55+
setInterval(tick, config.tickInterval, config, binanceClient);
56+
};
57+
58+
run()

Diff for: node_modules/axios/CHANGELOG.md

+662
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: node_modules/axios/LICENSE

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)