Tag Archives: programs

QuantNet’s International Guide to Programs in Financial Engineering.

QuantNet’s International Guide to Programs in Financial Engineering.

QuantNet is proud to announce the release of our latest QuantNet International Guide to Programs in Financial Engineering.  Our inaugural edition has been an extremely useful companion guide to the field of financial engineering for many students. It has been downloaded over 10,000 times since its debut. The 2013-2014 Guide has many new and updated contents, among them 2013-14 ranking of quantitative finance programs, career advice from top Wall Street executive, etc.  “Big Data” is an important topic these days, not only in finance but also other industries where quantitative skills are in high demand. We have it covered in this guide. You will learn what it means, how to prepare and reinvent yourself for this growing job market.  To download the Guide, please visit quantnet.com/guide  Best regards, Andy Nguyen

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Latest links for best ranking MFE Programs and Universities rated by QuantNet.com

Latest links for best ranking MFE Programs and Universities rated by QuantNet.com

If you cannot afford these schools or cannot be bothered, join my FREE newsletter to see how I plan to accomplish the equivalent

This just came in  from the founder of QuantNet.com

New York – QuantNet today released the third bi-annual edition of its MFE rankings which rank the top masters programs in Financial Engineering, Mathematical Finance, Quantitative Finance in North America. The 2013-14 QuantNet ranking is the most comprehensive ranking of such programs to date.

Founded in 2003, Quantnet.com, with its online C++ certificate (jointly offered with Baruch MFE program), MFE programs info/reviews, applications tracker, MFE grads salary database, accompanied by an active, knowledgable community, has grown to be the most comprehensive research tool for graduate students considering education and career opportunities in the field of quantitative finance.

Best regards,
Andy Nguyen – QuantNet

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Are their Sample Model Programs in Matlab in M Language?

Are their Sample Model Programs in Matlab in M Language?

Question from my Linkedin Group:

I have basic Mat lab programming knowledge. Can someone please post programs for learning Mat lab in depth.
Thank you in advance.

My answer:

http://quantlabs.net/labs/code/matlab-source
PLus we got other propietary Matlab code in our Premium Membership but we focus now on R

Get access to this now here or see the membership benefits

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Quant development: “Debugging of Multithreaded and Multiprocess Programs on Linux” at Silicon Valley Code Camp

Quant development: “Debugging of Multithreaded and Multiprocess Programs on Linux” at Silicon Valley Code Camp

We will discuss the connection between Linux kernel scheduler behavior and non-deterministic nature of multithreaded and multiprocessed programs. We will look at the issues faced by a multicore programmer, and look at Maze, a new concurrent development tool. We will discuss Maze architecture and look at the tool in operation. The target audience is software engineers, CS students and researchers, and anybody else who is interested in parallel programming, software testing, and debugging. Participants are expected to be familiar with the concept of a Linux process. The examples will be in C with the use of POSIX threads API.

When: Saturday, October 8th, 2011, 5PM – 6:15PM

Where: Silicon Valley Code Camp 2011 ( Code Camp Venue: Foothill College, 12345 El Monte Road,Los Altos Hills, CA 94022)

Link: http://www.siliconvalley-codecamp.com

 

Why exactly POSIX API ? You always give away performance when you try to gain portability (the principle otherwise known as “there is no such thing as free lunch” – well unless you drink beer 😉 – just saw the excellent part 1 of Ken Burns documentary on prohibition last night !)

 

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Add clipboard copy functionality easily to Windows programs with metafiles in C++

Add clipboard copy functionality easily to Windows programs with metafiles in C++

C++ clipboard copy with metafile demo sample program preview

Contents

Introduction

While I was reading Charles Petzold’s Programming Windows book, more specifically the chapter on metafiles, I was wondering what could be the potential usages of such a feature in a real world application. The chapter describes in length what metafiles do and how they work, but little is said about what you can do with them or why you should use them. I think that I found a worthwhile application for metafiles and I am going to share it. This article has no claims of inventing a revolutionary technique as it is ridiculously simple, but in the same time, it does not seem to be widely known. This technique is for sharing data among different applications, as for sharing the data among the same application, private data formats might be more appropriate. In this C++ Windows programming tutorial, I will give a brief overview of what metafiles are, and then I will present the technique.

Background

