Wednesday, March 28, 2018

DIY Excel Accounting System | 2018

Step 1

Download the base file from Facebook
Copy to your local drive and make changes (refer to video) in 'TabList' to activate the clickable buttons.

To be continued...

Sunday, March 25, 2018

Uploading Python file To Get Stock Data From Yahoo Finance| 2018

Just uploaded the Python file to my Facebook group (link below)

Get_Stock_Python_File

Updated Version @ March 27, 2018


*By clicking the link above, you are assumed to accept any disclaimer terms
stated in the linked post 

#get_stock_data_from_web, #yahoo_finance, #python, #pandas_datareader, 

Remote Accessing Raspberry Pi 3 From Win 10| 2018-03-25


Just captured the screenshots for the process setting up remote access to Pi3 from Win 10
Click the link below for detail instructions.



Remote Accessing Raspberry Pi3 From Win 10

Sunday, March 4, 2018

5 Steps To Start Simple Stock Prediction | Python 3.6.4| Code Demo| Mar 2018



00:29 - 08:35 | Get Web Data + Preprocessing
08:35 - 19:18 | Make Data Table + Define Target
19:18 - 25:50 | Define Triggering Event
25:51 - 27:03 | Rough Interpretation

How to install Anaconda
https://www.youtube.com/watch?v=omr8sETbIiA&list=PLgBXjIucQF7YHwVXhOlM13iNHgoUJyPNb&index=7

Create Virtual Environment
https://www.youtube.com/watch?v=CxoynHV5DGs&list=PLgBXjIucQF7YHwVXhOlM13iNHgoUJyPNb&index=8

Disclaimer
The blog is provided as is, without warranty of any kind, neither expressed or implied,
including without limitation warranties of merchantability, fitness for a particular
purpose, title, security, accuracy and non-infringement.
Creator(s) make(s) no warranty or representation,
either expressed or implied, that any contents stated in this blog is error-free.

Use of the blog is at your own risk.  You assume full responsibility and risk of loss
resulting from your downloading, transfer, understanding, and/or use of files,
information, other communications, content, or other material, including,
without limitation software, accessed through or obtained by means of the blog.

www.facebook.com/clueple

errata
Calculation shown from 17:17 to 17:41 should be
(24608 - 25029 ) divided by 25029, instead of 25022


Tuesday, February 27, 2018

Notes | Entry-Level Stock Price Analysis | Stats On Stock Price Percentage Change N Days After

Quoted from this page

1) [Import Libraries]
We need at least 2 Python libraries (pandas and numpy) to read stock data (step 3) and calculation.

2) [Define Data Source]
In case you have the stock data in CSV or Excel format, you can simply
store it in variable (e.g. data_source) assigning the file path (e.g. r'your_path', see pic)

If you want to get data feed online, you might:
 (i) write code on another Python file + store the result in local drive + assign variable to that path
(see this video https://www.youtube.com/watch?v=BKezm2_hLNw)
or
(ii) wrtie code on the SAME Python file + store the result in local drive + assign variable to that path

I preferred method (i) because of the quicker load time and cleaner code to maintain.
I ran into problem with method (ii).  I could fix that by creating multiple variables but still, it's not
very convenient for me.

3) [Store Data In Tabular Format]
Simply use the 'pandas' package to read your source file in tabular format.
The 'dropna()' simply clear whatever row that has non-numeric/datetime value inside.

4) [Define Target Column(s)]
This is the real start of our solution.
We first set the target.  In this case, my question is as follows:

"I want to know when something happens (triggering event), what do I get (target_event)."

From pic_1 and pic_3, I want to know [the percentage change N days after [trigger_event] happens.

That's why I need to define [the percentage change] by using the '.pct_change()' method after
the column (e.g. Close).

5) [Define Triggering Event(s)]
I define the 'triggering event' in the variable 'criteria' which can further be divided into
many sub-sections (e.g. 'tcriteria' means target criteria; 'dcriteria' means day period...)
The variable names are up to you (e.g. you can call 'trigger_event' instead of 'criteria')

In Pic_1, (see 5a), I filter out those with [today's stock price change %] is UP or DOWN more than 1%
(e.g. abs(df['day_chg'] ) > 1)
You might change the 'tcriteria' to something like

my_cat_s_birthday = '2018-02-08'
Replace 'tcriteria' with 'my_cat_s_birthday'

It's totally up to you.

The reason I split 'criteria' into (5a - tcriteria) and (5b - dcritiera) is
the greater flexibility. 
Usually, I want to know whatever triggering event (5a) happens in whatever period (5b).
Through adding a separate period criteria (5b - dcritiera), it's easier to maintain the code.

6) [Define LookUp Period]
Usually, we want to know 'what will [the stock price] be [N days after today].
This is the part to define.

In Pic_1, we want to know 'the percentage change' (df['day_chg']) 1 day after today, so
our code is

df['Ndaychg'] = df['day_chg'].shift(-1)

Since we will be building more interactive app for data analysis,
I suggest generalizing the above formula like this:

lookforwardday = 1   <- you can change this to input(whatever number here, see Pic_3)

df['Ndaychg'] = df['day_chg'].shift(lookforwardday)

7) [Print Result]

Note that you can print 'whatever you want' from your dataset.

But in my case, I want to know the 'mean', 'standard deviation', and 'median' of 'columns that I want to view'.

Given that, I split my print action into (7a) and (7b)
(7a) is simply printing ALL information (e.g. include Open High Low CLose ...) that meets the criteria
stated in step (5)

In Pic_1, you notice the latest day (the bottom row, 2018-02-28 has [NdayChg] = NaN, not a number.
because, on Feb 28, 2018, we don't know what will happen the day after, Mar 1, 2018.

In Pic_3, we define the 'lookforwardday' to be 3.  That's why, we won't know what will 3 (trade days)
after will be, on Feb 26, and Feb 28, 2018.


(7b) Based on the info (see 7a), I add the 'columns that I want to view the stats'
(e.g. .loc[:, ['Vol','Ndaychg']]) 

Put it simple,

df[critieria]   add  .loc[all rows, ['column1', 'column2','column_whatever']]  then add
.agg(['mean','std','median'])  





Sunday, February 25, 2018

Install Dash By Plotly On Anaconda3 Windows 10 | Feb 2018

#install_dash_on_anaconda,

Step A:
a.1 -> Start Anaconda Prompt
a.2 ->Type 'activate [fill in your_environment here]' (like ref a on image) to go your environment.
(In case you don't have any environment, simply install to (base))
a.3 -> pip install dash... (follow the installation page but type on the same line instead)
e.g.
what it shows on the installation page is as follows:

pip install dash==0.21.0  # The core dash backend
pip install dash-renderer==0.11.3  # The dash front-end
pip install dash-html-components==0.9.0  # HTML components
pip install dash-core-components==0.18.1  # Supercharged components
pip install plotly --upgrade  # Plotly graphing library used in examples 

Then you should type the following on your Anaconda Prompt environment (as shown on image ref (a):

pip install dash==0.21.0 dash-renderer==0.11.3 dash-html-components==0.9.0 dash-core-components==0.18.1 plotly -- upgrade

(All in one line, pay attention to space and strokes otherwise you won't install successfully.)

Step B:
Once you finish installation, you can check whether it's done successfully by
typing 'pip list' inside your environment (e.g. myTrade or base)

Step C:
You can now start coding Dash.
When you hit run (e.g. [F5] in Python Idle),
you will see [whatever server is running ] on your Anaconda Prompt (see ref (c) on image)

Then you need to open a new browser (as shown as ref (c) on image)
to view your coding results.


Click to view photos