Sunday, June 07, 2009

New 1.0.4d Release - Cash and Dividend Management

Another excited 1.0.4d release from JStock.

We did some major work on Portfolio management, by integrating it together with cash and dividend management. Picture worths thousand words. Let's see our new freshly portfolio.



You may add comment to your every transaction.


You may manage your cash.


You may manage your dividend payout.


This didn't give you enough reason to download yet? No worry. We had embedded another new character into our JStock, his name is blobsallad.

Want to know what it can do? Just download fresh and new JStock. :)

Thursday, May 14, 2009

New 1.0.4c Release - Good News For Intraday Traders

Good news for Intraday traders.

Although we are now busy pushing for release 1.0.5, we must not forget the need of our beloved end users at the same time. We try to keep frequent update and release on new features and bug fixes.

This round, 1.0.4c release, we choose to bring good news to intraday traders. JStock comes with Intraday Stock Price Snapshot. If you are a daily trader, we understand that your need in monitoring stock price movement in seconds precision. Hence, JStock is providing Intraday Stock Price Snapshot. The stock price will be captured in every 10 seconds in daily basics, lasted for 2 hours.

Here is the screen shoot of this cool feature :

Good News For Mac Users


Good news for Mac users. We had recently recruited a loyal Mac user to our team, to build a package for JStock in order. We want Mac users able to execute JStock smoothly.

The released date for Mac dmg file shall be expected to fall within this week. Stay tune ;)

Tuesday, May 05, 2009

Feature [2676553] On The Way

Today, we plan to start work on feature [2676553]. This will be the key feature for our very exciting next major release - 1.0.5

First, I decide to review our "two-dimensional graphics framework" library. Currently, we are using JHotDraw. After several consideration, "stability", "requirement", "compatibility", we decide to stay on JHotDraw.

I foresee that we will be required to work on JHotDraw source code, either understand it or expanding from it. Hence, grabbing out the right JHotDraw source code is another big task.

Our previous JHotDraw version is 7. However, I have a hard time to figure out the minor version of current deployed JHotDraw. After some try and error, I decide to give up figuring out current JHotDraw minor version.

I decide to first port over JStock source code, to make use of latest JHotDraw 7.1. The latest stable version of JHotDraw 7.1 is released since 2008-03-25.

After building JHotDraw 7.1 together with quaqua.jar, java_30.zip and MRJAdapter, we obtain a hot baked JHotDraw 7.1. When run it together with JStock 1.0.4b, opps...


[yancheng@yancheng jstock]$ java -jar jstock.jar
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.yccheok.jstock.gui.OperatorFigure.add(Lorg/jhotdraw/draw/Figure;)V
at org.yccheok.jstock.gui.OperatorFigure.(OperatorFigure.java:70)
at org.yccheok.jstock.gui.LogicalOperatorFigure.(LogicalOperatorFigure.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...


Look like we have some work to be done :)

Tuesday, April 28, 2009

JStock - Stock Market Software: 1.0.4b Released

New version of JStock 1.0.4b has been released with the following features and bug fixes.

1. [2686577] Feature added. Proxy Auth Support. Contributed by gransi.

2. [2722273] Feature added. Read/ Write on Excel/ CSV File Format.

3. [2725384] Remember The Width of Table Column. Contributed by gransi.

4. [2687975] Bug fixed. Wrong Information Displayed For Korea Market.

5. [2767249] Bug fixed. Current price Is 0 when there is no transaction on that day.

6. [2737316] Bug fixed. NPE in ArithmeticOperator.division. Contributed by wolfc.

You may download JStock 1.0.4b from http://jstock.sourceforge.net

Monday, March 30, 2009

Unhappy OSX User

It seems that we are having some unhappy OSX users.

https://sourceforge.net/forum/forum.php?thread_id=3103567&forum_id=723855

As hard core Windows user, I do not own any OSX to reproduce the problem. Hence, I decide to setup a virtual environment for OSX, by using VMWare player. Just like what I had done to test JStock for Ubuntu Linux, under VMWare player.

Unfortunately, OSX under VMWare player is much more resource intensive than what I am expecting. Moving a mouse pointer, click on the Safari icon, take 1++ minute to launch the browser!!!

After several tries, I decide to give up the idea of perform testing under VMWare. OK, I would like to invite OSX packager to join JStock project, as posted here and here.

Anyone?

Further Addon Plans for 1.0.4b

During the development of 1.0.4b, we discover other bugs which may make our end users unhappy.

[2687975] Wrong Information Displayed For Korea Market

Hence, we decide to mark this as "Must Fixed", before we are losing potential Korean user.

Thursday, March 19, 2009

