Daily Digital Sketch

September 24, 2020 Leave a comment

Here is the daily-sketch for today. I am using Galaxy Note 9 and Samsung Note Application for drawing and Coloring..

more on my Twitter here H.ta3kees

Two years ago Sketch

August 21, 2020 2 comments

Looking back in my sketchbooks this is a sketch from Two years back on same day 21.8.2018, this Winnie the Pooh was a sticker on my Daughter pincel case. I color it last week using my Galaxy Note 9.

Python: Shares Speculation System – Part 7

August 18, 2020 Leave a comment


Learning : Python, DataBase, SQL, SQlite3
Subject: Plan, Design and Build a Shares Speculation System

Project Card:
Project Name: Shares Speculation System
By: Ali
Date: 2.7.2020
Version: V01-2.7.2020

In this Part we will write the Function to Delete a Transaction from the System, and will write the last part of show_all_Transaction function.
First we will write a Function to Delete a Transaction, we have two types of Transactions “Buying” and “Selling” so the user will select the Transaction Type to delete.
1. Buying Transaction: If the user select to Delete a Buying Transaction, we will call show_all function to display all the Buying Transactions and the ask the user to Enter the ID of the record to be Deleted. Here is the Code ..

Then we will print-out the Selected Transaction Details and ask the user to Confirm the Deleting action by Entering ‘Y’.
After Confirming we need to perform or to Aplay three parts of code:
1. Deleting the Buying Transaction from Buying Table (buy_t_table).
2. Deleting the Buying Record from the Budget Table.
3. Updating the Share Basket Table (s_basket).
For the “Update the Share Basket Table (s_basket).” we need to Subtract the amount of the shares from the Share Basket.
Here is the code for all three action..



The Same actions will be taken if the user select to Delete a Selling
transaction. So if the user select “2. Selling Transaction:” we will call show_all function to display all the Selling Transactions and the ask the user to Enter the ID of the record to be Deleted and will display the Transaction Details. Here is the Code ..



And will waite for the user to Confirm the Deleting action, then again three blocks of code will Delete and update records in our system, here are the code ..

Now we finish the def del_trans(): Function to Delete a Buying or Selling Transaction and will work on the last part of def show_all_trans (inside = ‘No’, show=’3′): to Show/Display both Buying and Selling Transactions in one table format. To do so First we will RUN two SQL commands to ‘fetchall’ Buying and Selling Transaction… Here is the code ..


# Get All Sell Transactions Order by id desc
c.execute (" select * from sell_t_table where st_id > 0 order by st_id desc") 
show_s_trans = c.fetchall()   
            
# Get All buy Transactions Order by id desc
c.execute (" select * from buy_t_table where bt_id > 0 order by bt_id desc") 
show_b_trans = c.fetchall()    

