avenwedde avatar

Pythonic Tutorial Part 1-6

avenwedde

Published: 22 Dec 2019 › Updated: 22 Dec 2019Pythonic Tutorial Part 1-6

Pythonic Tutorial Part 1-6

alt

Introduction

In this series I will guide through the several functionalities of the graphical programming tool for Python — Pythonic.

Intended as an easy to use open source programming framework for crypto trading bots, it’s well tested basic functionality can be applied to various other applications as well.

If your application requires smart logging capabilities, a reliable scheduling system, connectivity options and a scalable multiprocessing concept, then Pythonic is the right choice.

1.Installation

Pythonic is based on Python 3 and is available over Pythons standard package manager Pip. Regardless of the operating system, you can install Pythonic with the following steps:

  1. Download and install Python 3 (recommended ≥ 3.5)

  2. Run pip install Pythonic

    The command will automatically collect all decencies of Pythonic. This process could take a while. If the installation was successful, you should see a message like this on the screen:

    alt
    Pip installation successful (Pythonic v0.16)

  3. Open a terminal and simply type Pythonic

  4. You should now recognize that a new windows has opened:

    alt
    Pythonic 0.16 on Gnome 3

2. Concept

The programming area consist of 5 grids which can be populated with elements. The unit of 5 grids together is called a workflow. You can populate a grid with various elements by drag and drop them from the element bar to one of the placeholders (the ,,X”-elements at the end of the execution tree). You can choose elements from the fields Basic, Binance, Connectivity and Machine Learning.


alt
Basic Elements

Each element is a atomic program which is executed in its own process.

alt
Two elements inside Grid 1

The execution flow is processed always from top to bottom and from left to right. (Of course there is a jump-to element available)

alt
Execution flow

Each element has an input and an output. When an element is triggered, the output of the former element is passed as the input to the current element. After execution, the result is passed as the output to a subsequent element.

alt
Input / Output parameter

The input and output can be of any Python type. Some elements expect a certain input type to work properly.

If you forgot to place an element to your execution flow, you can drag and drop an already setup element to the parking place (only the last element of a execution tree can be dropped).


alt
Parking space

From the parking place, the element can be placed somewhere else in one of the grids — the configuration isn’t lost!

3. Toolbar

alt
File IO


From left to right:

  • New workflow
  • Open workflow
  • Save workflow
  • Save workflow as ..

alt
Execution control


From left to right:

  • Start debug: Start the execution on all grids with a delay between the elements (adjustable under File-> Settings, default: 500ms)
  • Run: Start normal execution on all grids (without delay)
  • Stop execution on all grids (becomes effective on the transition between elements)
  • Kill running timers and child processes: As the name suggests, kill immediately all background processes such as timers etc…

Also each element has its own toolbar:


alt
Element toolbar

From top to bottom:

  • Open element configuration
  • Enable debug output: After the element was processed successfully, open a new window which shows the output of the element and pause the execution till you click on the “Ok” button.
  • Delete the element (caution: configuration is then lost!)

4. Logging

Pythonic has an easy to use logging feature: You can configure each element to create a log message when it is processed.


alt
Option for logging

The related log files are saved inside the users home directory under the following path scheme:

~/Pythonic_<Year>/<Month>/log_<Date>.txt

alt
Log files inside users home directory


This scheme makes an easy recovery of log files possible, provides traceability and ensures that log files are not overwritten. When you start Pythonic, a new log file for the current day is created (if not already present). This happens also during the transition of two days.

alt
Log file created by Pythonic

The implementation of how to create a log message within a Basic Operation element can be seen in 6. Basic Operation.

5. Basic Scheduler

alt
Basic Scheduler


The Basic Scheduler is always the first element in each grid. The output of this element is always the Python type None. In the default settings, it does simply trigger the subsequent element without repetition.

If you need this element later in the execution tree, you can find it under Basic tab of the element bar:


alt
Basic Scheduler

This element lets you define when and how often subsequent elements are triggered.

When the frame color after the initial execution stays yellow, a background timer is still active which will trigger according to the configuration.


alt
Active Basic Scheduler

6. Basic Operation

The Basic Operation element lets you execute arbitrary Python code.
You can import every Python library which is currently installed in your system.

The following predefined variables are available:

  • input…………..Access the input of the previously element
  • output…………Data which is passed to the subsequent element
  • log_txt…………User defined log message when Log output es enabled

    alt
    Basic Operation log message

    Due to the fact that the standard code input lacks features like syntax highlighting and auto-completion, you can also setup your favorite editor by activating the checkbox ”Use custom editor?”.

Windows

  • Visual Studio Code
    <Path-to-VS-Code-installation-directory>\code.exe $FILENAME
  • Notepad++
    <Path-to-Notepad++-directory>\notepad++.exe $FILENAME

Example:
D:\"Program Files (x86)”\”Microsoft VS Code”\code.exe $FILENAME

Linux

  • Vim (GNOME-Terminal >= 3.27.1 required)
    gnome-terminal — wait -e “vim $FILENAME”
  • Visual Studio Code
    code -w $FILENAME

Leave Pythonic Tutorial Part 1-6 to:

Written by

Read more #programming posts


Best Posts From avenwedde

We have not curated any of avenwedde's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From avenwedde