orderExecutor/handler.js
// say, 5% above the price we triggered on
say, 5% above the price we triggered on
say 5% above the price we triggered on
function executeGeminiBuy(account, isSandboxed) {
  var buyUpperBound = account.buyPrice * 1.05;
  var amountToBuy = account.accountBalanceUSD / account.buyPrice;
  var requestBody = {
    "request": "/v1/order/new",
    "nonce": new Date().getTime(),
    "client_order_id": account.id + '',
    "symbol": "btcusd",
    "amount": amountToBuy + '',
    "price": buyUpperBound + '',
    "side": "buy",
    "type": "exchange limit",
    "options": ["immediate-or-cancel"]
  };
  console.log('final form of request body: ' + JSON.stringify(requestBody, null, 4));
  var url = null;
  if (isSandboxed) {
    url = 'https://api.sandbox.gemini.com/v1/order/new';
    console.log('using sandbox URL: ' + url);
  } else {
    url = 'https://api.gemini.com/v1/order/new';
    console.log('using actual exchange URL: ' + url);
  }
  return makeAPICall(requestContentObject, account, url);
}
function executeGeminiBuy ( account , isSandboxed ) { var buyUpperBound = account . buyPrice * 1.05 ; var amountToBuy = account . accountBalanceUSD / account . buyPrice ; var requestBody = { "request" : "/v1/order/new" , "nonce" : new Date ( ) . getTime ( ) , "client_order_id" : account . id + '' , "symbol" : "btcusd" , "amount" : amountToBuy + '' , "price" : buyUpperBound + '' , "side" : "buy" , "type" : "exchange limit" , "options" : [ "immediate-or-cancel" ] } ; console . log ( 'final form of request body: ' + JSON . stringify ( requestBody , null , 4 ) ) ; var url = null ; if ( isSandboxed ) { url = 'https://api.sandbox.gemini.com/v1/order/new' ; console . log ( 'using sandbox URL: ' + url ) ; } else { url = 'https://api.gemini.com/v1/order/new' ; console . log ( 'using actual exchange URL: ' + url ) ; } return makeAPICall ( requestContentObject , account , url ) ; }
say, 5% above the price we triggered on
say 5% above the price we triggered on