There are two types of metafiles: the original ones that have been around since Windows 1.0, and the enhanced metafiles. The difference between them is very small. The enhanced metafiles have a slightly more detailed header which makes them more self contained. There is no good reason to use the original metafiles unless you have to keep compatibility with an old Win16 application. If it is not the case, then you should stick with the enhanced metafiles. Metafiles are GDI objects that once opened will return a device context. Metafiles store all the GDI function calls performed with their DC and then allow the user to perform a playback of the stored GDI calls. They are one of the standard data formats that the clipboard accepts. MFC encapsulates metafiles functionality in the class CMetaFileDC which derives from the class CDC.

Using the code

The technique consists of putting your drawing code in a function that takes a device context object pointer as an input parameter:

void Draw(CDC *pdc);

This function can be called from your WM_PAINT handler:

void CChildView::OnPaint()
{
    CPaintDC dc(this); // device context for painting

    Draw(&dc);
}

Now, your new copy handler will look like this:

void CChildView::OnEditCopy()
{
    CMetaFileDC mfdc;
    if( mfdc.CreateEnhanced(NULL,NULL,NULL,NULL) )
    {
        Draw(&mfdc);
        HENHMETAFILE hmf;
        if( (hmf = mfdc.CloseEnhanced()) )
        {
            if( OpenClipboard() )
            {
                EmptyClipboard();
                SetClipboardData(CF_ENHMETAFILE, hmf);
                CloseClipboard();
            }
            else
            {
                /*
                 * The metafile is deleted only when it has not been set in
                 * the clipboard.
                 */
                ::DeleteEnhMetaFile(hmf);
            }
        }
    }
}

This is all that your program needs, to be able to copy the client area content and paste it in any application supporting metafiles.

The demo program

The demo program is just a simple MFC AppWizard generated SDI application where a bogus drawing function has been added to prove the concept. Then, the copy handler has been added to the CChildView class.

Points of Interest

You can easily adapt this code to a MFC View/Document program or a Win32 API program. Also, an astute reader pointed out that if your OnDraw() function calls attribute GDI functions such as GetTextExtent(), you must first manually set the metafile h_hAttribDC. You can either do that with a CClientDC or with an information context like that:

CMetaFileDC mfdc;
if( mfdc.CreateEnhanced(NULL,NULL,NULL,NULL) )
{
    // Create a second device context that points to the screen, in order to make
    // functions like GetTextExtent work correctly
    CDC cdc;
    VERIFY(cdc.CreateIC(__TEXT("DISPLAY"),NULL,NULL,NULL));
    mfdc.SetAttribDC(cdc.m_hAttribDC);

    Draw(&mfdc);
    ...
}

You cannot call SetAttribDC() with mfdc.m_hDC because the CMetafileDC version of this function forbids you to set m_hAttribDC to m_hDC but this is wrong! It should work because the first parameter of CreateEnhanced is:

  • pDCRef – Identifies a reference device for the enhanced metafile.

When it is NULL, the reference device will be the display. The reason why MFC ignores pDCRef and sets m_hAttribDC to NULL is probably becauseCMetafileDC also supports the old Windows 1.0 metafile format and these metafiles have no notion of reference devices. As a side note, I just do not like the Attribute DC notion of MFC DC classes because most of the time m_hDC is the same as m_hAttribDC and the presence of m_hAttribDC just adds a superfluous overhead all over the CDC code. The only exception where m_hAttribDC is actually useful is in CPreviewDC used in the MFC print preview feature. Here is an example of this from the MFC source code:

CPoint CDC::MoveTo(int x, int y)
{
     ASSERT(m_hDC != NULL);
     CPoint point;

     if (m_hDC != m_hAttribDC)
          VERIFY(::MoveToEx(m_hDC, x, y, &point));
     if (m_hAttribDC != NULL)
          VERIFY(::MoveToEx(m_hAttribDC, x, y, &point));
     return point;
}

Conclusion

That is it! I hope you that enjoyed this C++ Windows programming tutorial and that you have found it useful. In the next section, you will find the books that I have consulted to build this C++ Windows programming tutorial. Those books are great and filled with Windows programming gems that you should know. It is strongly recommended that you get yourself a copy of these books especially since from time to time, you can find these books at a bargain price. Take the time to check the prices. This is maybe your lucky day today!

Source: Thanks to Olivier Langlois

http://www.olivierlanglois.net/metafile-clipboard.html

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Idioms for using C++ in C programs (Part 1 of 2)

Idioms for using C++ in C programs (Part 1 of 2)

Contents

Introduction

Using C from C++ is trivial since it was one of the design goals of the C++ language. All you have to do is to conditionally wrap C functions declarations intoextern "C" blocks like this:

#ifdef __cplusplus
extern "C"
{
#endif
void A();
#ifdef __cplusplus
}
#endif

