首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用python读取Amibroker价格交易量数据

使用python读取Amibroker价格交易量数据
EN

Stack Overflow用户
提问于 2016-03-31 12:53:16
回答 3查看 5.6K关注 0票数 7

我想阅读使用python的Amibroker股票符号的价格交易量数据。我找不到任何有用的谷歌做这件事。有人能帮忙吗?

EN

回答 3

Stack Overflow用户

发布于 2016-04-04 08:22:31

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

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

下一个选项是直接与AB对象交互,参见指南。我不知道用Python怎么能做到这一点。

下面是COM对象指南,引号如下:

类表示一条价格数据。

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

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

Equivalent code of CreateObject in C#

塞特莫

票数 1
EN

Stack Overflow用户

发布于 2017-10-18 04:05:50

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

代码语言:javascript
复制
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" ); ​

票数 1
EN

Stack Overflow用户

发布于 2022-02-17 08:55:11

代码语言:javascript
复制
//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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36334084

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档