Candlestick.js with some new features

Posted on by Ami

The Candlestick.js project on github has some new features already and others are in development.

There are 3 live demos,

  1. The first is very short, just the minimal code needed to create a nice looking chart.
  2. The second is a simple explorer with an embeded history of tickers the user looked at.
  3. The last one includes some data analysis or technical analysis, a search was done to find candles where the close price crossed the simple moving average from below to above. On these events the code to draw a purple line to highlight the event is shown.

There are a lot of small details to work on and improve the Candlestick.js project and I’m working on it as fast as I can.

One major change I hope to accomplish is switch from an object parameter with all the settings to a more general free text language spec where you’ll be able to write something like:

Panels(50,30,30) // define 3 panels with proportional sizes.

// the main candlestic panel plus a special moving average
// based on the average of the high and low.
Panel0( candlestick, sma(20), sma((h+l)/2, 20) )

// 2nd panel with MACD default values of close,12,26,9
Panel1(macd)

// of course you can get crazy with customizing
// the MACD in panel1
//Panel1( macd( (h+l+c)/3,10,22,6) )

Panel2(volume,sma(volume,50))

I will develop the language in the coming weeks. To use it you will write the code in a string variable or a text file and put it in the main line instead of the options object.

var options = [
  'Panels(50,30,30)',
  'Panel0(candlestick,sma(20),sma((h+l)/2,20))',
  'Panel1(macd)',
  'Panel2(v,sma(v,50)'
].join('\n');
Candlestick(canvasID, data, options);
Posted in Uncategorized

Candlestick.js on github

Posted on by Ami

A new open source MIT licensed javascript project for candlestick charts is on github. I started it to make it easy to create nice looking charts in modern browsers using the HTML5 canvas.

The project is called Candlestick.js and is in active development. Many features are still missing but it is easy to understand and use.

All you need is a simple historical data file similar to yahoo's finance site and you're ready to go.

Soon additional indicator types and other time frames will be added.

Posted in Uncategorized

options-logging

Posted on by Ami

I need a system in place to log my reasoning when entering a trade. I just bought a very long term debit call spread on MA – that's Mastercard. I jotted down on paper the calculations while preparing for this trade and I need a permanent place to look at this important info when the market gets crazy and moves fast.

I then use my thoughts when I bought as a tool to prevent me from getting out too early or trying to hedge prematurely.

I'm not sure if this is a product on its own as in mytradinglog.com or a part of chartly.com which will have several tools and this will be one of them.

Anyway, until I have this sorted out, here is my reasoning:

  1. In my home made list of ranked stocks based on Magic Formula Investing, it is in the top 20%, or in other words - the top fifth of the universe of stocks.
  2. When checking for Rule Number One criteria, this is a great company with steady multiyear returns and growth in equity and profitability.
  3. On a technical note, I usually look at long term – 3 to 5 years weekly candlestick charts and on this one I noticed a very interesting chart – It is quite boring, I didn't mean to contradict myself, this is a rare case where a predictable chart with a good growth slope and very low variability is a good thing.
  4. I guess I got tired of waiting for a temporary dip in the stock price, if this will happen, I will reassess and and might increase my position.
  5. I estimate the price to be at around 730 in a year and a half – that's a 22% more than today or 14% annualized return which is half of the conservative growth rate of the company in the previous 4 years.

I bought the Jan 2015 $700 call option and sold the Jan 2015 $730 call option, this sale is coupled with the buy so the margin requirements are limited. The default calculated price for this combo was $1005 based on the high price for the buy and the low price for the sale. I put this as a limit order at the cost of $880 and was immediately filled. I guess I should have tried a lower limit.

Anyway, the potential is the difference which is $30 x 100 divided by the cost of $880 and the potential gain is 240% in a year and a half. Perhaps sooner.

Of course, if the stock moves fast, I might add other options to protect and lock in some of the profit earlier without limiting the additional profit potential.

Posted in Uncategorized

עמיחי היינס – אתר חדש לעצמי

Posted on by Ami

