使用 python 读取 Amibroker 价格量数据

Read Amibroker price volume data using python

我想使用 python 读取 Amibroker 股票代码的价格量数据。我在 google 上找不到任何有用的东西来做这件事。有人可以帮忙吗?

我不确定你的情况是什么,但你有几个选择。

最终,关于股票的所有存储信息都在 AB 数据库中,您可以从 AFL 访问该数据库。因此,要将值放入 Python,您可以创建一个文本文件,您的 Python 代码可以读取该文件。

您的下一个选择是直接与 AB COM 对象交互,请参阅指南。我不知道如何在 Python.

中做到这一点

这是 COM 对象指南,在引用下:

Quotation class represents one bar of price data

https://www.amibroker.com/guide/objects.html

下面的 link 是我发布的关于 AB COM 互操作的另一个答案的想法。

Equivalent code of CreateObject in C#

塞斯莫

Cool:就毫不犹豫的打开一盒美味的糖果

AmiBroker 与其他交易框架一样,可以提供数据,但它是一个紧凑的(约 3.5 MB .EXE + .DLLs)、性能优化的可执行文件,不像 Java 或 .NET 程序,需要任何内部 VM 在字节码级别解释用户进程,但 运行 在机器代码级别上全力以赴。

虽然 AB 为数据访问提供了多个集成选项,我的建议——在过去 12 年的定量研发中——将是:go分布式(忘记花时间只实现对某些数据元素( Volume )的特定访问,不要进一步依赖状态共享——而是开始使用智能进程间通信和智能代理间发信号python-询问,AmiBroker-临时回复等等。

Python 边 -- 免费 ( . . . 在 localhost 或另一个大陆 运行 )

根据扩展和 tools/modules 可用性,这被认为是非常简单和灵活的,这让我直接跳过这里,你先验地知道你在 python 方面需要什么并且大部分需求已经实现或者只是作为一些模块扩展添加。

AmiBroker 方面 -- 更难的部分

Tomasz Janeczko 写了很多关于 AB 集成的特定模式 - 基于 DLL 的模式。为什么? DLL-s 允许在系统到系统的通信架构中进行平滑和完全可控的集成。

(cit.:) "... translate ... to C/C++ language and compile as AFL plugin DLL. Doing so requires some C/C++ programming knowledge, a C/C++ compiler (free Visual Studio Express or GNU tools can be used) and AmiBroker Development Kit (ADK).

ADK contains instructions how to write your own AFL plugin along with code samples that are ready-to-compile. Some C/C++ knowledge is required though.

ADK is freely downloadable from
http://www.amibroker.com/bin/ADK.exe (self-extracing exe) or http://www.amibroker.com/bin/ADK.zip (zip archive)

NOTE: ADK is not for the beginners. It is for programmers (i.e. for people who already wrote some C/C++ code in their life)."

注意:

When plug-in DLL is written with AmiBroker Development Kit (ADK) it is usually compiled with Microsoft C runtime library. The “problem” is that depending on compiler used, different versions of C runtime are required for the DLL to be loaded by the operating system.

For example Visual C++ 6.0 links against MSVCRT.DLL that is commonly found in all Windows starting from Windows XP so you can “forget” about installing the runtime. But when plugin is compiled with more recent Visual C++ 2005, 2008 or 2010 then required C runtime library is almost never present on target ( client ) computer.

In order to load the plugin compiled with VC2005 or higher, one must install proper run-time library on the client computer. The runtime must exactly match the compiler version and eventual compiler service pack used to compile the DLL, otherwise operating system will not load the DLL. Appropriate runtimes (vcredist.exe) are in:

VCInstallDir\SDK\v2.0\Bootstrapper\Packgages\vcredist_x86 or
VCInstallDir\SDK\v2.0\Bootstrapper\Packgages\vcredist_x64

or similar directory (depending on VC version being used). Then such vcredist.exe must be shipped with the DLL to all clients for their installation.

Alternatively can compile DLL with a static runtime library.

There is a freeware tool called Dependency Walker (http://www.dependencywalker.com/) that allows to check what given DLL needs to be loaded by the operating system.

另外——您绝对需要确保您的插件使用“多线程 DLL”运行-time 库。好消息是,Visual C++ 编译器(2005 和 2010)不再允许选择单线程 运行time。

所以 -- 将您的 DLL 放入“Plugins”目录,如果它没有出现在数据源列表中,则意味着它的位数(32 位/64 位)与 AmiBroker 不匹配。

准备好使用 DLL 模式后,就可以为几乎所有类似的智能消息传递框架实现基于 DLL 的包装器 ZeroMQ, nanomsg et al 并实现了这一点,您的想象力是进一步与 [=13= 进行系统到系统通信的唯一限制].

  • python-询问,AmiBroker-回复
  • AmiBroker-询问,python-回复
  • AmiBroker-询问,remote-GPU-回复
  • AmiBroker-询问,remote-AI/ML-预测和发布交易设置/交易目标管理(适用于低延迟时间 -- 数十 [ms] -- 适用于甚至低强度的 HFT 策略),
  • AmiBroker-发布,remote-ComputingGrid-处理任何 [=126] =]-处理

你可以尝试将我修改的Amibroker示例javascript更改为Python。 javascript 会将 Amibroker 数据库转储到文件中。该脚本会让您了解如何访问 Amibroker 中的数据库。

function FormatFloat( number )
{
 number = 0.001 * Math.round( number * 1000 );
 str = number.toString();
 return str.substring( 0, str.indexOf(".") + 4 );
}

var oAB = new ActiveXObject("Broker.Application"); 
var fso = new ActiveXObject("Scripting.FileSystemObject"); 

/* Indicate the location and file name for the database dump. */
file = fso.OpenTextFile( "C:\Info.txt", 2, true ); 

/* Indicate the location and name of the database to dump. */
oAB.LoadDatabase("C:\Program Files (x86)\AmiBroker\Data");

var oStocks = oAB.Stocks; 
var Qty = oStocks.Count;

for( i = 0; i < Qty; i++ ) { /* Loop through all the stocks in the database. */
 oStock = oStocks(i);
 for (j = 0; j < oStocks(i).Quotations.Count; j++) { /* Loop through all the ohlcv in each stock. */
  oQuote = oStock.Quotations( j );
  var oDate = new Date( oQuote.Date );
  file.WriteLine( oStocks(i).Ticker + "," + 
   (oDate.getMonth()+1) + "/" + oDate.getDate() + "/" + oDate.getFullYear() + "," + 
   FormatFloat( oQuote.Open ) + "," + 
   FormatFloat( oQuote.High ) + "," +
   FormatFloat( oQuote.Low ) + "," +
   FormatFloat( oQuote.Close ) + "," + 
   Math.round( oQuote.Volume )  );
 }
} 
file.Close(); 
WScript.Echo("Export finished" ); ​

//Price Volume of the ticker (Formula: Close x Volume)

  Price_Volume = C*V

//Price Volume of specific ticker (eg. SPY) (Formula: Close x Volume)

  Price_Volume_SPY = foreign("SPY","C")*foreign("SPY","V")

//Yesterday Price Volume of specific ticker (eg. SPY) (Formula: Close x Volume)

  Yesterday_Price_Volume_SPY = Ref(foreign("SPY","C"),-1)*Ref(foreign("SPY","V"),-1)