Interesting Blog by Joshua Bloch

I have been reading an interesting blog by Joshua Bloch, Extra, Extra - Read All About It: Nearly All Binary Searches and Mergesorts are Broken

The following solution can be found in latest version of JDK


int mid = (low + high) >>> 1;


The first thing which comes across my mind is that, (low + high) will cause sign overflow too. However, the comment from the following reader clears out my mind.

">>>" is the unsigned right shift operator. So if I'm not mistaken (low + high) is stored in unsigned int and then shifted one to the right dropping remainder leaving a division by 2 with no remainder returned as a signed int. So it does work.

Very cool, isn't it?

Thursday, March 12, 2009

Patches and Minor Fixes Planned for 1.0.4b

The release of 1.0.4a had been locked down. This means there shall no be any further major enhancement and major bug fixing for 1.0.4a. All the major enhancement and bug fixing will be going into release 1.0.5.

However, patches and minor bug fixing will still be released along the line 1.0.4b, 1.0.4c…

After the few hours released of 1.0.4a, 3 minor bugs (which doesn’t not have large impact to the end users) had been identified :

(1) False alert being received in “Fall Below” - The plan to fix this is to include more detailed in the email sent out by JStock, in order for developers to track down the problem

(2) NPE while changing country - This shall not have the major impact, as NPE is caught at Swing Event Dispatch level. However, there shall not be any NPE thrown.

(3) Two country channel displayed at the same list box while changing the country. There should be only one.

Developers are now working on to resolve the problem. All the above mentioned problem are targeted to be released at 1.0.4b

11 New Countries Support In 1.0.4a

Due to request from users, the following new countries had been added in version 1.0.4a

- Australia
- Austria
- Belgium
- Canada
- HongKong
- Indonesia
- Korea
- Netherlands
- Portugal
- Switzerland
- Taiwan

Thanks to the well design abstraction employed by JStock. All the new countries can be easily added within a night, with not much difficulty encounter ;)

Welcomed to JStock Development Blog

The development goal for JStock 1.0.5 had been defined :

Further enhance usability of Stock Indicator Editor.

Two feature tracker had identified with highest priority :

[2676553] Complex Operator composed of Primitive Operator
[2214275] Internationalization and Localization


Stay tune on the development progress of JStock.

Friday, October 31, 2008

Java Generic Array Creation

Consider the following code :-


class A<E>
{
public A<E>[] array = new A<E>[4];
}


We will get the following compilation error :-

C:\Projects\Main\src\test\Main.java:24: generic array creation


This is due to erasure in generic http://en.wikipedia.org/wiki/Generics_in_Java, which posts a limit to generic array creation.

The workaround is simple. Here is the fixed code :-


class A<E>
{
@SuppressWarnings("unchecked")
public A<E>[] array = new A[4];
}


However, is it safe to do so? Yes. Generics are checked at compile-time for type correctness. We still able to receive "protection" from the above code. Consider the following :-


public class Main {
public static void main(String[] args) {
A<String> a = new A<String>();
// We try to do some stupid thing here.
a.array[0] = 0;
}
}


The compiler will prevent us to do "stupid" thing by flagging us :-

C:\Projects\Main\src\test\Main.java:32: incompatible types


We are being protected :)

Saturday, October 18, 2008

Compile Open Source Edition QT4.4.3 using Microsoft Visual C++ 2008 Express Edition

It is pretty simple and straight forward to compile open source edition QT4.4.3 using Microsoft Visual C++ 2008 Express Edition

1) Add the following path "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" into environment variable.

2) cd C:\QT\4.4.3 (Assume you extract out qt-win-opensource-src-4.4.3.zip there)

3) vcvars32.bat

4) configure -platform win32-msvc2008

5) nmake

Done :)

Wednesday, October 15, 2008

String As Template Parameter

Consider the following template function :-


template<const char* T>
void fun()
{
}


How can we make a call to this function?

"Easy!". I heard you are saying that way. Just :-


const char* s0 = "hello world";

int main()
{

fun<s0>();
return 0;
}


However, when performing compilation, our Visual C++ gives us the following compilation error :-

error C2975: 'T' : invalid template argument for 'fun', expected compile-time constant expression

"Arghh, I know that, just provide array of character, as its length is known during compile-time."