כבר הרבה זמן שאני דוחה את זה, אבל הגיע הזמן לבנות לי אתר חדש, אני מניח שהסנדלר הולך יחף – בתור מתכנת יכולתי לעשות לי אתר מרשים יותר…

יש סקיצה של האתר החדש בכתובת החדשה שלי: עמיחי היינס

אתם מוזמנים להתקשר ולצחוק עלי 052-3569713

עמיחי

Posted in Uncategorized

extend office trial up to 6 months

Posted on by Ami

I use microsoft office rarely, I have a customer with a Microsoft Access project.

I use it once every few months to fix or add stuff.

The trial version I used expired and I found there is a small exe that will extend the trial for another 30 days.

You can use it for up to 5 times – I've been told.

the file is located at: /host/Program Files/Common Files/Microsoft Shared/OfficeSoftwareProtectionPlatform/OSPPREARM.EXE

Posted in Uncategorized

old Mac problems: Disk image failed to mount: Device not configured

Posted on by Ami

Run /Applications/Utilities/Disk Utility.Click on “Macintosh HD” in the left column and then press the “Repair Disk Permissions” button.

Delete the file called /System/Library/Extension.kextcache

Delete the folder called /System/Library/Caches/com.apple.kernalcaches/

Restart

After these steps, disk images mounts properly

via Disk image failed to mount: Device not configured.

Posted in Uncategorized

PHP + Apache לעומת Node.js

Posted on by Ami

 

מאמר זה תורגם מאנגלית על ידי עמיחי היינס.

במקור זה מאמר של תומס האנטר.

 

זאת השוואה של תפוחים לתפוזים. PHP היא שפה בוגרת, פועלת מאחורי שרת האינטרנט Apache בתצורה של בקשה / תגובה. Node.js הוא מסגרת מבוססת JavaScript המריצה לולאת אירואים לא חוסמים ואשר פועלת בתוך מנוע V8, עם שרת אינטרנט אופציונלי הבנוי בתוכו ואז שוב, האם זה באמת השוואה של תפוחים לתפוזים? שתי הטכנולוגיות משמשות בדרך כלל להגשת דפי אינטרנט לדפדפנים.

 

אם אתם עוקבים אחרי הבלוג שלי לאורך השנים, הייתם יודעים שאני מעריץ גדול של PHP. השגתי את תעודת ה- PHP5 ZCE (מהנדס מוסמך Zend) לפני כמה שנים. בניתי כמה מאות אתרים מבוססי תוכן באמצעות מערכות ניהול תוכן שונות, כמו גם תריסר יישומים באמצעות מסגרות PHP שונות. היה לי ארוע מוצלח ב – 2011 ZendCon, ואפילו לימדתי Meetup PHP במשך כתשעה חודשים.

 

אם היית קורא את הבלוג שלי בזמן אחרון, היית גם שם לב שאני לא סותם את הפה על הדבר החדש הזה שנקרא Node.js שזה (JavaScript שלא על הדפדפן). טוב, ללא ספק, אני לא זרקתי שנים של ניסיון שלי ב- PHP לילד החדש בבלוק, נכון?

 

בכנות, אני כבר משתמש בשתי השפות לאחרונה. בעבודה אתרי האינטרנט שלנו בנויים באמצעות PHP (למרות שאני מוצא עוד סיבות לNode.js כל יום). לעבודות צדדיות שלי, אני כותב משחקי אינטרנט מרובי משתתפים ותוכנות התממשקות חומרה באמצעות Node.js.

 

לשתי הסביבות יש יתרונות וחסרונותיהם משלהם, ואף שפה היא הפתרון המושלם לכל פרויקט. בפוסט הזה אני הולך להשוות ולעמת את שתי סביבות, המכסה את נקודות החוזק והחולשה שלהם, ומתווה מי הוא טוב יותר למצבים שונים.

 

למה אני רק מכסה PHP + אפצ'י וNode.js? בכנות, אלו השפות שאני יודע הכי טוב ויש לי קוד ייצור פועל עבור כל אחד. Ruby, Python הן כמה שפות גדולות באותו מרחב זה עם עוצמות וחולשות דומות, אבל לא היתה לי ההזדמנות ללמוד אותם. JavaScript (Node.js) ו-PHP מכילות השפעות תחביריות גדולות משפת C.

 