Then we print-out the Table header as the following line:
print(“\n”,” “*11,”{:<9}{:<13}{:<30}{:<16}{:<11}{:<15}{}".format('ID','Date','Share Name','SAmount','Price','Cost','Income'))
Then using a For loop we will print-out the transactions in same format of the table header .. Here is the full Code

Last thing we will print the Totals of Investment, Incomes and the Net Profit.


print(" "*73,'Total Investment is: {:,}'.format(total_inv)) 
print(" "*76,'Total Incomes is: {:,}'.format(total_inc))  
print(" "*75,"-"*30,"\n"," "*75,'   Net Profit is: {:,} '.format(total_inc - total_inv))




We Done with this Part ..

Coming Up: In the Next post we will write the Function to Edit a Transaction.

[NOTES]
1. Part-1 has no code file.
2. We are applying some basic Validations on some part of the code, and assuming that the user will not enter a messy data.
3. This Application Purpose for Saving Transactions and NOT for Desetion Making and Dose’t Have any type of AI or ML Model to Predict the Prices and/or Giving Sugestions on Buying or Selling Shares.


:: Shares Speculation System ::

Part 1 Part 2 Part 3 Part 4 Part 5
Part 6 Part 7 Part 8



All the code are available ..

To Download my Python code (.py) files Click-Here

 


Follow me on Twitter..

By: Ali Radwani

 

Python: Shares Speculation System – Part 6

August 12, 2020 1 comment


Learning : Python, DataBase, SQL, SQlite3
Subject: Plan, Design and Build a Shares Speculation System

Project Card:
Project Name: Shares Speculation System
By: Ali
Date: 2.7.2020
Version: V01-2.7.2020

In Part-5 we wrote the function to submit the Buying Transactions ..[Click to Read] also we wrote the section of showing/displaying the Buying records on the screen. In this part we will continu on same function to write the code to Save Selling Transaction and display them on the screen in Show all Transactions Function.

So First we will writing the code to Save/Submit Selling Transactions. Now let’s start coding ..

Before we start I want to focus on a one-line If statement that we will use to give the user the ability or the chance to Quit or Exit from the function in any time before saving the Transaction by just entering ‘Q’, here is the code: if s_s_id in [‘Q’,’q’] : return (s_s_id is the user input).

In def sell_share(): function we will display all the Shares Name (by calling show_share() function) on the screen and ask the user to select the ID for the share, then we will Run tow SQL statements to get some data about that share such as it Full Name and the amount of shares we have (from s_basket table), if the return value of the s_basket is None or we Don’t have any shares we can’t do any Sell process so we will Exit. Here is the code ..



If we have shares, then we will print on the screen to show total amount of shares we have and will ask the user to Enter the new selling share information like the Date, The Amount of Selling and the Price, here is the code ..


After that, we will ask the user to CONFIRM Saving by pressing ‘Y’, and will use the SQL Insert statement to submit the data to the Database, also to update the s_basket table…. Here is the code.


Now we finish the def sell_share(): function and will start to writing the corresponding part to show the Selling Transactions in def show_all_trans ():, in this section of the code as we did to show the Buying Transactions we will RUN an SQL statement to get all selling transaction in the table, we will use the formatting to output the data as a table format. Here is the code


Coming Up: In Next part we will Write the Function to Delete Transactions from the System, also will write a code to Show All Transactions Buying and Selling in one Table.


[NOTES]
1. Part-1 has no code file.
2. We are applying some basic Validations on some part of the code, and assuming that the user will not enter a messy data.
3. This Application Purpose for Saving Transactions and NOT for Desetion Making and Dose’t Have any type of AI or ML Model to Predict the Prices and/or Giving Sugestions on Buying or Selling Shares.


:: Shares Speculation System ::

Part 1 Part 2 Part 3 Part 4 Part 5
Part 6



To Download my Python code (.py) files Click-Here




Follow me on Twitter..




By: Ali Radwani




Python: Shares Speculation System – Part 5

August 9, 2020 2 comments


Learning : Python, DataBase, SQL, SQlite3
Subject: Plan, Design and Build a Shares Speculation System

Project Card:
Project Name: Shares Speculation System
By: Ali
Date: 2.7.2020
Version: V01-2.7.2020

In this part we will talk or say will work on two functions, Buying Transactions and Show All Transactions, both are fill in Transactions Managment. But first we will do some changes in our main codes as following:
1. Add New Table to the DataBase named s_basket using this code:
“CREATE TABLE if not exists s_basket (sb_id INTEGER PRIMARY KEY AUTOINCREMENT, sn_id integer, ts_amount float, min_p float, max_p float)”
also we will Insert the zero record as:
c.execute (“INSERT INTO s_basket (sb_id) VALUES(:sb_id)”,{“sb_id”:0})

2. Changing in Main Menu.



[Important Note]: This application Purpose for Saving Transactions and NOT for Desetion Making and dose’t have any type of AI or ML Model to Predict the Prices and/or Giving Sugestions on Buying or Selling Shares.


Transactions Managment: In our previous parts and codes we published, we used two options in the main menu (Buying Transaction, Selling Transaction) in this part we will change this to have one menu option called Transactions Managment this option will take the user to a sub-menu having some other options as shown:

The Main-Menu Code

Out-Put

Transaction Managment Menu


Out-put


Buying Transactions: we will start writing the functions to Insert a Buying Transactions, in this function first we will display a list of Shares we have and the user will select the ID of the share needed, here is the code ..



Now we will use the ID to get the selected share Full-Name and it’s Abbreviation also the amount of shares we have with the lowest and highest price we bought this share before and will display all this information on the screen. Next step is to collect the buying record information to be saved, so we will ask the user to Enter the Date, Share Amount and the Price. With each Data-Entry line we will give the user the ability to terminate the process by Entering ‘Q’, for the date we will use date_validation function. Here is the code for this section..


After that we are ready to Insert the data into the Database, and update other records. Here is the code..

Now we have saved one Buying record, before we continu with Selling Transactions we will write the Show All Transactions this function will display all the records of Buying Transactions and Selling Transactions. Now we will write the section to display the Buying Transaction records. We will call the function def show_all_trans () and we will ask the user to select “What type of Transaction to Show:”
1. Buying Transaction.
2. Selling Transaction.
3. All Transactions.
then we will display the transactions in a table format. In this part we will write the code for the Buying Transaction. Here is the code ..


We Done in this Part ..


Coming Up: In Next part we will write the Function Save Selling Transactions to our system, also updating the Show


[NOTES]
1. Part-1 has no code file.
2. We are applying some basic Validations on some part of the code, and assuming that the user will not enter a messy data.
3. This Application Purpose for Saving Transactions and NOT for Desetion Making and Dose’t Have any type of AI or ML Model to Predict the Prices and/or Giving Sugestions on Buying or Selling Shares.


:: Shares Speculation System ::

Part 1 Part 2 Part 3 Part 4
Part5




All the Codes in this Post Available here ..

To Download my Python code (.py) files Click-Here




Follow me on Twitter..




By: Ali Radwani




Sketch from One Year Back

August 5, 2020 Leave a comment

This is an Elephant sketch from One #year ago i use a pencile then black ink pen.

Follow me on Twitter..

To The Freedom

August 3, 2020 Leave a comment

Another sketche I woke on with watercolor.

Follow me on Twitter

Lily Flower Drawing


Away from Coding and Python projects, drawing is my best way to relax, along with coffee and almost 15min of sketching with pencil then ink-ed it, here is the Lily.

Follow Me on Twitter

Random Sketch


Last night I was going through the Net looking for some Animals phones for my kids to learn there Names and the kind of food each will eat, I came up with this photo of a Giraffe, couldn’t stop myself from the desire to draw it. I use my Galaxy Tab S4 and Autodesk Sketchbook Application to sketch it.. Here it is.. And you may fond more of my sketches on the SKETCHE Page.

Follow me on Twitter Here

Tow Weeks with Kaggle



Several months ago I was looking for some data to test one of my projects, the search take me to KAGGLE page, I spend some time there grab some free data I want; test my project.. DONE!.

Tow weeks ago I was reading an article and the name Kaggle come across, I decide to give the page some more time. I join it, and immediately start to joined one of free courses. I am happy to be there, learning from the community I finish five free courses in Tow Weeks, they have tons of data, highly recommended it.


…… KAGGLE Team ….. Thank you ..



To Download my Python code (.py) files Click-Here




Follow me on Twitter..




By: Ali Radwani




Categories: Uncategorized