DEV Community

Cover image for Day 01

Posted on

Day 01

Date: 19 May, 2024.
Introduction--> Hi I am Rohit. I am a stock market trader. Now I am planning to learn algo trading. For that, I have chosen Python as my programming language. I will be writing blogs to document my progress in it.

Basic:- Python is a high-level language. By high-level we mean, many things like memory management are taken care of in the background. The modern python is both compiled and interpreted language. Our code is first compiled and converted into a byte file. This is then interpreted line by line in PVM(a program that provides an environment to run Python).

Variable:- Variables are things in which we can store data. We have to follow some rules in naming a variable(these rules are the same for naming any other thing in Python)
1) The only characters we can use are numbers(0-9), small case letters(a-z), capital letters(A-Z) and underscore(_).
2) The name should not start with a number
3) we use snake case conviction for writing names eg snake_case
4) Avoid using keywords(words which are assigned special meaning/use in Python)
5) We use all capital letters for variables whose values we don't want to change
The rule 3, 4 & 5 are not binding. Violating them won't give any error except 4 which may sometimes give error.

Data types:- There are primary 4 data types in Python.
1) Integer - for whole numbers eg 23, -4, 0. We can't write data as 02.
2) Float - for numbers containing decimals eg 2.47, 3.14.
3) String - sequence of characters eg "this is Ron"
4) Booleans - True & False. These are used in building logic.

String:- String is a sequence of characters, where each character is assigned a unique integer value(index). The leftmost side is assigned 0 as the index value and +1 as we move to the right side. On screen, it's basically a text. We can use double or single quotes to represent it, but only one type. These two are used for single-line strings. For multiple lines, we use double quotes 3 times ("""...""").
Escape characters - used for introducing special characters or modifying character meaning in the interpreter.
Some are:
\n insert line break,
\t insert tab
\" allow using double quotes inside the double quotes
\' allow using single quotes inside the single quotes
\\ insert backslash
String concatenation - it is the process of joining two or more strings. We use + operator for this.
eg "string1 " + "string2" >> "string1 string2".

Comments - the text that developers use for explaining what code will do. This is ignored by the interpreter. To indicate a comment we start it with #. We can also use multi-line strings for comments.

Functions:- Function is a name given to a part of code that performs a specified task. To use it we have to call that function. To call we use the name of the function and the brackets '()', eg func(). We pass some data(called arguments) into it(sometimes we don't pass any value). It performs a specific task and returns a value. For the best understanding, just imagine that returned value replaces the function call.
Python provides many built-in functions. Some I learned are:-
1) print(..) shows data passed on the screen
2) input(..) shows data passed on the screen and waits for the user to enter(input) some data
3) len(string) returns the length of the string. Don't confuse it with index as it starts counting from 1.
4) id(variable) returns the memory address of that variable. It is not a binary address, but a unique number assigned by python library to the variable. It is different each time we run the program.
! A library is a pre-written file containing many functions, which we can use or interpreter uses.

Thanks for reading my blog, I would love to hear any guidance or feedback if possible.

Personal --> This is just my informal talk, you can skip it. So why learn algorithmic trading? To be honest I don't have a perfect answer to that. My programmer friend suggested I should look into this, so I am just giving it a try. If it works for me all good, if not that's also okay for me. I am also not ignoring the job perspective of it. I have chosen python as my programming language as it will be easier for a beginner like me. Later, if I like algo trading I will surely try to learn Rust or C++.
Today day 1 was harder for me, it took me more time to cover than I thought. I am learning python from Dr. Angela Yu course on udemy. I am giving 1 year time to myself to learn algo trading. Let's see how it goes. Thanks if you have read this also.

Top comments (0)