Skip to content

A simple script that allows you to download historical price data from all pairs against USDT, BTC, BNB, ETH and to apply simple statistics on it, including the construction of the MVP and the OPTIMAL PORTFOLIO

License

Notifications You must be signed in to change notification settings

fedemagnani/Binance_Watcher.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binance_Watcher.js Scrutinizer Code Quality License stars - Binance_Watcher.js Twitter

I've written this code for my Bachelor thesis: "Semantica del valore, modelli fattoriali e teoria del portafoglio nel mercato delle criptovalute"

A simple script that allows you to download historical price data of all pairs against BUSD, USDT, BTC, BNB, ETH from Binance. This script allows you to get statistics from the price candles and to apply basic concepts of Modern Portfolio Theory by Harry Markowitz.

Candles, portfolio weights and returns are also saved in CSV format.

Getting started

This program requires NodeJS to be installed: https://nodejs.org/it/download/

STEPS:

  1. Open your terminal (Start > cmd)

  2. git clone https://github.com/fedemagnani/Binance_Watcher.js.git

  3. cd Binance_Watcher.js

  4. npm install (in order to install all the dependencies)

  5. node main

If you want to add other timeframes, just populate the array called timeframes at the top of main.js script. If you want to change the quote assets, just edit the array called quoteList at the top of main.js script.

This will allow you to download the last 1000 candles of each timeframe you've set (by default: "5m","30m","1h","4h","1d","1w") of ANY PAIR against the quote assets you've set (by default: "BUSD","USDT","BTC","ETH","BNB"). For example, you can check the daily USDT candles by going to /Candele_USDT/1d/ and then select the pair you want.

Asset allocation

For what regards asset allocation, the script will calculate weights for:

Efficient Frontier

Optimal Risky Portfolio

Minimum Variance Portfolio

You just have to set the number of candles required for each pair in order to be considered in the calculation of the portfolios: you can do it by changing the requiredCandles variable in main.js

By default, this script will compute the optimal portfolio built on any timeframe you've specified and on any pair related to the quote assets you've set. You can check the optimal portfolio weights, expected return, standard deviation and sharpe ratio by going to /Portafogli_Ottimi/timeframe/example.json

Frontier

In order to see graphs like this you need to change directory by typing on the command line:

cd GRAFICI_statistica_descrittiva_unicaserie

Then, you need to edit the quote and timeframe variables in base.js in order to have data from the desired quote asset and timeframe.

Finally, type on the command line

electron app

Statistics

In addition, if you go to /Statistica_Descrittiva_UnicaSerie_1d/ you can check the file that summarizes some statistics computed on the daily candles of each USDT pair, The statistics included are:

Expected Return

Variance

Standard Deviation

Sharpe Ratio

Value at risk (fifth percentile)

Ninety-fifth percentile

Skewness

Kurtosis

Downside Risk (change variable target in main.js)

About

A simple script that allows you to download historical price data from all pairs against USDT, BTC, BNB, ETH and to apply simple statistics on it, including the construction of the MVP and the OPTIMAL PORTFOLIO

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published