Thursday, November 5, 2020

Ubuntu

Basic notation

abc@abcmachine:~$

Meaning: user "abc" is logged into virtual machine "abcmachine". "~" means user is current location is the home folder. "$" is the prompt symbol.


Basic ubuntu commands


mkdir

make directory


mkdir .env

Make directory of the hidden type (hidden directory begins with ".")

By convention, we use hidden directories to create a virtual environment.


ls

display visible contents (files & folders) in current directory


ls -la

display visible+invisible contents in current directory


touch ex_if.py

create an empty file "ex_if.py" in the current directory


cat ex_if.py

display contents of the file "ex_if.py". Useful to identify the correct file (before executing it) by looking at its 1st page contents. Not useful to read contents of a big file.


python3 ex_if.py

run the python file "ex_if.py" using python3


cd ..

go up one directory


Shift+Ctrl+C

copy selected item


Shift+Ctrl+V

paste copied item


Ctrl+C

Cancel any ongoing program or script


virtualenv .env/freqtrade

Install virtual environment inside the project folder called "freqtrade" in the hidden folder ".env"

This inserts another copy of python components within the folder "freqtrade", so that if u screw up, u can just delete this folder and reinstall the components again.


source .env/freqtrade/bin/activate

Activate the virtual environment. U will see the prompt have an extra prefix "(freqtrade)". Moving forward, anything u do will occur within the virtual environment (within the ubuntu VM). No longer occurs at the ubuntu VM level. If u execute "python" or "pip", it will run those scripts found in the virtual environment, not in the virtual machine.


deactivate

Deactivate the virtual environment. The prompt's prefix of "(freqtrade)" disappears. Anything done will now occur at the ubuntu VM level.


import time

to import the entire package/module "time" (created by someone else) into memory to use the functions within; uses more memory


from time import sleep

to import only the function "sleep" from within the package/module "time"; use less memory


How to import a function from another file:

  • Lets say this the folder structure:
    • user1@computer1:~/Exercises/myfunctions.py
    • user1@computer1:~/Exercises/myscript.py
  • myfunctions.py                              #(this file stores all your functions used in the project)
    • def hellofunc():                    
      • print("hello")
  • myscript.py (this file stores your sequence of todo's, including how u use the functions)
    • from myfunctions import hellofunc       #access the file "myfunctions.py" (must be in same folder as myscript.py), then import "hellofunc()" to memory
    • hellofunc()                                              #run the function


-------------------------------------

SUMMARY: Always Do This First

1. Start VM (Oracle VM VirtualBox > Start a saved machine)

2. In Ubuntu, open terminal (Ctrl+Alt+T)

3. Activate your virtual environment

user1@computer1:~$ cd freqtrade

user1@computer1:~/freqtrade$ source .env/bin/activate


------------------------------------

Summary: Starting the Bot

A1. Start Bot with specific Config File

(.env) user1@computer1:~/freqtrade$ python3 ./freqtrade/main.py -c config.json

Note: executing the above command will also cause telegram bot to start returning messages

A2. Start Bot with specific Config File & Apply to Top 100 pairs with highest volume

Go to exchange, check volume of all pairs, then select the top 100 pairs with highest volume, then apply your strategy

(.env) user1@computer1:~/freqtrade$ python3 ./freqtrade/main.py -c config.json --dynamic-whitelist 100


------------------------------------

Summary: workflow to edit an existing strategy:

1. Load atom within freqtrade folder (type "atom .")

(.env) user1@computer1:~/freqtrade$ atom .

2. Open the default strategy file

freqtrade > freqtrade > strategy > default_strategy.py

Note: If an identical strategy is found in the default_strategy.py file, it will override the strategy in the config.json file

-----------------------------------

Summary: To create a new strategy:

1. Load atom within freqtrade folder (type "atom .")

(.env) user1@computer1:~/freqtrade$ atom .

2. To create a new strategy:

Atom > File > New File > copy contents from "freqtrade > freqtrade > strategy > default_strategy.py" & paste into new file > save as "freqtrade > freqtrade > strategy > bb_rsi.py" whereby bb_rsi.py is new filename

In file "bb_rsi.py", change "class DefaultStrategy(IStrategy):" to "class Bb_Rsi(IStrategy):"

3. Tell bot how to find the new strategy

Open "freqtrade\freqtrade\strategy\__init__.py"

Add line (immediately below "from freqtrade.strategy.default_strategy import DefaultStrategy"): 

"from freqtrade.strategy.bb_rsi import Bb_Rsi"

whereby "bb_rsi" is the python filename and "Bb_Rsi" is the class


CONTINNUE WITH CHAPTER 36 (CODING THE STRATEGY) @8:38

----------------------------------

Some config tips (in config.json)

"dry_run": true,    #use fake money to run a simulation



Continue at chapter 34 (Strategy Explanation)

How to Enable Virtualization on WINDOWS 10 PC with GIGABYTE motherboard and AMD RYZEN 5

My specs (run DXDIAG within Windows to view this info)

- Motherboard: GIGABYTE B450M S2H

- BIOS: F50

- Processor: AMD Ryzen 5 3600 6-core Processor (12 CPUs, ~3.6GHz)


Steps:

1. Windows button > Recovery option > Advanced startup > Restart now > Troubleshoot > Advanced options > UEFI Firmware settings > Restart

2. If PC remains black for an undetermined amount of time (and BIOS menu does not appear), try unplugging and replug monitor to CPU.

2.1 If PC still displays a black screen, hit the RESET button. The GIGABYTE logo should appear (see step 3 below).

3. When you see the startup screen with the big GIGABYTE logo, hit DELETE (this instruction appears at bottom left of screen).

4. In the BIOS menu: 

  • Change language to English.
  • M.I.T. > Advance frequency settings > Advanced core CPU settings > SVM Mode > Enable > Save & exit


Enabling SVM mode will turn on virtualization on your windows 10 PC. 

How to confirm? Ctrl+Alt+Del > Task Manager > Performance tab > you will see "Virtualization: Enabled".


Popular Posts