Saturday, November 4, 2017

How I Create My 1st Backtest With Python | Example: Google (GOOG)

Finally finished up my 1st backtest with Python.
Just shoot this video to help remind myself the basics
and hopefully, this can help people get their feet wet
on Python coding ... (advanced users feel free to jump around using the time table below)

Here, I am showing you 2 videos where the first one is the Python setup (from scratch)
and the second one is the backtest creation.

YouTube video link - Install Python & Related Packages:

*Note that I installed Python to specific folder "py362"  but you can feel free to decide the destination folder location.
**Also, I setup the Sublime Text 3 as my code editor.  Again, you can pick your own editor.
In the backtest creation video, I used the Python built-in editor (IDLE).
***I created the virtualenv (virtual environment) for my trade algo.
You don't need that for backtest.  But it's highly recommended if you want to build Python projects, other than trade algo.




YouTube video link - Creating backtest:
https://www.youtube.com/watch?v=D73NyNb2YZs


Time Table |English Version
hh:mm:ss
00:00:09 - 00:08:24 | part 1| Get stock data from Yahoo Finance + Save to Excel
00:08:26 - 00:14:49 | part 2.1| Strategy class - defininng basic parameters
00:14:50 - 00:21:21 | part 2.2| Strategy class - calculate moving averages
00:21:22 - 00:30:53 | part 2.3| Strategy class - calculate trend details
00:30:54 - 00:37:58 | part3.1| Signal class - calculate trade signal and order
00:30:59 - 00:45:51 | part4.1| Portfolio class - calculate trade amount
00:45:52 - 00:52:26 | part4.2| Portfolio class - calculate cash balance and asset position
00:52:26 - 00:57:56| part 5.1| calculate profit and loss + plot graph


For part 4.2 "cash_balance and asset position",
you can read Isaac Kwan's code for traditional stock trade style.
He offered great help in explaining the use of abstract-based class of Python (I am still figuring that out :))

https://gitlab.com/snippets/1681494


Python script: (underlying stock being changed to 0388.HK)
https://github.com/clueple/algo/blob/master/hkex_full_example.py

Isaac Kwan's link on part 4.2 - cash balance and asset position
https://gitlab.com/snippets/1681494



Finally, please read the video disclaimer
and by no means, this video be used for real trade.

Tuesday, October 31, 2017

Wonder if Windows 10 Creator Breaks Asus Laptop

Just wonder if Win 10 Creator breaks my Asus laptop*

My laptop broke down for the 1st time after forced Win 10 Assistant Update
A few days ago, should be before Oct 29, 2017,
forced Win 10 Assistant Update again; breaks down on Nov 1, 2017

Asus laptop breaks down again on Nov 1, 2017

Asus laptop 1st break-down on Oct 11, 2017; Repair back on Oct 22


*
Asus A555 UQ-DM044T
i7-6500U
120 SSD + 1TB HDD
Purchase Date: Dec 08, 2016
1st Break-Down: Oct 11, 2017
1st Repair: Oct 22, 2017
2nd Break-Down: Nov 01, 2017

Monday, October 30, 2017

Sunday, October 29, 2017

FireFox Force English Interface Regardless Of Location

FireFox Force English Interface Regardless Of Location

Check this out:
https://addons.mozilla.org/en-US/firefox/addon/google-ncr/

FireFox Custom Installation

This link provides custom installation of FireFox.

Need to install on D drive instead of default C drive; also need to change the profile location.

Otherwise, the FireFox profile still sits inside %appdata%Firefox in C drive

https://support.mozilla.org/en-US/kb/custom-installation-firefox-on-windows

Wednesday, October 18, 2017

Counting Stock Trend With Numpy Array

Just shot a video to help me memorize how to do trend count with Numpy array:

a = np.array([0,0,0,1,1,1,0,0,1,0,1,1,0])

value_to_count = 1
value_to_reset = 0

no_reset = (a == value_to_count).cumsum()

reset = (a == value_to_reset)

excess = np.maximum.accumulate(no_reset*reset)

result = no_reset - access



Tuesday, October 17, 2017

Test iOS 11.0.3 Screen Recording On iPhone SE 2017

Test iOS 11.0.3 Screen Recording On iPhone SE 2017

Testing the iOS 11.0.3 update - screen recording feature
Device : iPhone SE (16 GB); Rendering platform: Facebook

Setup steps:
1) General ... Control Center ... add screen recording
2.1) General ... Restrictions ...type code to get in...
2.2) turn 'Screen Recording' to green ...Screen Recording inside 'Game Center'...

Recording Steps: ...starting from the main screen...
1) swipe the phone from the bottom
2) press the button ...screen recording button...
3) When you see flashing red ...see video start of this video..., you're recording
4) Once you finish recording, go back to step1... and press the button to stop