2.3 List of market prices

Author: The Little Dream, Created: 2016-11-08 11:05:52, Updated: 2019-08-01 09:26:02

List of market prices


Both retesting and real-time testing choose OKCoin spot exchanges

  • Buy (()) List of market prices Re-test

    See the API documentation
Buy(Price, Amount)	下买单, Price为买单价格,Amount为数量, 返回一个订单ID
可以跟多余的参数做为附加消息显示到日志, 如exchange.Buy(1000,0.1, "OK", 123)
支持现货(火币/BitVC/OKCoin/OKCoin国际/OKCoin期货/BTCChina/BitYes)市价单, 市价单价格指定为-1
exchange.Buy(1000), 指买市价1000元的币, BTCChina例外exchange.Buy(0.3)指市价买0.3个币

Here is the source code of the test:

function main() { 
    var ticker = null;    // 用于获取ticker 行情。
    Log("initAccount:", exchange.GetAccount());   // 获取初始账户信息。
    Log("ticker:", ticker = exchange.GetTicker());  // 获取并打印行情
    Log("3000元 预计买到 Amount:", 3000 / ticker.Last);   // 计算下 Amount 传入 3000 预计按照当前的行情可以买入的数量。
    exchange.Buy(-1, 3000);           // 使用市价单, 在参数 Price 传入 -1 , 第二个参数 Amount 回测系统中为 法币。
    Log("nowAccount:", exchange.GetAccount()); // 显示当前账户信息,用于对比 实际买入的数量。
}

Here are the results:imgNote: The Amount parameter entered during the retest is the currency.

  • Buy (()) List of market prices Real-time testing

    imgYou can see that the inventor quantified that the analogue disk does not support the market price list.
function main() { 
    var ticker = null;
    Log("OKCoin 允许的BTC最小交易量:", 0.01); //  显示一下 OKCoin 允许的最小交易量
    // GetMinStock 函数已经废除, 需要使用一个 变量代替 最小交易币数(或者设置成 界面参数)
    Log("initAccount:", exchange.GetAccount());  
    Log("ticker:", ticker = exchange.GetTicker());
    
    exchange.Buy(-1, 200);  
    Log("nowAccount:", exchange.GetAccount());
}

img

You can see the Amount is transferred to 200 because there is not enough fiat currency balance in the account. So the Amount parameter is the number of transactions?

exchange.Buy(-1, 0.5); // 这句的 第二个参数 原来是200 改为 0.5 img

As you can see, the 0.5 is not 0.5 but 0.5 (RMB) so the above error will be displayed.

  • Sell (()) List of market prices Re-tested

    This time, sell and buy are a little different.
  function main() { 
    var ticker = null;
    Log("OKCoin 允许的BTC最小交易量:", 0.01);
    // GetMinStock 函数已经废除, 需要使用一个 变量代替 最小交易币数(或者设置成 界面参数)
    Log("initAccount:", exchange.GetAccount());
    Log("ticker:", ticker = exchange.GetTicker());
    
    exchange.Sell(-1, 0.5);   //  注意这里 传入Amount 的值  0.5
    Log("nowAccount:", exchange.GetAccount());
}

The results of the tests:imgIt can be seen that when using the Sell below market price list, the parameter for the Amount input is the amount to be traded (the number of BTC coins) rather than the amount of the tokens, which is different from calling Buy.

  • Sell (()) List of market prices Real-time testing

    This time I rushed in to test some money.
function main() { 
    var ticker = null;
    Log("OKCoin 允许的BTC最小交易量:", 0.01);
    Log("initAccount:", exchange.GetAccount());
    // GetMinStock 函数已经废除, 需要使用一个 变量代替 最小交易币数(或者设置成 界面参数)
    Log("ticker:", ticker = exchange.GetTicker());
    
    exchange.Sell(-1, 0.011);    // 我实盘 冲进去了一点钱,  看看效果。
    Sleep(5000);
    Log("nowAccount:", exchange.GetAccount());
}

The results:imgYou can see that the second parameter of Sell is Amount, which is the number of coins to be traded.


More

wlIt's as if the futures are not supporting the list price.

maroonstarHow do you get the minimum trading volume after GetMinStock is discontinued?

BlackGetMinStock should have been discarded, or it would have been better to remove the function from the example.

FangBeiPython version This is a list of all the different ways Dn-filebox.qbox.me/9c60297441da0ff8ae0d59aa204ce3ff512a2e49.png is credited in the database. This is a list of all the different ways Def30c890172a44d526ea55c7f38e32507f000c6.png is credited in the database.

The Little DreamIn the retesting system, futures are not supported for the time being.

The Little DreamThanks for the suggestion ^^