יתרונות של PHP

 

PHP היא ללא ספק השפה הנפוצה ביותר בצד שרת לתכנות באינטרנט. זה ישן, ואף פעם אין מחסור של ספקי ארוח משותפים זולים. חלק מהפלטפורמות הגדולות/היישומים נוהגים להשתמש PHP. וורדפרס, הפופולרי ביותר מבין פלטפורמות בלוגים עצמאיים המתארחים כתובה ב PHP וגם MediaWiki, Joomla, הן כמה דוגמאות ליישומים נפוצים המשתמשים ב-PHP.

 

חלק מאתרי האינטרנט הגדולים ביותר משתמשים ב- PHP, כגון פייסבוק, ויקיפדיה. PHP משתמש במתודולוגיות מסורתיות (זאת אומרת – מוכרות) כמו תכנות מונחה עצמים. יש המון מסגרות אינטרנט PHP ותיעוד שלהן ושל השפה.

 

PHP היא נהדרת עבור שרת של אתרי תוכן. PHP יושב מאחורי שרת אינטרנט, שיכול לבדוק אם הקובץ המבוקש קיים במערכת הקבצים. אם כן, הקובץ יכול להיות מוגש ללקוח ללא צורך להפעיל קוד PHP. זה לא בהכרח יתרון של השפה עצמה, אבל זו תוצאת לוואי מועילה עבור רוב המצבים.

 

PHP יש גם גיבוי של חברה מסחרית על ידי חברת זנד (הסלוגן שלהם הוא "חברת ה- PHP"). גיבוי זה נדרש על ידי תאגידים גדולים, שחולק את אותה הפילוסופיה, "אם משהו לא עולה כסף אנחנו לא רוצים אותו".

 

חסרונות של PHP

 

PHP  לא אמורה לרוץ למשכי זמן ארוכים. רבים יתווכחו איתי כאן, אבל בברירת המחדל מוגדר להפסיק את עצמו ברגע שהוא כבר פועל במשך 30 שניות, או אם הוא מגיע לכמות מסוימת של שימוש בזיכרון. אפשר לכבות את ההגדרות הללו, ויישומים יכולים להיות בנויים לרוץ במשך זמן רב בהצלחה, אבל זה לא התחום שבו PHP מתבלט לטובה.

 

השפה לא מסוגלת להפעיל קוד במקביל. אתה יכול, תוך שימוש בכלים כמו Gearman, להעביר חלק מהעבודה לתהליכים אחרים, ודי לפקוח עין על ההתקדמות, אבל התהליך הזה די מקרטע, ולא מה שPHP מיועד להיות. Gearman עצמו מציע מגוון גדול של אפשרויות וניתן להשתמש בו בסביבות שונות, כולל Node.js.

 

בימים עברו, כאשר היה מיפוי של 1:1 בין כתובות ומערכות קבצים, זה נראה הגיוני לגמרי שיש שרת אינטרנט נפרד מהשפה שהוא מריץ. אבל כיום, כל יישום PHP עם כתובות יפות פועל מאחורי שרת האינטרנט Apache צריך קובץ .Htaccess, שמבקש מהשרת לתרגם ביטוי של כתובת לקובץ בעזרת regex. נשמע מורכב ומסורבל עם תקורה מיותרת? זה בגלל שזה באמת ככה.

 

בסך הכל, המערכת הנדרשת לתמוך ב- PHP היא מורכבת יתר על מידה בהשוואה למשהו פשוט כמו node. קודם כל צריך אפצ'י, שבו יש כמה הגדרות גלובליות, כמו גם הגדרות אתר ספציפיות. צריך גם PHP, שבו יש הגדרות php.ini  גלובליות, שחלקם יכול להיות מבוטל בזמן ריצה (אך לא הכל). יש גם חבורה של דברים ישנים שהשאירו בסביבה ויש להסיר, למשל, תמיכת Y2K (לבסוף הוסר ב5.4).

 

