Google Sheet - Average Rotations Dashboard LIVE
Note: As of Nov 2021, this will be scheduled to run just 1x per day to save resources.
Avg Rotation Dash is a dashboard showing statistics of "rotations" for different financial instruments. It is mainly for manual intraday and algorithmic traders.
The point of measuring rotations is to give us reasonable (but dynamic) expectations of risk.
Avg Rotation Dash downloads free tick data from Dukascopy, then resamples the ticks and measures rotations. Results are written to Google Sheets, where stats and visualizations may be further customized.
The script can run or be scheduled locally, or hosted in the cloud (using services such as PythonAnywhere, GCP, or AWS).
The idea of measuring rotations originally came from FT71 (FuturesTrader71):
The code for downloading ticks from Dukascopy came originally from these repos:
terukusu / download-tick-from-dukascopy
Also thanks to:
-
"File" > "Make a copy" of this Google Sheet
-
Download and unzip this repo to where you'll run it (local, PythonAnywhere, AWS, et cetera).
-
Run
pip install gspread
-
Get service account credentials for Google Sheets:
-
Create a new project in Google Cloud Console.
-
Create a service account (name it and click through rest of options).
-
Once you're back on the credentials page, click "Service Account" > "Keys" > "Add key" > "Create new key". Select JSON (default) and it will download. Copy the service account e-mail.
-
Click and drag the JSON credentials into to your repo folder (just inside the main folder, the script will find it automatically).
-
Share your Google Sheet with the service account e-mail (as editor).
-
-
In the main repo folder, open
settings.py
to adjust your settings (explained below).
In settings.py
:
SHEET_ID (required): Id of the Google Sheet you copied. Looks like "1Ur7CJJu-cDkhcFjEXG4smsxlKYc_323PcPYloLEvshA".
DATE_RANGE (default 5): Number of business days to download data. Days outside of this will be deleted (to manage storage).
INTERVAL (default '5Min'): Ticks will be resampled to this time period. Accepts rules such as "1Min", "1H", or anything from pandas.DataFrame.resample. Higher timeframes will give you higher level swings, but less data points.
ROTATIONS_AVG (default 20): Periods for moving average over rotation results. Displays in the Sheet as a chart, and a single number (average of last 20 rotations).
INSTS (default GBPUSD, USA500IDXUSD, BTCUSD): This is a multi-line string, just add somewhere in the string and the script will parse it. Uses names from Dukascopy, without the "." or "/"'s.
Run locally:
python run_all.py
Schedule in PythonAnywhere:
python3.6 /home/samcha/avg-rot-dash/run_all.py
If you are having issues, it may be due to the script not handling scaling for every single instrument that exists. This happens converting the ticks from binary (in download_dukas.py
). If you're downloading an obscure instrument, edit normalize_tick()
to handle it.
Scaling also occurs for *JPY and other fx instruments, in rotations.py
. Again, if you're looking at obscure instruments you may handle scaling in this file.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.