The resource loading... loading...

One of the newcomers to the K-line collection on the hard disk

Author: lengfeng, Created: 2015-07-21 13:15:05, Updated: 2019-08-01 11:01:03

Hello, I'm Coldwind, welcome to inventor quantification, starting today, I'm starting a series of introductory articles to help you get started quickly and write your own strategies.

The style of the article is minimalist, and I try to make each small article solve a small problem and accompany a complete, workable example.

If you have any questions, you can also contact me, I will try to help you solve some of your problems, because also at work, the time is very tight, you can not answer in time, and I will also help you to solve some of your problems.

Please forgive me.

I'm going to give you a simple example to show you that some trading platforms provide K-string data, for example tokens.

okcoin, for such a platform, can be directly accessed, whereas most trading platforms, do not provide K-line data, in which case the K-line must be collected themselves.

Note: In a test environment, it is not necessary to collect K strings because, the inventor quantifies the history of K strings provided for the test, why the inventor quantifies the history of K strings, not allowing the user to trade when on the real disk

This is mainly due to the fact that the inventor quantified the K-string itself, which may vary slightly in quantity and accuracy, so it is not available to the user when operating on a real disk.

Note that exchange.GetRecords ((); the maximum number of K-strings collected is 1411, and after 1441 lines, the first one is deleted to avoid affecting performance.

img

function onTick(exchange) {

var records = exchange.GetRecords();//搜集K线,最多可以搜集1411条

if (!records) {
    return;
}

Log("当前搜集到的K(分钟)线数量",records.length);

}

function main() {

Log(exchange.GetName(), exchange.GetCurrency());

while (true) {//循环执行
    onTick(exchange);
    Sleep(10000);
}

}


More

Selling outHello, I'm Coolwind, welcome to BOTVS, starting today, I'm starting a series of new entry articles to help you get started quickly and write your own strategies. I'm looking forward to this, but it seems that there is no or very little!!!

feng_yqThere are a few questions I would like to ask. 1. I found in the reticle environment with this code that the K-line historical data collected and the reticle log graphs are different, the K-line data is basically the same in both OPEN/HIGH/LOW/CLOSE and the change is significantly smaller than the log graph. I just added a line of code at the end of onTick to the last of the print records. Reviewed time selection 2015-08-10 17:10:24 to 2015-08-10 20:10:24,5 minutes K line, token BTC, actually select other time frames also have the same problem. Please see 3 K lines starting at 17:55 and printed as follows: This is the first time I've ever seen a movie with a female lead. This is a list of all the different ways Open: High: High: Low: Low is credited in the database. This is a list of all the different ways Time (1439201100000, Open (1643.88, High (1643.884816), Low (1643.88, Close (1643.884816, Volume: 702.867), is credited in the database. 2, the owner here wants to point out that in a real disk environment (whether it is a token that provides K-line history or not) we rely on our own robots to collect K-line data, and the robots will cache at most 1411 K-lines, right?

ZeroI'm sorry to see so late.. if the transaction all provides API to get the K-line, the custodian will not collect the K-line themselves under the real disk, directly get the K-line provided by the exchange, if the exchange does not provide it to collect itself, only save the most recent 1411 items, the tick-level data is simulated, different from the real one.