The resource loading... loading...

Digital currency: the function of currency pairs

Author: Inventors quantify - small dreams, Created: 2017-06-12 13:03:56, Updated: 2017-10-11 10:23:17

  • Exchange currency pairs when running

All digital currency exchanges except for ETH (as ETH is a separate API address for tokens)货币对I'm not sure what to do. Please note: Update the most recent administrator protocols

  • Examples

  // 切换Bter交易对为LTC_BTC, 切换后所有交易函数都受影响
  exchange.IO("currency", "LTC_BTC");
  
  // 切换P网交易对为BTC_XRP, 切换后所有交易函数都受影响
  exchange.IO("currency", "BTC_XRP");
  
  // 切换 OKCoin 交易对为 LTC ,切换后所有交易函数都受影响
  exchange.IO("currency", "LTC");
  • We use the interactive functionality to test, and during the program run we switch the currency from BTC to LTC.

    Note: All transaction functions are affected after the switch

var preRecordTime = 0;
function main() {
    LogReset(1);
    while (true) {
        var records = exchange.GetRecords();

        // 交互
        var cmd = GetCommand(); // 调用API  获取界面交互控件的消息。 
        if (cmd) { // 判断是否有消息
            var js = cmd.split(':', 2)[1]; // 分割 返回的消息 字符串, 限制返回2个, 把索引为1的 元素 赋值给 名为js 的变量 
            Log("执行调试代码:", js); // 输出 执行的代码
            try { // 异常检测
                eval(js); // 执行 eval函数, 该函数执行传入的参数(代码)。
            } catch (e) { // 抛出异常
                Log("Exception", e); // 输出错误信息
            }
        }

        if (records && records.length > 2) {
            if(records[records.length - 1].Time !== preRecordTime){
                Log("币种:", exchange.GetCurrency(), "倒数第一bar:", records[records.length - 1], "倒数第二bar:", records[records.length - 2]);
                preRecordTime = records[records.length - 1].Time;
            }
        }
        LogStatus("时间:", _D(), "币种:", exchange.GetCurrency(), "records:", (records == null || (records && records.length == 0)) ? "--" : records[records.length - 1]);
        
        Sleep(500)
    }
}
  • The first step is to add an interactive control, like this:

    img

  • The new robot, running.

    img

  • Open the interactive controller, enter the codeexchange.IO("currency", "LTC");Call the function to switch the currency pair to LTC.

    img

  • Identify the executable code

    img

  • As you can see, the transaction data has changed to LTC.

    img


More

anysouIs the interactive controller not supporting Python?

zhangyijunIs there an API or documentation listing the pairs of transactions supported by each exchange?

High suction low throwThe collection

Inventors quantify - small dreamsSupport and usage are the same.

Inventors quantify - small dreamsCustom controls can be set to be used when creating a robot, as long as the exchange supports the transaction pair.