The resource loading... loading...

实际交易数量与exchange.Buy设置的数量不符。

Author: mlnotes, Created: 2018-03-05 18:18:47, Updated: 2018-03-05 18:19:29

下面是我用的测试大吗,非常简单,每个小时以市价购入10个ETH,初试价格是10000,但是在模拟回测的时候发现每次都显示交易成功,但是交易的量都不是10.

function onTick() {
    var id = exchange.Buy(-1, 10);
    Log("Order Id:", id);
    Log(exchange.GetOrder(id));
    Log(exchange.GetTrades());
    Log(exchange.GetAccount());
}

function main() {
    Log(exchange.GetAccount());
    while (true) {
        onTick();
        Sleep(3600 * 1000);
    }
}

Log of one of the transactions

2018-03-05 06:00:25		信息	{"Balance":9699.61809,"Stocks":0.33250049999999987,"FrozenBalance":0,"FrozenStocks":0}
2018-03-05 06:00:24		信息	[{"Id":31,"Time":1520200824800,"Price":900,"Amount":1,"Type":1}]
2018-03-05 06:00:24		信息	{"Id":31,"Price":-1,"Amount":10,"DealAmount":10,"Type":0,"Status":1,"AvgPrice":900.01}
2018-03-05 06:00:24		信息	Order Id: 31
2018-03-05 06:00:24	OKCoin_EN	买入	市价	10

Do you know what the reason is?


More

dyhhuIf I have 100 yuan in my pocket and I need to buy it quickly, you let me calculate how many yuan I can buy in a temporary way, I really don't have time.

mlnotesGreat, you're right! But I think it's easy to get confused, if you set the price, the second parameter is the amount of ETH, if the market price, the second parameter is the dollar, the API is poorly designed.

Inventors quantify - small dreamsHere, the 10 entered in the market price list does not refer to 10 ETH coins, but to 10 dollars, and you put this var id = exchange.Buy ((-1, 10); the number 10 is changed to 900. Try to see if after buying the Stocks will be closer to 1 ETH.

Inventors quantify - small dreamsThe API interface for OKEX is designed so that if the market price is purchased, it does not receive the order quantity, as long as the order price (i.e. the amount represented by the currency, depending on the amount purchased, it is not known how much the transaction coin is), sell only the order quantity (number of transaction coins) and do not ask for the price.