Sunday, October 30, 2016

Protect your streaming video from being stolen


Let's start with the “The Golden Rule”:
Anyone who can watch your video, can steal your video.
The best way to deal with it, is to minimize the number of times the video is stolen.

The most simple method of stealing, is to use a video capture technique.
video capture is an application that captures whatever is displayed on screen. It is possible to define a certain area or window (i.e. the video screen), play the video and tell the utility to capture it.

What can be done ?
An effective way to deal with that, is to apply watermarks, for example a graphical logo with a link to the author domain. Even if someone uses such video content, it will only advertise the author. Be aware, that it is simple to cut out logo of such type using any program for video editing, that's why, a good solution is to use a dynamic watermark which appear in different places, be shown during some period of time and faded.

Beside that, the best and most practical way to stop theft is to use a streaming server as follows :

1. First of all, use an encrypted streaming method( SSl streaming, RTMPE, etc.. ).
2. Secondly, use the following mechanism:
1)  Client create an ID token, Update the server DB and send it to the streaming server.
2)  Based on the ID token, streaming server find out the appropriate media file(Use a server that support plugins) and remove token from DB (If you want to be more secure , those ID tokens could have a limited time of use).


Advantages :

1. Your true streaming link is not exposed in the client.
2. Its not possible to use any software to download the media.


Please feel free to contact me if you have any questions.

Good Luck.

Moris Oz
Caapi Technologies



Tuesday, April 28, 2015

Fullscreen video streaming via www for Unity iOS


Unity is a flexible and powerful development platform for creating multiplatform 3D and 2D games and interactive experiences, It's goal is to create a fluid and fun to use cross platform apps. Unity is made to empower you to create the best interactive entertainment or multimedia experience that you can.

In this article we will be discussing one of the most interesting feature of Unity, Which is "Video streaming"

Based on the unity manual, in order to stream a Video in fullscreen mode for mobile devices, we should use the "Handheld.PlayFullScreenMovie"  function, but unfortunately, its not really helping us in our case, because this function can only stream movies from a local storage, and not from the web media server. Loading a movie from an asset bundle is painful because the bundle takes so long to load especially if you have few movies that are very large.

The way to overcome this problem is to use a method called Plugin. In Unity, you normally use scripts to create functionality but you can also include code created outside Unity in the form of a Plugin.

Before we begin, we should be aware that The Mono Runtime (Unity engine's scripting is built on Mono, Which is an open source development platform based on the .NET framework, allows developers to build cross-platform applications ) makes calls into native code using C standards. Any language that follows the C calling convention can be called. Unfortunately Objective-C does not follow this convention. We will have to wrap Objective-C APIs with C code to make it available to Unity. This is done by putting our calls inside C functions and using a C compiler to compile it. Our file will contain calls into C++ so we need to use a .mm file with Extern "C" { at the top and } at the bottom to avoid name mangling issues.

The first phase, should be to write a wrapper with a C named ( Unity needs the plugins to be C named. That's why, we need to wrap it in an extern “C”.), and from that wrapper we can call to the video class.

So, Let's begin :

1) In your Unity project, create a folder Assets/Plugin/iOS. Files in that folder (can’t be in a subfolder) automatically get added to your iOS project when you have Unity create an iOS build.

First, we create the iOS wrapper plugin file. In that file, we put the code for the iOS side of the plugin. Unity needs the plugins to be c named. So, we wrap it in an extern “C”.

Here is an example plugin:

videopluginwrapper.mm:

#import "videoplugin.h"
extern "C"
{
    bool videoIosPlay( const char* url)
    {
            return [videoPlayerHelper play:[NSString stringWithUTF8String:url]];
    }
}


2) Second, we create the actual iOS video class.

videoplugin.h:

#import <MediaPlayer/MediaPlayer.h>

@interface VideoPlayerHelper : NSObject {
@private
        // Native playback
    MPMoviePlayerController* _moviePlayer;
   
     }

- (BOOL)play:(NSString*)url;

@end


videoplugin.m:

#import "videoplugin.h"
#import <AVFoundation/AVAudioSession.h>

@implementation VideoPlayer

////////////////////////////////////////////////////////////////////////////////

