@Author: Ken Nguyen
1. Show Stock Mock
Friends, Family tried to join the stock market
But I don't have any money, what do I do ?
I created Stock Mock to provide a free playground for stock traders
What it does:
- Real time stock market simulation
- Every user gets 50.000 $, start trading stocks in a simulation
- you can check your stocks, your current cash, current net-worth, current pending transactions
sign up/ sign in
check check money
see all stocks
2. Show code snippet
python (consume alphavantage's API)
show redux use : Tools_Loader
show mocha/chai testing for back-end API
a. used python to consume alphavantage's API, store json results in files so that we don't have to call it every minute. The server runs 11 minutes slower than reality, so that Stock Mock only calls alphavantage every 11 minutes, reducing load on the API server of alphavantage.co
b. Used Tools_Loader so that reactJS can ajax the whole package of information (user, stocks, transactions), make code easier to read, help making an ajax feature in the future.
c. Added different console.log in error situations ("error 17", "error 29",...) mark where each error appeared in debug
3. Research possible solutions:
a. When I wanted to transfer different states (user information, stock quotes information..) between different React components globally, I did not know what to do.
Then I found: redux, Watched YouTube tutorial about it (The New Boston - highly recommended)
b. The production server has a different time-zone from alphavantage's. I needed a way to modify the system, work easily with files, MySql database.
So I used python and shell script, which can be interfaced with "child_process" library of NodeJS.
So I researched for "child_processes" on Stack OverFlow, starting from "how to run cli command in nodeJS"
d. Researched about stock trading on investopedia.com: (https://www.investopedia.com/ask/answers/100314/whats-difference-between-market-order-and-limit-order.asp) to develop proper algorithms for each order type (Market Order, Limit Order, Stop Order).
Trouble with connections, api calls:
check console.log, see file name and line
trace the code snippet.
run mocha testing on API.
try to see if the error is server side or front-end. Then come up with solutions.
eg: Cross-Origin Resource sharing was a problem:
API call didn't work for reactJS's API call
had to check console.log
figured the error, it was server side.
installed "cors" library on server
Trouble rendering components:
console.log the component's data or stack trace (f12 in browser)
trace the bug, fix it.
If the bug is too hard, break the component down to small pieces, then build it up piece by piece to identify the bug.
Trouble with algorithms:
console.log results returned from algorithms
trace bug, de-bug (from the console.logs and stack trace in CLI)
run mocha/chai testing, make sure the tests work
run reactJS, make sure the problem is fixed.
General code problem (invalid operator, wrong parameter passed in)
follow the stack trace, check each variable to see the bug.
If the bug is too hard, i will again, break the suspected code into small pieces, then build it up piece by piece until I identify the bug.
This Presentation is for Semios, to show case my java Script skill sets for the Java Script Developer Internship Position.