Code Monkey home page Code Monkey logo

kairos's Introduction

Kairos

Web automation tool using Python, Selenium and Chrome's Web Driver. Kairos aims to help you save time by automating repetitive tasks on TradingView such as refreshing alerts and creating new ones.

There are a number of instruction videos available:

  1. How to install Kairos on Windows
  2. How to use Kairos to browse through a watch list
  3. How to use Kairos to save a screener as a watch list
  4. How to use Kairos to create TradingView alerts
  5. How to use Kairos to create summary mails and export data

Table of contents

Features

  • Set alerts automatically on TradingView through web automation.
  • Define multiple charts with multiple alerts per chart on multiple time frames in one file.
  • Add (limited) dynamic data to your alert messages.
  • Run from command line and in the background.
  • Send a summary mail.
  • Generate a TradingView watchlist from the summary mail.
  • Import generated TradingView watchlist.
  • Send signals to a webhook/endpoint or a Google Sheet

Prerequisites

Note: when you install Python on Windows make sure that it's part of your PATH.

Installing

If you run Ubuntu 18.04 there is a list of commands here: Ubuntu 18.04 - command line installation.

From archive (Linux, OS X and Windows)

If you are running Linux / OS X then run listed commands with sudo

pip install setuptools
pip install --upgrade setuptools
  • Run the following command from the Kairos directory:
python setup.py install

From source

  • Install / update setuptools:
pip install setuptools
pip install --upgrade setuptools
  • Clone archive and install:
git clone --recursive https://github.com/timelyart/kairos.git
cd Kairos
python setup.py install

Ubuntu 18.04 - command line installation

cd ~/
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt-get update
sudo apt-get install google-chrome-stable
sudo apt-get install unzip
sudo apt-get install python3.7
sudo apt-get install python3-setuptools
wget https://chromedriver.storage.googleapis.com/2.43/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/chromedriver
sudo chown root:root /usr/bin/chromedriver
sudo chmod +x /usr/bin/chromedriver
mkdir -p Git/repositories
cd Git/repositories/
git clone https://github.com/timelyart/Kairos.git
cd Kairos/
sudo python3 setup.py install

Post installation

  • Open the Kairos directory
  • Rename _kairos.cfg to kairos.cfg and open it.
  • Take good notice of the options that are available to you in the kairos.cfg. Fill in the blanks and adjust to your preference and limitations.
  • Rename _example.yaml to example.yaml and open it.
  • Edit the example.yaml to your liking. Study the section Defining TradingView alerts to get a feeling for the structure of the document. Together with the inline documentation within the YAML file, it should give you a good idea on how to cater it to your preferences. If you have questions please contact me.
  • Finally, run the following command from the Kairos directory:
python main.py example.yaml

TIP: Run Kairos periodically using s scheduler. Use a separate file for each interval you wish to run, e.g. weekly.yaml, daily.yaml and 4hourly.yaml.

Defining TradingView alerts

You can define which alerts Kairos should set in so-called YAML files. Use the example.yaml as a base for your own yaml file. NOTE: all values are case sensitive and should be exactly the same as when you manually create an alert.

When creating/editing YAML files you have to be careful with indentation. If you have errors in your YAML, Kairos error messages give good hints where the error is with a line and column number. However, as of 1.3.0 Kairos will create a temporary YAML based upon your own file. In case of an error a my_file.yaml.err will be created. The line and column numbers that Kairos shows refer to that .err file. Another way of testing if your YAML file is correct is by using a website like https://yamlchecker.com

Steps:

  • Create a chart and plot the indicators you would like to set alerts on
  • Create a new yaml entry (use the template below) and set the chart's url
- url:
  timeframes: []
  watchlists: []
  alerts:
  - name:
    conditions: []
    options: "Once Per Bar Close"
    expiration: 86400
    show_popup: no
    sound:
      play: no
      ringtone: Hand Bell
      duration: 10 seconds
    send:
      email: yes
      email-to-sms: no
      sms: no
      notify-on-app: no
    message:
      prepend: no
      text:
  • Fill in the timeframe(s) and watchlist(s) you want to use
  • Create a mock up alert and write down the options (case sensitive!) you select in order (going from left to right and from top to bottom)
  • Fill in the rest of the template with your written down values