// Play the asset
- (BOOL)play:(NSString*)url
{
    BOOL ret = YES;
   
    AVAudioSession *session = [AVAudioSession sharedInstance];
    [session setCategory:AVAudioSessionCategoryPlayback error:nil];
    NSURL *urlMovie = [NSURL URLWithString:url];
    _moviePlayer = [[MPMoviePlayerController alloc]
                                       initWithContentURL:urlMovie];

    _moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    _moviePlayer.shouldAutoplay = YES;
    _moviePlayer.view.transform = CGAffineTransformConcat

(_moviePlayer.view.transform,CGAffineTransformMakeRotation(M_PI_2));
   
    UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow];
   
    [_moviePlayer.view setFrame:backgroundWindow.frame];
    [backgroundWindow addSubview:_moviePlayer.view];
    [_moviePlayer prepareToPlay];
    [_moviePlayer play];
   
    return ret;
}

@end


3) Now that we’ve built the plugin, we are ready to call it from Unity code. first, we need to declare the native functions that will be using in managed code(we put this file in the Assets folder) :

VideoPlayer.cs :

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

public class VideoPlayer{

    /* Interface to native implementation */
   
    [DllImport ("__Internal")]
    private static extern void videoIosPlay(string strUrl);
     
    // play movie
    public static void PlayVideo(string strUrl)
    {
        // Call plugin only when running on real device
        if (Application.platform != RuntimePlatform.OSXEditor)
            videoIosPlay(strUrl);
    }

}


*** Note that the “__Internal” name is used for iOS plugins.


4) Finally, we create a Unity script to use it.

TestPlugin.cs :

using UnityEngine;
using System.Collections;
public class PlayerScript : MonoBehaviour {
   
    private float    _buttonX = 30f;
    private float    _buttonY = 30f;
    private float    _buttonWidth = 30f;
    private float    _buttonHeight = 30f;
   