האתר הרשמי הוא די מכוער ומיושן. המסמכים הם בסדר, המשתמשים תרמו הערות מועילות מאוד, עם זאת השיטה לעדכן מסמכים כרוכים SVN והאקינג בקבצי XML, ולא בדיוק מעודד עבור רוב האנשים כדי לכתוב תיעוד.

 

ניהול חבילות הוא כמעט לא קיים. בטח, יש PEAR, אבל הכלי מעצבן לשימוש עד כדי גיחוך. כמה מנהלי חבילות אחרים הופיעו, למשל Pyrus (PEAR2) ו- Packagist, אבל השימוש בהן כל כך נדיר שאין סטנדרט דה פקטו. ולומר את האמת, כנראה שלעולם לא יהיה. יש גם PHPClasses.org, אבל האתר הזה לא נוח לשימוש ומחייב את המשתמש להירשם כדי לגלוש.

 

מאז שתהליך PHP מתחיל, ומבצע כמה תהליכים קבועים ואחר כך  מבצע את המשימה שהמשתמש בעצם רוצה, ולאחר מכן מת, נתונים אינם נשמרים בזיכרון. אתה יכול לשמור את הנתונים באופן מתמשך  באמצעות כלי צד שלישיים כמו מסד נתוני Memcache או בסיס נתונים מסורתי, אבל אז יש את התקורה של תקשורת עם התהליכים חיצוניים האלה.

 

יתרונות של Node.js

 

הכח הגדול ביותר של Node.js, לעניות דעתי, הוא שהוא מונע  אירועים (Event driven). יישומי node רצים נהדר על פני תקופות זמן ארוכות. מנהל האירועים, בעוד די פשוט ביסודו, מספק ממשק חזק ועקבי לביצוע קוד לפי ארועים בעת הצורך.

 

לnode יש שרת אינטרנט מובנה. יש אנשים שחושבים שזה דבר רע, אני קורא לאותם אנשים משוגעים. מאחר שהשרת מובנה אין בכלל את הצורך בדבר המביך הזה שנקרא htaccess config. כל בקשה מנותבת לעבור את אותו תהליך, מבלי לצוד באמצעות מערכת הקבצים ולהבין איזה תסריט צריך לרוץ.

 

צוואר הבקבוק מספר אחד עם יישומי אינטרנט הוא לא הזמן שלוקח לחישוב פעולות רעבות CPU, אלא הרשת, I/O. אם אתה צריך להגיב לבקשת לקוח לאחר ביצוע שיחת מסד נתונים ושליחת דוא"ל, תוכל לבצע את שתי הפעולות ולהגיב

כאשר שתיהם בוצעו במלואם.

 

כמובן, עם Node.js שנכתב ב-JavaScript, אם אתה כבר יודע JS לפיתוח ממשק משתמש, אתה כבר מתמצא די טוב בתחום Node.js. אתה כבר יודע את התחביר,ואת הבעיות של השפה, כל שנותרי הוא להכיראת ה-API  לאינטראקציה עם המערכת.

 

מערכת ניהול החבילות, npm, היא נהדרת (למרות שחסר הרבה כדי שהאתר יהיה שלם). במקום לעקוב אחרי הנחיות קפדניות ודרישות עיצוב (כמו ב-PEAR של PHP למשל), כל אחד יכול לשים כל דבר לnpm (אפילו אני!). זה דומה לשוק של אנדרואיד. בטח, אתה יכול לקבל כמה דברים נוראים  משם, אבל אם משתמשים בהיגיון בריא לא תורידו וירוס.

 

כל כך חדש, שאין לו הרבה שאריות מטען מימי קדם. מכיוון שיש שרת מובנה, הערימה היא הרבה יותר פשוטה, יש פחות נקודות כישלון, ויש יותר שליטה על מה שאתה יכול לעשות עם תגובות של HTTP (ניסית אי פעם להחליף את שמו של שרת האינטרנט באמצעות PHP?).

 <">