(Note : To understand the difference among char pointer and char array, please refer to http://support.microsoft.com/kb/44463. We may use sizeof operator, which is evaluated during compile-time, to retrieve string length information from char array, but not char pointer)

So, we would have something like this :-


const char s0[] = "hello world";

int main()
{

fun<s0>();
return 0;
}


OK. It should compiled then, isn't it? However, our compiler again make a complain :-

error C2970: 'fun' : template parameter 'T' : 's0' : an expression involving objects with internal linkage cannot be used as a non-type argument

I heard you are crying.

Take a rest for a while. Let's forget string template parameter at this moment. Let us take a look into internal linkage and external linkage. Consider the following two files :-


// Module0.cpp
////////////////////
//Internal Linkage//
////////////////////

// Constant pointer which is having internal linkage
char* const s0 = "hello";

// Constant string with constant pointer is haing internal linkage
const char* const s1 = "hello";

// Internal linkage
const char s3[] = "hello";


and


// Module1.cpp
////////////////////
//Internal Linkage//
////////////////////

// Constant pointer which is having internal linkage
char* const s0 = "hello";

// Constant string with constant pointer is haing internal linkage
const char* const s1 = "hello";

// Internal linkage
const char s3[] = "hello";


There are two modules. Two modules are having the same set of variable names. However, when we compile and link them together, everything just work fine. This is because they are having internal linkage. The variables are only visible within their own translator unit (object file). No conflict will occur.

How about external linkage? Consider the following two files again.


// Module0.cpp
////////////////////
//External Linkage//
////////////////////

// Constant string which is having external linkage (Early detected during compiled time)
const char* s0 = "hello";

// String with external linkage
char* s1 = "hello";


and


// Module1.cpp
////////////////////
//External Linkage//
////////////////////

// Constant string which is having external linkage
const char* s0 = "hello";

// String with external linkage
char* s1 = "hello";


We will fail during linking time. The external linkage variables are visible among other translator units. Hence, compiler will complain duplicated variable's names being detected.

Till now, I guess you roughly have an idea on why the char array is not being accepted by template function. char array is having internal linkage by default. We need to explicit state that we want external linkage.

Please do not ask me why it must be external linkage. Ask Bjarne Stroustrup. His 14.3.2 "The C++ Programming Language" states that way.

The final piece of code to solve this problem is :-


extern const char s0[] = "hello world";

int main()
{

fun<s0>();
return 0;
}

Sunday, October 12, 2008

Template Version memcpy

I came across the following code snippet few days ago


template<int size, typename T>
void template_memcpy(T* dest, const T* src)
{
struct type {
T data[size];
};

*reinterpret_cast<type *>(dest) = *reinterpret_cast<const type *>(src);
}


The code seems pretty cool. It performs conventional memcpy, by depending on compiler generated code.

I made a test on Visual C++ 2008 compiler, to see whether the generated code from template_memcpy, is as good as conventional c-style memcpy.

Our source is a 31 bytes char array. Take a look on the conventional c-style memcpy source code, together with its disassembly.


memcpy(dest, src, sizeof(src));
00241053 B9 07 00 00 00 mov ecx,7
00241058 8D 74 24 1C lea esi,[esp+1Ch]
0024105C 8B FB mov edi,ebx
0024105E F3 A5 rep movs dword ptr es:[edi],dword ptr [esi]
00241060 66 A5 movs word ptr es:[edi],word ptr [esi]
00241062 A4 movs byte ptr es:[edi],byte ptr [esi]


From the assembly code, we know that CPU performs

1) Move double word (4 bytes) from source to destination memory 7 times.
2) Move word (2 bytes) from source to destination memory 1 time.
3) Move byte from source to destination memory 1 time.

How about the generated code for template_memcpy?


template_memcpy<sizeof(src)>(dest, src);
002410C7 B9 07 00 00 00 mov ecx,7
002410CC 8D 74 24 1C lea esi,[esp+1Ch]
002410D0 8B FB mov edi,ebx
002410D2 F3 A5 rep movs dword ptr es:[edi],dword ptr [esi]
002410D4 66 A5 movs word ptr es:[edi],word ptr [esi]
002410D6 A4 movs byte ptr es:[edi],byte ptr [esi]


See. template_memcpy is as good as conventional memcpy, isn't it?

OK. So, why do we choose template_memcpy over memcpy?

template_memcpy with come in handy, when you try to perform copy on array of objects.

Instead of :-


MyObject src[100];
MyObject *dest = new MyObject[sizeof(src) / sizeof(src[0])];

for(int i=0; i<(sizeof(src) / sizeof(src[0])); i++) {
dest[i] = src[i];
}

delete[] dest;


We may :-


MyObject src[100];
MyObject *dest = new MyObject[sizeof(src) / sizeof(src[0])];

template_memcpy<sizeof(src) / sizeof(src[0])>(dest, src);

delete[] dest;


The code seems cleaner, isn't it?

Of course, there is a shortcoming for template_memcpy. It only support memory size, which is known during compiled time :)

Followers