The resource loading... loading...

2.3 List of market prices

Author: Inventors quantify - small dreams, 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 below the market price 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:2.3 下市价单 交易Note: The Amount parameter entered during the retest is the currency.

  • ### Buy ((() List of prices below the market2.3 下市价单 交易You 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());
}

2.3 下市价单 交易

You can see the Amount is transferred to 200 because the account has insufficient fiat currency balance. So the Amount parameter is the number of coins being traded.

  ![2.3 下市价单 交易](/upload/asset/773243ad0ca0a9e7995f8a64fe0e4077b8ef8ec1.png) 
  
  可以看到这里传入的 0.5 不是 0.5个币,而是 0.5法币(RMB金额),所以才会显示上面的报错。
  
- ### Sell( ) 下市价单 回测测试
  这次的Sell 和 Buy 有些不同

function main (() { The value of the variable is zero. Log (( OKCoin allows minimum amount of BTC to be traded: , 0.01); // GetMinStock has been deprecated, requiring a variable to replace the minimum transaction number (or set to the interface parameter) Log ((initAccount: , exchange.GetAccount)))); Log ((ticker: hey, ticker = exchange.GetTicker)));

exchange.Sell(-1, 0.5);   //  注意这里 传入Amount 的值  0.5
Log("nowAccount:", exchange.GetAccount());

}

  回测结果:
  ![2.3 下市价单 交易](/upload/asset/677f0ccaa98a25dabbacc88dc12d7e461b9568c9.png) 
  可以看出 在使用 Sell 下市价单的时候 传入Amount 的参数是 指的 要交易的量(BTC币数),而不是 法币金额,和 调用 Buy 不同。
  
- ### Sell( ) 下市价单 实盘测试
  这次实盘我冲进去了一点钱测试。

function main (() { The value of the variable is zero. Log (( OKCoin allows minimum amount of BTC to be traded: , 0.01); Log ((initAccount: , exchange.GetAccount)))); // GetMinStock has been deprecated, requiring a variable to replace the minimum transaction number (or set to the interface parameter) Log ((ticker: hey, ticker = exchange.GetTicker)));

exchange.Sell(-1, 0.011);    // 我实盘 冲进去了一点钱,  看看效果。
Sleep(5000);
Log("nowAccount:", exchange.GetAccount());

} “`

The results:2.3 下市价单 交易You 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.

Inventors quantify - small dreamsIn the retesting system, futures are not supported for the time being.

Inventors quantify - small dreamsThanks for the suggestion ^^