Doing the reverse is relatively easy if you know the simple guidelines. This tutorial is the first part of a 2 parts serie devoted of the topic. In this tutorial, I will introduce the simple guidelines and pitfalls to avoid when using C++ in C programs. The second part will continue by presenting higher level patterns to leverage the good software architecture patterns that C++ language facilities encourage into C programs.

1. The main module must be in C++

A lot of stuff happens before and after the main() function in a C++ programs such as initializing the global C++ objects. It is imperative to minimally have themain() function written in C++ for a proper initialization of the C++ run-time environment.

2. Avoid using strdup()

strdup() is not part of the standard C and C++ libraries so there is no guarantee on how the memory to store the returned string will be allocated. It could be with malloc() or it could be with new[] depending if it is called from a C or a C++ module. Fortunately, it is very easy to redefine strdup():

namespace util
{
// Variant #1
char *strdup(const char *s, int size)
{
    ++size;
    char *res = static_cast<char *>(malloc(size));
    if(res)
    {
      // Use memcpy() as it is faster than strcpy()
      // since we already have the strlen.
      memcpy(res,s,size);
    }
    return res;
}

// Variant #2
char *strdup(const char *s)
{
    return strdup(s,strlen(s));
}

}

I have 2 variants of strdup() since I have found out that very often the string length is known at the calling site so I save myself from recalculating it again.

3. Do not let C++ exceptions slip out of C++ modules into C modules

C does not understand C++ exceptions. The details of how C++ exceptions are thrown are specific to each implementation of the C++ language. I have not study exactly how it works but the C function will certainly not like the stack unwinding that the C++ called function will have performed. All that to say that if you forget to wrap your C++ entry points with a try/catch block and an exception slips out, the resulting behavior is undefined. At best, the exception will quietly disapear since you did not take the opportunity to catch it (very unlikely, IHMO). A much more likely scenario is that the program will core dump or if you are unlucky, you will get erratic behavior of your program in some other unrelated areas of it.

4. Use the pimpl idiom to carry objects into C structures

The pimpl was coined several years ago by Jeff Sumner (chief programmer at PeerDirect). It is a popular design idiom in C++ to reduce the header file dependencies. The best coverage of that pattern that I have seen is in the book Exceptionnal C++ from Herb Sutter but for the purpose of this tutorial, briefly the pimpl pattern is that the only data member of class is a pointer of a forward declared class:

class A
{
private:
  class CImpl;
  CImpl *m_pImpl;
};

In the cpp file containing the class A definition, you can include all the header files needed for class CImpl and declare CImpl with all the data members that you would have placed into class A without the pimpl idiom. What this technique buys you is that all the users of class A will not need to include all the header files that you included for the class CImpl.

If you want to store C++ objects in a C structure, the pimpl idiom is the only way to do it. Since I am not sure that C support forward declarations or at least not as well as in C++, I suggest using a void pointer as the implementation pointer and typecast it back to the correct type when you need to use it. Here is how you could do it:

sType.h:

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct {
  void  *m; /* Must be type less as you cannot include
             * a C++ template class declaration in C modules
             */
} sType;

/* C style constructor/destructor */
sType *create_sType();
void destroy_sType(sType *);

void use_sType(sType *);

#ifdef __cplusplus
}
#endif
sType.cpp:

inline std::map<const char*, int> *getMap(sType *s)
{
    return static_cast<std::map<const char*, int> *>(s->m);
}

// You must wrap your C functions entry points to be sure that
// C++ exceptions do not cross into C modules.

sType *create_sType()
{
    try
    {
        sType *res = new sType;
        res->m = new std::map<const char*, int>;
        return res;
    }
    catch(...)
    {
    }
    return NULL;
}

void destroy_sType(sType *s)
{
    delete getMap(s);
    delete s;
}

/*
 * For every methods that need to use the map, use the inline function getMap() to retrieve
 * the map from the sType POD (Plain Old Data).
 */
void use_sType(sType *s)
{
}

Conclusion

By following these 4 simples guidelines, you will be able to start using C++ from C. Of course, there is more to say on the topic such as patterns in C that when recognized, you can apply systematic transformations in C++ that will optimize the benefits of porting a program from C to C++. This is exactly that topic that is covered in the next part of this serie of tutorials. Also, my blog is probably the best medium if you would like to provide feedback to this tutorial, you can do sohere.

Source: Thanks to Olivier Langlois

http://www.olivierlanglois.net/idioms_for_using_cpp_in_c_programs.html

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!