    void OnGUI ()
   {
        if(GUI.Button(new Rect(buttonX ,  _buttonY, _buttonWidth, _buttonHeight), "Play"))
        {
            VideoPlayer.PlayVideo("Movie WWW Link);
        }
    }

}


That's all for now.
please feel free to contact me If you have any questions.

Good Luck.

Moris Oz






Wednesday, March 28, 2012

The Art of Memory optimization in android frame animation.

I remember when I was a child, we have made drawings on papers which acted as animation. We draw numerous slides one by one and arrange them and flip them speedily. Flip books are low-tech fun that still appeal to kids today, especially if they are creating them themselves. Back then , there was not any problem with memory ( in the worse case we add more papers and expend the Flip book ).
Implementing animation on android is a totally different story. Each application has very limited amounts of memory, and it’s based on the specific firmware running on each device. Assume that your animation frame images are compressed (PNG or JPG). The compressed size is not useful for calculating how much memory is needed to display them. For that, you need to think about the uncompressed size. This will be the number of pixels multiplied by the number of bytes per pixel, which is typically 4 (32 bits).So let’s say , you have an animated cannon with 9 position ( Each position contain 8 frames of 130x130).It will require a total of 4,867,200 bytes to hold the raw bitmap data for all the frames , and this is only for one character animation. Within a regular game you have many characters and many animations. That's bring us to "Out Of memory error - Bitmap exceeds VM budget" error message, which is one of the most annoying (and common ) errors when dealing with bitmaps and Android ( you will find plenty of other posts related to this issue), and its caused due to limited virtual memory heap size.
To summarize the subject, you need to find a way to draw your animation using less memory. There are many options, but it depends a lot on how your animation needs to look.   One solution is to re-sample and scale your bitmaps prior to inserting them into the cache, by checking the image size and then down sample it by appropriate factor. Changing the sample size reduces the amount of memory used, but it will come on the cost of image quality. The other solutions is mainly determined by the animation style and an "out of the box" solutions. For example, if we go back to the cannon example. I can optimize the memory, by loading only one direction of the cannon positions, and mirror the other side when needed. The way to do it,without creating a new bitmap, is as followed :

//Load the Cannon drawable ( with only one direction of the cannon positions frames)
Bitmap sprite = BitmapFactory.decodeResource(this.getResources(), R.drawable.spritegfx );

//Create a matrix to be used to transform the bitmap
Matrix mirrorMatrix = new Matrix();

//Set the matrix to mirror the image in the x direction
mirrorMatrix.setScale(-1.0f, 1.0f);

//The image will draw flipped in X, but it will also appear to the left of the Y axis, which defaults to the left edge of the view. post-translate everything to the right by at least the width of the bitmap, to make it appear on screen.
mirrorMatrix.postTranslate(bitmap.getWidth(), 0)

// Save the default matrix state
canvas.save(Canvas.MATRIX_SAVE_FLAG);

// Apply your matrix on the current canvas                        
canvas.concat(mirrorMatrix);

// Draw bitmap on canvas. source Rectangle is created based on the current animation frame.
canvas.drawBitmap(sprite ,sourceRect,destRect,null);

// Restore original state
canvas.restore();

please feel free to contact me If you have any questions.

Good Luck.

Moris Oz
Caapi Technologies

Sunday, December 18, 2011

IB SDK/API review

This article reflects my experience developing an automated equity trading platforms using the IB SDK/API. I have written this article as an individual, not representing IB (Interactive brokers) in ANY way.

The IB Application Program Interface (API) connects through the Trader Workstation (often known as TWS) or the IB Gateway. TWS is programmed in Java, which is platform-independent and can be very useful( but, it is not as fast as it would be if it was programmed in C or C++ ). In order to connect to IB, the TWS (Trading Work Station ) application must be running in the background. The connection takes place via a network connection. If the TWS and the API application run on the same system this network connection will be through localhost ( which is a bit awkward, since trading program execution requires TWS to be run first to establish a session).

The good news is that, TWS provides a great API ( application programming interface ) in several programming languages, which including Java,C++, ActiveX and DDE for Excel ( there is also a possibility to get an interface in C# ), and this can be used to access almost all of the TWS' features via other programs. The API code makes a TCP/IP or local host connection to the TWS software( usually to port 7496 on the local host). There are two sides to the communication: the request and the response. This means that the process of reading from the socket and writing to the call back methods, is asynchronous and it takes place in separate threads. IB transaction either go through the TWS (trading software),or through CTCI FIX. When using The IB API, A single account (user name and password) is limited to 50 messages a second. Using the CTCI FIX interface the limit is150 messages a second. If you have the possibility, I would suggest to avoid using the CTCI FIX since its complex and sample applications are not provided.

Beside that, this are some of the issues that I had to deal with :
1) Opening an account with IB takes a long time. Application forms are the largest I have seen.
2) The API Chat is usually empty ( Which mean that I am the only person in the room ). Only Registered clients ( customers who paid money ), will get a full customer support by mail.
3) There were several technical issues, which forced me to find a creative solution inorder to make my trading platform work as I needed. For Eg: I placed a limit BUY at $60 for a stock at $30, IB rejected the order as too far outside the NBBO. Well, IB allows you to override TWS order price percentage constraints ( which are applied to orders that TWS sees as deviating too much from the NBBO` of the contract ). Unfortunately, setting this param ( from TWS or the API ) had no effect, and my only alternative was to place a market order. I guess, That this param exist there as a restriction created by the exchange in order to "protect" me. But, If I'm responsible enough for my own trades and want to make some more money, why this feature is not working ? Maybe if enough people will complain to IB , they will fix it.
4) Limits to data requests : 60 requests in 10 mins (almost) without pacing violations, But also this issue can be handled by implementing a smart mechanism ( Or you can just get real time data from Yahoo! Finance )

Despite of the problems I've described above, My main impression is good. The very best advantage that IB offers for developers is that there is a discussion forum, which serves as a serviceable message board where traders read and share information or even post programming code, also a very good API reference guide is presented, and you get code samples which,ship with the IB's API package.(Code samples :Cpp, Java, VB6, VB.NET, C#.NET).

IB support ( Only Registered clients ), a paper trading account which allows traders to test the full range of IB trading facilities in a simulated environment using real market conditions. Its especially beneficial to traders that want a special strategy implemented for them by a developer, without using there real account (paper trading account works just like the production account, but has different username/password). as well, Users can test new strategies and ideas risk-free or learn about order execution of global products they've never traded in the past. Last but not least, IB allows very sophisticated, advanced order specification and routing. They allow you to trade just about every kind of tradable security.

Moris oz
Algorithmic trading Consulting and development
www.caapitech.com

Sunday, July 3, 2011

Artificial Intelligence Goes to Wall Street: Trading Platforms Get Smarter

Press Release

It is no secret that for many years global banks have used artificial intelligence to make better trades. Now that technology might be coming to your local independent investment advisory service.
Caapi Technologies just announced that it signed a deal to use artificial intelligence technology to build custom trading systems for small to mid-size investment firms. Caapi will build applications with software development kits (SDKs) from ai-one that enable computers to understand human language to find undervalued stocks, bonds and derivatives.
The partnership makes Caapi one of the first consulting firms to use ai-one’s machine learning technology to build trading algorithms and platforms for traders, banks and hedge funds.
Building custom trading algorithms is a huge industry propelled by the success of high-frequency trading across global markets. Originally, these algorithms were designed to find and exploit pricing differences between stocks, commodities and derivatives. Now trading algorithms are so widespread and so sophisticated that they have completely reshaped markets to the point where pricing is often driven more by speculation than it is by the underlying value of the asset class.
The challenge now is to find underpriced opportunities that generate returns based on actual performance rather than market volatility. This requires that investors sort through vast amounts of unstructured data to find undervalued assets before they are identified by the rest of the market. Often this means reading text that can’t be processed by search engines like Google. Traditional algorithmic approaches, such as Google’s, fail as they only know what they are programmed to know or programmed to find. They miss finding unexpected results that don’t fit into an equation.
ai-one’s technology is described as “biologically inspired intelligence.” It is modeled after the human brain and does not depend on algorithms. Rather, it automatically sees the inherent patterns within data and forms associations between each data element. This enables machines to learn without any human intervention. More importantly, it enables people to ask the questions they wouldn’t normally know to ask.
The CEO of Caapi, Mr. Moris Oz, sees machine learning as the key to discovering hidden investment opportunities. “a-one’s technology enables us to build semantic associative search engines for our clients that understand how the price of any given investment is related to the unstructured data found on the internet.”
Caapi’s approach is to combine proven techniques using sophisticated algorithms with machine learning that understands words.  “Language is not math,” adds Olin Hyde, VP of Business Development at ai-one. “Algorithms are fantastic at processing structured data. But human behaviors and communications are inherently unstructured and complex. We learn through words not equations. So why not enable computers to do the same?”
According to Moris Oz, CEO of Caapi, “ai-one’s SDK for machine learning could be the answer for understanding and correlating soft data driving price moves in the markets.  I’m looking forward to applying this to new applications.” The market will soon tell if it works or not.
About Caapi Technologies, Caapi Technologies is a small, dynamic and friendly software-development company, capable of providing quick solutions for a variety of systems. Caapi Technologies was founded by Moris Oz, a skilled software developer with vast experience in various technologies, who leads all software projects. The company offer solutions for the many various stages of development, and services such as software development, web applications development and algorithmic trading solutions. Caapi Technologies's expertise spans the most common technologies such as C, C++, C#, .NET, Java, Jscript, PHP, ASP, VBscript, GWT, Flex, PHP, CSS, XML, Facebook SDK and more. They designed, programmed and delivered some very challenging and rewarding projects in the US and abroad
For more information see http://www.caapitech.com
Contact Moris Oz, Ph +972-9-8656875 email moris@caapitech.com
About ai-one inc., ai-one provides an “API for building learning machines”.  Based in San Diego, Zurich and Berlin, ai-one’s software technology is an adaptive holosemantic data space with semiotic capabilities (“biologically inspired intelligence”).  The Topic-Mapper™ SDK for text enables developers to create intelligent applications that deliver better sense-making capabilities for semantic discovery, lightweight ontologies, knowledge collaboration, sentiment analysis, artificial intelligence and data mining.
For more information see http://www.ai-one.com
Contact: Olin Hyde, Ph: 1-858-531-0674, email: oh@ai-one.com, web: www.ai-one.com

Wednesday, June 22, 2011

Troubleshoot - Android Platform Sooner Single ADB Interface error

When installing The Android ADB Interface drivers , There are situations where the system complain that the driver is not found , or the driver installation has failed. I was researching the web and found many solution , but neither of them really worked for me.
Anyway , This is my solution : 

1) Using a free tool called USBDeview you should first spot your ADB Interface driver (Using the USBDeview You can try uninstalling devices until you see in the DeviceManager that the ADB Interface is not there anymore) 
2) Now, unplug-plug your mobile device and spot the ADB Interface in the USBDeview,   look at the vid info of that interface , Over my place it looks like that :
Description =  Android Composite ADB Interface , Instance ID = USB\VID_1004&PID_618E_ADBInterface\6&34ef9180&5&0000 )
2) You need to download Google's android_usb_windows.zip package that contains the
driver.  Then unpack the zip file.
3) In the android USB windows folder ( C:\Program Files\Android\android-sdk\extras\google\usb_driver ) , edit the android_usb.inf file and add the specific Instance ID As followed :
"%CompositeAdbInterface%     = USB_Install, USB\{Your Vid Info}" 
Over my place the row Looks like that --> 
"%CompositeAdbInterface%     = USB_Install, USB\VID_1004&PID_618E&ADB.DeviceDescRelease%=androidusb.Dev, USB\VID_1004&PID_618E_ADBInterface"
4) Now , Try again to Update the ADB driver from the android USB folder, and make sure the ADB Interface driver has been installed without error in Device Manager.

If you still have problems , please let me know.

Good Luck.

Moris Oz
Caapi Technologies

Monday, June 13, 2011

Web Applications Development services

Hello All,

I'm pleased to announce the availability of Caapi Technlogies's new web applications development services. With all of the emails and questions we’ve been getting from our customers about providing custom web applications development services that are easier to use, attractive to look at, and serve the purpose of the clients, we’ve decided to start. So head on over to the Services page to get a full range of web site application development services, from requirements gathering and definition, through the delivery and deployment of web solutions. Our expertise spans the most common technology platforms such as Java, .NET, GWT, Flex, PHP, CSS , JS ,Facebook SDK etc., for building scalable, feature-rich Web applications. As part of our web development services we provide customized, secure and advanced Facebook Application development services. We build Facebook applications with unique, fresh concepts and stylish designs; and provide all the ongoing support needed thereafter.

Best Regards,

Moris Oz
Founder and CEO
Caapi Technologies

Sunday, May 22, 2011

MBTrading SDK/API review

This article reflects my experience developing an automated equity trading platforms using the MBTrading SDK/API. I have written this article as an individual, not representing the MBTrading in ANY way.

MB Trading's SDK/API is a fully Microsoft COM-compliant. It is dependent on Microsoft COM Objects and is suggested for use with VB, C,.C# and Excel.
MB Trading's support and high level technical folks are very helpful, but they could not resolve all of my technical issues, which been raised during development phase.
Here are some of the issues that I had to deal with :
1) The source code samples, provided by MB, shows how to pull one quote using the main thread , but there are some problems when pulling many quotes(with different symbols ) using the main thread. In order to solve it , I needed to work my way finding a creative multithreaded solutions .
2) When asking for historical data using the API , the document gives good specification on the various parameters , but when putting all things together in my own code , there was a need to play around with the parameters till the mechanism was really working.
3) A minor "minus", which was not a big concern for me , was that MB Trading's API "consumes" a login, and clients (by default) get only 1 login. This means , You just can't be logged into both of them with the same username( BTW , Forex traders are entitled to a free secondary login ID ).

Despite of the problems I've described above , My main impression is good. The very best advantage that MB Trading offers is their customer support and a  SDK site (http://sdk.mbtrading.com/)  with associated Yahoo! groups forum, and a very well documented API. You can check out the library of the code samples (VB6, VB.NET, C#.NET) ,which you can download in a zip file ( http://sdk.mbtrading.com/v.htm )
That should give you some examples of how to employ various approaches in your coding to use the objects in the SDK. The big plus for developers , is that MB provide a free demo , which is great to get your software developed and fine tuned. (Even though ,Demo logins may not see the current day for day bars, the current hour for min bars, or the current 20 mins for tick bars)

Moris oz
Algorithmic trading Consulting and development
www.caapitech.com

Wednesday, October 20, 2010

SmartGWT vs. Ext GWT ( Or 80-20 rule of development )



When you choose the framework you plan to work with, you try to select the best framework. It means that the framework has all required features, is flexible for extensions, has clear code, has rich documentation, is easy to use, has consistent APIs, has strong usage community , has  good support ,easy deployment, performance , memory issues is handled, and for sure ,has potential for future grow and new features implementation.
In the Web UI world, such framework does not exist and probably such framework doesn’t exist at all.   We need to understand that our expectations will never be fulfilled for 100% .We need to choose the framework at the begging of the project and at this point we still don’t know which extreme UI features our Functional Architect will require. We can just estimate, but from my experience the real final thing that really works and can answer on customer requirement may be far away from the initial estimation.  Anyone who has experienced with UI development will agree with me, since UI has the most dynamic changes in between versions, weekly and daily. So ,we just can’t expect from the selected framework to be perfect, and I am Ok with this as long as this framework answers on 80% of my expectations and allows me to extend it as I wish. These 80% include rich set of features, clear code and APIs, flexibility for extra extension, rich documentation, easy use and performance and memory issues handling. The limitations that I may allow are: The framework doesn’t need to be at the top of the GWT technologies development, but however it should be clear from the community forums that it goes there and in future versions all new features will be handled. In other words, it should be on the Technology Front, but it is not need to have all implementations right now. As well, I don’t expect it to have all UI features that I can  think about, but rather I expect it not to limit any feature development, allow components extensions and access to system native APIs.
In my research and conclusions regarding existing GWT UI frameworks I followed the concepts described above. My experience with SmartGWT is longer than with Ext GWT, I started with SmartGWT about a year ago and developed several screens for UI MashUp system, and recently I created a whole mockup with complete application layout, skinned and rich of ‘Wow’ effects of animation and fadeout-fadein. After I drilled down to the head of this library I turned to find something better. Recently I created the similar system with Ext GWT in order to compare my impressions. My purpose was to evaluate the feasibility of all of the features I implemented in the first project and also to test Ext GWT API in order to learn it better.
When I started, first of all I tried to find the most popular frameworks by the lists given by Wikipedia and other public sources. I rejected almost all frameworks because they were not rich in enough features, so I only selected two libraries, for checking: SmartGWT, ExtGWT, both work with GWT 2.0.

General APIs impression
o   The impression is that SmartGWT has exaggerated usage for their  GWT Widget wrapper object (the Canvas object):
       All APIs receive Canvas, that’s why, it actually makes it impossible to use native GWT components inside SmartGWT components. So the main impression is that SmartGWT is completely separated library ,which includes a really rich set of features but also obliges you to use their only components. For me it’s a limitation, because again my assumption is that any library ,just can’t include all  features in the world ,and in some stage in my development it will be necessary to use more components then only SmartGWT components. Also it makes my code depends forever on SmartGWT. I know that other libraries will make my code to be depend as well on there libraries, but if they supports GWT native objects it will be easily to decouple the code from them.
o   The example for such APIs: addMember(Canvas) of HStack object or method setPane(Canvas) of Tab.
o   In addition to this dependency, the APIs are not consistent; adding new member to the container element differs from object to object, as in the above example with layout object and tab. Both methods mean the same functionality – adding a new child to the container, but for some reason have different names: once it’s called “addMember” and another called “setTab”. 

These are just small things, but when you deal with big project and with thousands lines of code, it became very annoying.
There were no such problems with Ext GWT, the APIs are very close to GWT APIs, all receive native object and are consistent.

Effects
I wanted to implement something similar to IPhone panel, when you see one screen the second flies over it from the side. In both libraries I didn’t find a good way to do it. In both of them, I discovered problems when running animation on object which is inside the container. I still continue implementing it with Ext GWT, so now, it seems that I will need to create some floating absolute positioned panel and just move it over the first screen; this is exactly what I did with SmartGWT.
The other effects like fade-in-fadeout, rich set of move and other animation effects, exist in both libraries.

Layout APIs
Ok, the Ext GWT has very good Layout set, I tested almost all layouts and it works fine. From the begging it seemed to me too much complicated, too many different layouts: FitLayout , BorderLayout, CardLayout, CenterLayout etc, but after several tests I liked the structure and the concepts. It just worked as expected.
In SmartGWT there are two main layouts: HStack and VStack, from the first view it seems that everything is possible to create with these two basic stones, but somehow it has a lot of problems. The problems that I saw mostly were related to screen stretch layouts and alignment problems. Till now I didn’t succeed to align image to the center of the Canvas, if you know how to do it I will be happy to get the code sample. Also the Canvas basic object for some reason has 100px height by default, so if you want to create a smaller object, you must set the exact pixels, this is not good enough and to solve it I did some ugly workarounds. 

Events model
Ext GWT 2.0 still uses Listeners and it require some work to implement the MVP pattern. These Listeners are something between old GWT listeners and new Handlers pattern and in their roadmap they promise to implement new GWT Handlers mechanism in the coming 3.0 version.
SmartGWT uses GWT Handlers approach.

UIBuilder
UIBuilder is not supported. As I understood from Ext GWT forums this is not because of the library, but because of UIBuilder is not yet opened its internal API for overriding. However because of the fact that Ext GWT APIs are closer to GWT native APIs, I believe that once it will be possible it will be supported quickly by Ext GWT, while for SmartGWT is far away because of the code wrappers and other APIs limitations described above. 

Look&Feel Flexibility
Both libraries work with well defined skin. In SmartGWT the skin has code JavaScript extention, it consist of style css file and javascript file there you can add more logic, for example you can manage more UI controls modes than exist in css like toggled buttons. The Ext GWT skin contain just one style file, as simple as it should be for my opinion. 

Component set
Very rich in both libraries, SmartGWT has more built-in functional components, but Ext has more rich Layouts.

Performance issues
This is the most painful point for SmartGWT, because SmartGWT is not built as GWT native code, but is simply a wrapper above existing JS library. That’s why, it can’t use GWT compiler performance optimizations (like code split points). Yep, despite the fact that somebody already tried to convince me that the performance in general is OK and already have tested on big systems I think this is really big minus. GWT is quick growing technology and from version to version Google add more features, so choosing SmartGWT will mean that no core compiler features may be used in the future.  

Support and Community
When I downloaded Ext GWT I started asking the most stupid questions on their forum, about how to run the library and its components. In all cases I received immediate quick answers. For me this is a good sign. Also Ext GWT has a support package that includes online and offline support and even private patches (this service cost money). So, with whatever you need, you can get an urgent help, just payJ )
SmartGWT has also a big forum; it takes up to several days to answer, not bad for open source library.

License
SmartGWT is open source. Ext GWT has commercial different packages license from general to platinum, the license is per developer without royalty and also open source version that can be used for open sources products

My Conclusion
Ok, so where are the drawbacks of Ext GWT? My answer is that they are just there; I didn’t have the chance to discover a lot of them. Because I’ve started with SmartGWT and experienced all drawbacks of it, I only tested the same features for the second library to insure that it is built in the different way. So probably some problems will arise and I don’t expect it to be perfect, but again on the rule of 80-20 the Ext GWT beats SmartGWT in almost all aspects. 

Alona Oz
Web UI Expert

Thursday, October 14, 2010

Tips for developing the best High frequency trading (HFT) system.

1) When developing your HFT system , make sure you have an order execution engine that mirrors how the market acts , which will help you test/debug your platform/strategy in your own computer. The 'test mode' that usually supplied by the exchanges is not a replacement for that. Remember that your main interest is to preform all unit testing in your own environment , before you even start testing on the server side. Any Developer knows that its a big headache to debug on remote server ,especially when the far server do not have a debugging environment. For eg: Think about a situation when you are testing remotely in the server and you get a crash ,which caused because your system cannot deal with the low latency - Now ,your immediate response will be to put some prints and find where is the bug that cause the crash - but if you put some prints you suspend the system ,and the bug will not be there anymore - Now , how can you solve this problem remotely ?

2) Latency is the most important issue in HFT , That's why your code needs to be tight, fast and rock solid stable. Having an Algo crash and being caught with shares when the market moves against you is not very profitable . Well-written code runs fast, whereas poorly written code runs slow. Furthermore, well-written, object-oriented code will be far easier to debug and maintain.

3) The best Latency can be achieved by using hardware-accelerated functions - In other words , instead of using high level language - your platform+strategies will be converted to custom block of hardware that can run many times faster than the same code optimized in tight assembly language. But ( There is always But ) , you can only get there after you wrote the best optimized code by yourself , and then you will get some ideas about the parts you want to optimize.

4) Before even start coding , think about all the bottlenecks that will come letter . Find the solutions before they appear .Design your system in a way that it can be expended easily without damaging the latency.As you know sooner or later you will have to add more features - make the design ready for any future requirements.

5) Use the power of the hardware you have - make sure your software can take the advantages of the hardware you have.Design your software in a way that if tomorrow you get a new powerful hardware , It will boost the performance of your software's performance without the need of changing your software, because your software was designed from the beginning , to naturally fit your hardware architectures.

6) Be sure to be armed with the latest technology - That's what can make the difference between micro and nano sec. Change your development approach and start thinking of using parallel programming standards such as MPI for processors communication or other advanced techniques for Shared Memory messaging (This days , you can get to 700 nanoseconds of Latency for IPC). By using Advanced process techniques ,you can identify patterns among streaming event data and respond to those patterns in microseconds , This makes it possible to monitor, analyze and act on market data and respond immediately. You can use neural network for stock market prediction , Evolutionary Computation techniques, such as genetic programming to analysis of financial markets with a reassuring degree of success ,and fuzzy logic to find patterns and trends in financial indices. By Using advance A.I. technologis , the experience of a trader can be incorporated in a natural way inside your system.

Moris oz
Algorithmic trading Consulting and development
www.caapitech.com

Tuesday, October 5, 2010

The Benefits of outsourcing 'Algorithmic Trading' projects

(1) Independent Traders - Some traders wants to test there strategies using HFT structure, after testing with basic tools. They need a flexible HFT system with a mechanism for easily integration of various strategies within the system, with a full ability to add features that they need, with a "personal developer" that give them the right support they need.

(2) Setup A business - If you ever run an HFT System , you know that first you have to set up the legal and administrative structure and then set up the physical trading infrastructure ( hardware , server hosting, collocation servers - Especially in HFT you want to locate your servers near an Internet backbone as close as possible to the exchange on which your trades will be executed) , and you already spent around 100,000$ in the good case , without even start developing any system yet.Recruiting a development team will cost you extra million $ and you still have no profit yet.

 I recommend to my clients:
(1) Establish your business - First Establish your business :Get a freelance talent translates into cutting-edge skills and fresh perspectives to help get jobs done faster and better.Freelancers can help complete projects quickly, without the cost of additional overhead that full-time employees require. By finding the right professional programmer that already build an HFT infrastructure before ,you start a project right away and Give your business a competitive edge , instead of wasting big amount of money and weeks or months to hire people, train them, and provide the support they need. And if talking about HFT system that requires major capital investments , the start-up process can be even more difficult.
(2) Building one step at a time - I believe in Building one step at a time ,and go on to the next step after the previous one have been tested successfully.To start small, with limited investment and gradually scale up the business as you gain know-how and become profitable.It will be much easier to get more capital invested in your system after you have A simple HFT system with basic strategy that is working well and making some money. After you get more capital , you can invest in finding good physicists, mathematicians to get you a better strategies and if needed find some developers to add/optimize more features in your system.
(3) Focus in the core business - As mentioned before , In the 'Algo trading' business there is much more then development .I believe that my clients should Focus in there core business and let me do the development and to find the technical solution for them .As you know Every business has limited resources, and every manager has limited time and attention. A Good freelancer can help managers set their priorities more clearly.
(4) Risk management -  Every business investment carries a certain amount of risk. Outsourcing providers assume and manage this risk for you, and they generally are much better at deciding how to avoid risk in their areas of expertise

Moris oz
Algorithmic trading Consulting and development
www.caapitech.com

Monday, October 4, 2010

How to choose the best Algorithmic Trading programmer ?

1) Communication : When choosing someone to do any type of programming work for you, make sure you can communicate with him or her. After All - you want them to understand what you want and need.

2) Experience : You need to figure out whether the person is really capable of doing the work. In other words, make sure that he aren't the kind that just "talks the talk".Building an Algorithmic Trading machine requires a very professional programming skills.. This is especially true for high-frequency strategies where the speed of execution is of the essence.
Make sure your Developer have an in-depth knowledge of trading technology , and he already did something like that before.

3) Efficient : Sometimes you have a basic idea of what you want and need ( For Eg: I want an HFT Algo Machine that can trade Forex ) , But you don't really know how to go about doing that. Exchange , DMA , Brokers , Protocols , Backtesting , hardware , Software , etc.. - let the programmer help you with that - let him determine what would really help you be more efficient.

4) Flexibility: Some customers know exactly what they want and can put it all in writing. This ability enables the customer to require that the programmer give an exact quote on the project. When the project is completed, the customer should receive precisely what was requested. If the customer is not quite firm on what is needed , then it will most likely be necessary to implement changes during the creation stage. These changes in direction require a flexible programmer. The programmer should be able to handle a reasonable amount of such changes without having to increase the bid. However, if a programmer lacks flexibility it will probably be impossible to get changes implemented without a new quote being made. Of course, this process involves additional cost and time.

5) Price : software is part art, part science, and part math. its a craft that requires more then 10 years to master.Would you hire the cheapest doctor, lawyer, or plumber you could find? If you take trading seriously and think of it as a business, this makes no sense.As they say you get what you pay for. hire a pro, he'll have it done in 1/4 the time and it will be right the first time. In Algorithmic Trading machine - Any Bug can be crucial , especially If talking about HFT systems - if your system is not fast enough , then you are out of the game.

Moris oz
Algorithmic trading Consulting and development
www.caapitech.com