You can define in one file multiple charts with each chart having multiple alerts, like this:

charts:
- url:
  timeframes: []
  watchlists: []
  alerts:
  - name:
    conditions: []
    options: "Once Per Bar Close"
    expiration: 86400
    show_popup: no
    sound:
      play: no
      ringtone: Hand Bell
      duration: 10 seconds
    send:
      email: yes
      email-to-sms: no
      sms: no
      notify-on-app: no
    message:
      prepend: no
      text:
  - name:
    conditions: []
    options: "Only Once"
    expiration: 2
    show_popup: no
    sound:
      play: no
      ringtone: Hand Bell
      duration: 10 seconds
    send:
      email: yes
      email-to-sms: no
      sms: no
      notify-on-app: no
    message:
      prepend: no
      text:
- url:
  timeframes: []
  watchlists: []
  alerts:
  - name:
    conditions: []
    options: "Once Per Bar Close"
    expiration: 86400
    show_popup: no
    sound:
      play: no
      ringtone: Hand Bell
      duration: 10 seconds
    send:
      email: yes
      email-to-sms: no
      sms: no
      notify-on-app: no
    message:
      prepend: no
      text:      

YAML within YAML

As of version 1.3.0 you can load YAML files from any other YAML file by including the following in your YAML file:

file: path_to/my_other_yaml_file.yaml 

Consider root.yaml:

root:
  - branch:
      - branch: ["leaf", "leaf", "leaf"]
      - file: "branch_in_branch.yaml"
  - branch: ["leaf", "leaf", "leaf"]
  - file: "branch_in_branch.yaml"

By using other YAML files you can re-use parts of your YAML and share them with other YAML definition you may have.

If you find yourself copying and pasting a lot, you might want to consider to put some or all of that code into a separate YAML file.

The files needed to run root.yaml can be found in the folder yaml and I highly encourage to look into them to figure out how they work.

Command line examples

  • Refresh your existing alerts (depends on the settings in your kairos.cfg so proceed with caution).
python main.py refresh.yaml
  • Browse through your watchlist going from symbol to symbol at a regular interval.
    1. Rename _browse.yaml to browse.yaml and open it
    2. Fill in the blanks
    3. Run:
    python main.py browse.yaml
    
  • Generate a summary mail from unread TradingView Alert mails
python main.py -s

Troubleshooting

A lot can go wrong running web automation tools like Kairos. These are the most common ones:

  • The web page / server hasn't handled the interaction (a click or some input) yet before the next interaction is tried
  • A popup is displayed over the point that Kyros wants to interact with, e.g. a tooltip or TradingView's 'too many devices message'.
  • A form (e.g. an alert)was submitted but you don't see results.
  • The markup of the web page has changed thereby breaking the flow Kairos.

These issues are all related and amount to Kairos unable to either find an element or to interact with an element. You will get errors (see debug.log) like:

  • Message: unknown error: [...] is not clickable at point [...]
  • Time out exceptions
  • Not clickable exceptions
  • Not visible exceptions

Solutions

Run multiple times

If you are running Kairos for the first time, then Chrome hasn't cached anything yet. Try to run it a couple of times and ignore any errors. Of course, clearing the cache will, in all likelihood, spawn the same issues again.

Run on a different time of day

At certain times during the day TradingView can become less responsive. Try to run Kairos on a different time. If the issue persists, try to Increase delays

Increase delays

If you have run Kairos five times or so, and still encounter issues try to increase the break_mini, break and / or submit_alert in the kairos.cfg.

Check existing issues

If, after increasing wait times, you still get errors then the markup of the web page may have changed. Check if it is an existing issue, and if it is not: open one.

Feedback

Feedback is invaluable. Please, take the time to give constructive feedback by opening an issue so that this project may be improved on code and documentation.

Acknowledgements

DorukKorkmaz, for providing a starting point with his TradingView scraper.

PaulMcG, for his timing module

Author

timelyart

Donate

If you find value in this project and you would like to donate, please do so here

License

This project is licensed under the GNU GPLv3 License - see the LICENSE.md file for details.

kairos's People

Contributors

timelyart avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.