Tuesday, November 14, 2017

Run Python With VSCode On USB | Anaconda Envs| Windows 10| 2017-11-14

Why Use Visual Studio Code

I am happy with Sublime Text 3 for my Python coding.
But since VSCode is free, I'd like to give it a try.
To be honest, the task runner setup was more complicated that I expected.

Anyhow, I managed to set this up on a USB.

Python Environment

1) Python 3.6.3 - Anaconda , with environment being created with Anaconda Navigator
2) Operating System: Windows 10 

Steps

1) Install Anaconda (location being set to D drive (drive other than default C))

2) Create Environment With Anaconda Navigator (Optional)
This step is optional if you're happy with the Anaconda root installation.
I tend to create different projects in different environments (Python virtual environment),
just a matter of habit.

 
3) Download VSCode and Setup
This can be quite tricky when you need to setup the task runner to run Python code.


Saturday, November 11, 2017

Aspen Mics Vs Zoom H1 via KV Connection To iPhone SE | Screen Recording Test iOS 11.1


I was testing whether I can record video using the camera app WITH iOS 11.1 screen recording feature (camera app not recording).

It turned out that no audio was recorded if I turned on the camera app.
But audio recording resumed when I switched out of the iPhone camera app.

Listed below are the time section of Aspen Mics and Zoom H1 to iPhone SE

01:45 - 02:27 | Aspec Mic to iPhone via iOS 11.1 Screen Recording
02:28 - 03:15 | Zoom H1 through KV Connection Line-in to iPhone SE iOS 11.1 Screen Recording
03:16 - 03:50 | Zoom H1 through KV Connection Mic-in to iPhone SE iOS 11.1 Screen Recording


Friday, November 10, 2017

Create Python Backtest With Jupyter Notebook Anaconda 3.5.0.1 On Windows 10| 2017-11-11

Backtest With Jupyter Notebook Anaconda 3.5.0.1


Just walkthrough the whole process of creating Python backtest in Anaconda, Windows 10.

The process is broken down into 5 major steps:
00x | Install Anaconda
10x | Get online stock (e.g. AAPL) | Market Data
20x | Create trade strategy | Strategy Class
30x | Generate trade signal | Signal Class
40x | Create investment portfolio | Portfolio Class
50x | Perfomance review | PnL + Graphing

A timeline is provided below for easy navigation:
In case you just want to use the Anaconda root setup, skip step 'Ana002'

mm:ss
00:00 - 03:02 ||Ana001| Install Anaconda
03:04 - 10:02 ||Ana002|Setup different environment other than root - optional step*
10:04 - 19:02 ||Ana101| Get Apple stock data from Yahoo Finance, save to local drive as Excel
19:04 - 29:11 ||Ana201| Create Strategy - calculate moving averages
29:12 - 35:53 ||Ana202| Create Strategy - get stock trend
35:55 - 41:22 ||Ana301| Get Trade Signal and Generate Order
41:24 - 49:50 ||Ana401402| Create Investment Portfolio and Trade Details
49:52 - 59:03 ||Ana501502| Calculate Profit and Loss and Graphing

* install optional Python packages that your project requires
** the strategy mentioned assumes zero borrowing cost so that whenever short position occurs,
we can borrow unlimited amount of money without needing to pay a penny of interest.
This is not real in real world.  So just be aware of that.


Here's the 59-min video(Complete Walkthrough - Jupyter Notebook Anaconda):



*** this video is rendered in 1.05x speed; feel free to visit the original speed videos below.

Install Anaconda 3.5.0.1(Ana001)


Setup Environment In Anaconda 3.5.0.1(Ana002) - Optional



Get Online Stock Data + Save To Local Drive(Ana101) 


Form Trade Strategy - Calculate Moving Average (Ana201) 



Form Trade Strategy - Get Stock Trend (Ana202) 


Generate Trade Signal - Get Stock Trend (Ana301)


Create Investment Portfolio (Ana401402) 


Measuring Performance & Graphing (Ana501502)


Backtest With Python Default Editor



My Thought

Comparing to buidling Python strategy backtest in default Python editor,
the Anaconda Jupyter Notebook takes a bit of time to get used to.
It takes time to load up the Jupyter Notebook while such load time is minimal in Python default editor.

But from layman's perspective, setting up multiple environments and installing packages
through the Anaconda Navigator are intuitive.
Anaconda basically organizes the folders under the 'env' folder.
That's good folder management.

In the future, I'll try using Sublime Text 3 to route to the Anaconda's environment folder.
See if I can take advantage of Sublime Text' speed while maintaining proper environment folder
management.

If you find this article helpful, feel free to discuss on my Facebook:

www.facebook.com/clueple


Disclaimer:
Everything shown in this video is just the author's personal experience with Anaconda.
All mentioned assumptions and tactics are used as demonstration for education purpose.
Trade details, not limited to, leverage level, deposit amount, transactions fees, and
any costs associated with the strategy are not meant to be complete.

No investment decision should be based on any information provided in this video.
No professional advice are provided or implied whatsoever.

Viewers are solely responsible for any loss associated to consumption of this video.

Monday, November 6, 2017

Setup Jupyter Notebook & Anaconda Environment On Windows 10

Jupyter Notebook

Just record how to create Anaconda environment to use Jupyter Notebook in folders other than the root folder, Windows 10.


#create_anaconda_environment_on_win10, #jupyter_notebook_on_anaconda, #use_jupyter_notebook_in_folders_other_than_root_folder,

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.