The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Amibroker::OLE::Interface - A Simple Perl interface to OLE Automation framework of Amibroker Software.

VERSION

Version 0.02

SYNOPSIS

    use Amibroker::OLE::Interface;
    my $obj = Amibroker::OLE::Interface->new( { verbose => 1, 
                                                dbpath => "C:/amibroker/dbpath"
                                            } );
    $obj->start_amibroker_engine();
    $obj->run_analysis( { action => 2,
                          symbol => 'NIFTY-I', 
                          apx_file => 'C:/amibroker/apx/path/nifty.apx', 
                          result_file => 'C:/amibroker/result/path/report.csv'} );
    $obj->shutdown_amibroker_engine();

DESCRIPTION

Amibroker is one of the most used Automated trading and charting software in the world. Visit Amibroker website for information : https://www.amibroker.com/ Amibroker has provided OLE Automation framework, to interact with Amibroker engine from external scripts/programs. You can refer to the AmiBroker's OLE Automation Object Model guide: https://www.amibroker.com/guide/objects.html

This module will help programmers who use Amibroker to access the objects easily in perl.

PREREQUISITE

Prerequisite to use this module : You need to have Amibroker v.5 and above (32-bit or 64-bit) installed in your system.

new()

Constructor to create the object for interacting with Amibroker engine. The new() class method starts a new instance of an Amibroker OLE Interface object. It returns a reference to this object or undef if the creation failed.

    Eg: Amibroker::OLE::Interface->new()
Parameters to the constructor
  • Verbose is optional

  • dbpath is compulsory - dbpath should be valid Amibroker database path. For how to create database, please check here : https://www.amibroker.com/guide/w_dbsettings.html

        Code Example
            $obj = Amibroker::OLE::Interface->new( verbose => 1, dbpath => "C:/amibroker/dbpath");

start_amibroker_engine()

Starts the Amibroker Engine and Loads the database

Code Example

    $obj->start_amibroker_engine();

run_analysis()

You can run various analysis based on the action supplied. But before that you need to pass APX file,

APX file is an important file to Amibroker engine. It is like the rule book to the amibroker. The analysis project file (.apx extension) is human-readable self-explanatory XML-format file that can be written/edited/modified from any language / any text editor. APX file includes all settings and formula needed in single file that is required to run analysis. APX file instructs what the amibroker engine has to do.

NOTE: Be very careful in creating the apx file.

You can either manually create the apx file or by automatically by a script. There should be no errors in the content of APX file, else the analysis of the Amibroker fails.

How to create apx file manually:

  • Open Amibroker -> Analysis window -> Settings

  • Edit settings as per your requirement

  • Menu-> File-> Save_AS -> select (.apx extenstion)

    For more infor on apx file, check this forum : http://amibrokerforum.proboards.com/thread/57/analysis-project-files-apx

        $obj->run_analysis( action => 2 ) method allows to run asynchronously scan/explorations/backtest/optimizations.
        Action parameter can be one of the following values:
        0 : Scan
        1 : Exploration
        2 : Portfolio Backtest
        3 : Individual Backtest
        4 : Portfolio Optimization 
        5 : Individual Optimization (supported starting from v5.69)
        6 : Walk Forward Test

    Symbol would be appended with '-I' => for current month contract future or '-II' for next month contract future Eg: for Nifty, Symbol would be 'Nifty-I'. This is just an example, you should check your database for the exact symbol name. If the Symbol passed to this function is not present in your amibroker database, then the analysis is bound to fail.

    result_file is the path where you want to dump the result of the Amibroker analysis. result_file file should NOT be created manually, it will be created automatically by the Amibroker engine when the analysis runs. You have to just pass the filename with the path.

parameters to run_analysis method
  • action is compulsory

  • symbol is compulsory

  • apx_file is compulsory

  • result_file is Optional - Default will be stored in C:/result.csv

    Code Example

        $obj->run_analysis( { action => 2, 
                                                      symbol => 'NIFTY-I', 
                              apx_file => "C:/amibroker/apx/path/nifty.apx", 
                              result_file => "C:/amibroker/result/path/report.csv" 
                                               } ); 

shutdown_amibroker_engine()

Shuts down Amibroker engine.

Code Example

        $obj->shutdown_amibroker_engine();

AUTHOR

Babu Prasad HP, <bprasad at cpan.org>

BUGS

Please report any bugs or feature requests to bug-amibroker-ole-interface at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Amibroker-OLE-Interface. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Amibroker::OLE::Interface

You can also look for information at:

ACKNOWLEDGEMENTS

I would like to thank Mr.Pannag M for supporting me in writing this module.

LICENSE AND COPYRIGHT

Copyright 2015 Babu Prasad HP.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.