Skip to content

Commit

Permalink
sharpe
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Mar 24, 2019
1 parent 06ffd15 commit 5c52235
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ To use:
5. Clone this repo, cd into directory


6. Run npm i hitbtc-api express request ejs body-parser

6. Run npm i hitbtc-api express request ejs body-parser portfolio-analytics

7. Run node hitbtc.js
2 changes: 1 addition & 1 deletion READMEBINANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ To use:
5. Clone this repo, cd into directory


6. Run npm i binance-api-node express request ejs body-parser
6. Run npm i binance-api-node express request ejs body-parser portfolio-analytics


7. Run node binance.js
45 changes: 43 additions & 2 deletions hitbtc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
const HitBTC = require('hitbtc-api').default
var PortfolioAnalytics = require('portfolio-analytics');
let returnPortfolio;
let benchmark;
let zeroRisk;
let sharpe;
setInterval(function(){
rdiffs.append(rdiff)
retdiffs.append(retdiff)
var retdiffs = [0.003, 0.026, 0.011, -0.01, 0.015, 0.025, 0.016, 0.067, -0.014, 0.04, -0.005, 0.081, 0.04, -0.037, -0.061, 0.017, -0.049, -0.022, 0.07, 0.058, -0.065, 0.024, -0.005, -0.009];
var rdiffs = [0.002, 0.025, 0.018, -0.011, 0.014, 0.018, 0.014, 0.065, -0.015, 0.042, -0.006, 0.083, 0.039, -0.038, -0.062, 0.015, -0.048, 0.021, 0.06, 0.056, -0.067, 0.019, -0.003, 0];

// Build the equity curves corresponding to the returns
returnPortfolio = new Array(retdiffs.length + 1);
benchmark = new Array(rdiffs.length + 1);
zeroRisk = new Array(rdiffs.length + 1);
returnPortfolio[0] = 100;
benchmark[0] = 100;
zeroRisk[0] = 100;
for (var i=0; i<retdiffs.length; ++i) {
returnPortfolio[i+1] = returnPortfolio[i] * (1 + retdiffs[i]);
benchmark[i+1] = benchmark[i] * (1 + rdiffs[i]);
zeroRisk[i+1] = zeroRisk[i];
}
sharpe = PortfolioAnalytics.sharpeRatio(returnPortfolio, zeroRisk)
console.log('sharpe: ' + sharpe)

}, 60 * 1000);

let key = "";
let secret = "";
const restClient = new HitBTC({ key, secret, isDemo: false });
Expand Down Expand Up @@ -160,6 +188,10 @@ getTrades();
setInterval(function(){
getTrades()
}, 60 * 1001)
let rdiff = 0;
let retdiff = 0;
let rdiffs = []
let retdiffs = []
async function doPost(req, res) {
numOrders = 0;
let orders2 = (await restClient.getMyActiveOrders()).orders
Expand Down Expand Up @@ -211,7 +243,15 @@ async function doPost(req, res) {
ethtotal = (((total2 / btcs2['ETH'])));
let btcdiff = 100* (-1 * (1 - (btctotal / btcstart)));
let ethdiff = 100* (-1 * (1 - (ethtotal / ethstart)));

rdiff = refdiff;
let adiff = [usddiff, btcdiff, ethdiff]
let lll = -9999999999999999999999999999
for (var a in adiff){
if (adiff[a] > lll){
lll = adiff[a]
}
}
retdiff = lll;
totalbefore = total2;
if (req.query.name) {
res.json({
Expand All @@ -230,7 +270,8 @@ async function doPost(req, res) {
balances2 : bals4,
btcVol: btcVol,
least: least,
refdiff: refdiff
refdiff: refdiff,
sharpe: sharpe
});

} else {
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"mongodb": "*",
"path": "*",
"poloniex-api-node": "^1.9.0",
"portfolio-analytics": "0.0.4",
"request": "^2.88.0",
"serve-favicon": "*",
"socks-proxy-agent": "*",
Expand Down
5 changes: 3 additions & 2 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<script src="https://code.highcharts.com/stock/modules/export-data.js"></script>
The goal of this bot isn't to profit: it's to show off that there would be profits if we eliminated the 0.1% trading fee, or effect a market maker rebate of -0.01% or up to -0.1%. Imagine this chart as you're watching it without the steep falls after some of the green (buying) lines: those drops are fees. Imagine it with bigger climbs on some of the red (selling) lines: sales without fees. <a href="https://medium.com/@jarettrsdunn/binance-hitbtc-etc-market-maker-pitch-how-to-get-rich-online-2988c1d328ac">Read More Here.</a> <br> <br> # current orders: <div id = 'numOrders'></div> Buy orders: <div id = 'buyOrders'></div> Sell orders: <div id = 'sellOrders'></div> <br> # recent trades: <div id = 'numTrades'></div><br>All balances: <div id = "balances"></div><br>Oldest trade in recent memory: <div id = 'least'></div> and btcVol in recent memory: <div id='btcVol'></div><br>Hours since oldest trade: <div id ='hours'></div><br>Est. daily vol: <div id="dailyvol"></div><br><br>Est. 1 BTC invested: <div id="1btc"></div>Est. 5 BTC invested: <div id="5btc"></div>Est. 10 BTC invested: <div id="10btc"></div>Est. 20 BTC invested: <div id="20btc"></div>
The goal of this bot isn't to profit: it's to show off that there would be profits if we eliminated the 0.1% trading fee, or effect a market maker rebate of -0.01% or up to -0.1%. Imagine this chart as you're watching it without the steep falls after some of the green (buying) lines: those drops are fees. Imagine it with bigger climbs on some of the red (selling) lines: sales without fees. <a href="https://medium.com/@jarettrsdunn/binance-hitbtc-etc-market-maker-pitch-how-to-get-rich-online-2988c1d328ac">Read More Here.</a> <br> <br> # current orders: <div id = 'numOrders'></div> Buy orders: <div id = 'buyOrders'></div> Sell orders: <div id = 'sellOrders'></div> <br> # recent trades: <div id = 'numTrades'></div><br>All balances: <div id = "balances"></div><br>Oldest trade in recent memory: <div id = 'least'></div> and btcVol in recent memory: <div id='btcVol'></div><br>Hours since oldest trade: <div id ='hours'></div><br>Est. daily vol: <div id="dailyvol"></div><br><br>Est. 1 BTC invested: <div id="1btc"></div>Est. 5 BTC invested: <div id="5btc"></div>Est. 10 BTC invested: <div id="10btc"></div>Est. 20 BTC invested: <div id="20btc"></div><br>Minutely Sharpe vs. hold BTC: <div id="sharpe"></div>

<div id="container0" style="height: 500px; min-width: 310px"></div>
<div id="container" style="height: 500px; min-width: 310px"></div>
Expand Down Expand Up @@ -281,7 +281,8 @@ console.log(div)
console.log(jsondata.btcVol)
let dailyvol = div * jsondata.btcVol
console.log(dailyvol)
$('#dailyvol').html(dailyvol)
$('#dailyvol').html(dailyvol)
$('#sharpe').html(jsondata.sharpe)
let a = jsondata.btc / 0.01
let b2 = dailyvol / a
Expand Down

0 comments on commit 5c52235

Please sign in to comment.