挂单类交易

获得某个账号的挂单

Node.JS Example

var Remote = require('jingtu-lib').Remote;
var remote = new Remote({server: 'ws://ts5.jingtum.com:5020', local_sign:true});
remote.connect(function (err, result) {
    if(err) return console.log('err: ', err);
    var options = {account: 'jB7r...Y2xLZ', limit: 10};
    var req = remote.requestAccountOffers(options);
    req.submit(function(err, result) {
        if(err) {return console.log('err:',err);}
        console.log('get account orders:', result);
    });
});

C# Example

var remote = new Remote(@"ws://ts5.jingtum.com:5020", true);
remote.Connec(result =>
{
  if (result.Exception != null)
  {
    Console.Write(result.Exception.Message);
  }
  else
  {
    var req = remote.RequestAccountOffers(new AccountOffersOptions
    {
      Account = "j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1"
    });
    req.Submit(reqResult =>
    {
      Console.Write(reqResult.Message);
      // get result from reqResult.Result
    });
  }
});

挂单

Node.JS Example

var Remote = require('jingtum-lib').Remote;
var remote = new Remote({server: 'ws://ts5.jingtum.com:5020', local_sign:true});
remote.connect(function (err, result) {
    if(err) return console.log('err: ', err);
    var options = {
        type: 'Sell',
        account: 'jB7r...2xLZ',
        taker_gets: {
            value: '0.01',
            currency: 'CNY',
            issuer: 'jBciDE8Q3uJjf111VeiUNM775AMKHEbBLS'
        },
        taker_pays: {
            value: '1',
            currency: 'SWT',
            issuer: ''
        }
    };
    var tx = remote.buildOfferCreateTx(options);
    tx.setSecret('sn37...jXUWd');
    tx.submit(function(err, result) {
        if(err) {return console.log('err:',err);}
        console.log('build order result:', result);
    });
});

C# Example

var remote = new Remote(@"ws://ts5.jingtum.com:5020", true);
remote.Connect(result =>
{
  if (result.Exception != null)
  {
    Console.Write(result.Exception.Message);
  }
  else
  {
    var tx = remote.BuildOfferCreateTx(new OfferCreateTxOptions
    {
      Account = "j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1",
      Type = OfferType.Sell,
      TakerGets = new Amount
      {
        Value = "0.01",
        Currency = "SWT",
        Issuer = ""
    },
    TakerPays = new Amount
    {
       Value = "1",
       Currency = "CNY",
       Issuer = "jBciDE8Q3uJjf111VeiUNM775AMKHEbBLS"
    }
  });
  tx.SetSecret("ssG......dNi");
  tx.Submit(txResult => {
    Console.Write(txResult.Message);
    //get result from txResult.Result
  });
 }
});

获得市场挂单

Node.JS Example

var Remote = require('jingtum-lib').Remote;
var remote = new Remote({server: 'ws://ts5.jingtum.com:5020', local_sign:true});
remote.connect(function (err, result) {
    if(err) return console.log('err: ', err);
    var options = {
        gets: { currency: 'SWT', issuer: '' },
        pays: { currency: 'CNY', issuer: 'jBciDE8Q3uJjf111VeiUNM775AMKHEbBLS'}};
    var req = remote.requestOrderBook(options);
    req.submit(function(err, result) {
        if(err) {return console.log('err:', err);}
        console.log('get market orders:', result);
    });
});

C# Example

var remote = new Remote(@"wss://ts5.jingtum.com:5020", true);
remote.Connect(result =>
{
  if (result.Exception != null)
  {
    Console.Write(result.Exception.Message);
  }
  else
  {
    var req = remote.RequestOrderBook(new OrderBookOptions
    {
      Gets = new Amount ("SWT", ""),
      Pays = new Amount ("CNY", "jBciDE8Q3uJjf111VeiUNM775AMKHEbBLS")
    });
    req.Submit(reqResult =>
    {
      Console.Write(reqResult.Message);
    });
  }
});

取消挂单

Node.JS Example

var Remote = require('jingtum-lib').Remote;
var remote = new Remote({server: 'ws://ts5.jingtum.com:5020', local_sign:true});
remote.connect(function (err, result) {
    if(err) return console.log('err: ', err);
    var options = {account: 'jB7r...Y2xLZ', sequence: 688};
    var tx = remote.buildOfferCancelTx(options);
    tx.setSecret('sn37...FjXUWd');
    tx.submit(function(err, result) {
        if(err) {return console.log('err:',err);}
        console.log('cancel order result:', result);
    });
});

C# Example

var remote = new Remote(@"ws://ts5.jingtum.com:5020", true);
remote.Connect(result =>
{
  if (result.Exception != null)
  {
    Console.Write(result.Exception.Message);
  }
  else
  {
    var tx = remote.BuildOfferCancelTx(new OfferCancelTxOptions
    {
      Account = "j9FGhAW9dSzL3RjbXkyW6Z6bHGxFk8cmB1",
      Sequence = 8
    });
    tx.SetSecret("ssG......dNi");
    rx.Submit(txResult => {
      Console.Write(rxResult.Message);
      //get result from txRresult.Result
    });
  }
});