Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

allypi

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allypi - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

8

dist/index.js
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"UL96":[function(require,module,exports) {
"use strict";var e,t,r,o;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecurityType=exports.MarketSide=exports.TimeInForce=exports.OrderType=void 0,function(e){e[e.Market=1]="Market",e[e.Limit=2]="Limit",e[e.Stop=3]="Stop",e[e.StopLimit=4]="StopLimit"}(e=exports.OrderType||(exports.OrderType={})),function(e){e[e.Day=0]="Day",e[e.GTC=1]="GTC",e[e.MarketOnClose=7]="MarketOnClose"}(t=exports.TimeInForce||(exports.TimeInForce={})),function(e){e[e.Buy=1]="Buy",e[e.Sell=2]="Sell",e[e.SellShort=5]="SellShort"}(r=exports.MarketSide||(exports.MarketSide={})),function(e){e.CommonStock="CS",e.Option="OPT"}(o=exports.SecurityType||(exports.SecurityType={}));
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SecurityType=exports.MarketSide=exports.TimeInForce=exports.OrderType=exports.parseQuote=void 0;var e,t,o,r,a=function(e){return{symbol:e.symbol,open:parseFloat(e.opn),high:parseFloat(e.hi),low:parseFloat(e.lo),prevClose:parseFloat(e.cl),last:parseFloat(e.last),bid:parseFloat(e.bid),bidSize:parseInt(e.bidsz),ask:parseFloat(e.ask),askSize:parseInt(e.asksz),volume:parseInt(e.vl),change:parseFloat(e.chg),percentChange:parseFloat(e.pchg)/100,high52Week:parseFloat(e.wk52hi),high52WeekDate:new Date(e.wk52hidate.slice(4,6)+"-"+e.wk52hidate.slice(6)+"-"+e.wk52hidate.slice(0,4)),low52Week:parseFloat(e.wk52lo),low52WeekDate:new Date(e.wk52lodate.slice(0,4)+"-"+e.wk52lodate.slice(4,6)+"-"+e.wk52lodate.slice(6))}};exports.parseQuote=a,function(e){e[e.Market=1]="Market",e[e.Limit=2]="Limit",e[e.Stop=3]="Stop",e[e.StopLimit=4]="StopLimit"}(e=exports.OrderType||(exports.OrderType={})),function(e){e[e.Day=0]="Day",e[e.GTC=1]="GTC",e[e.MarketOnClose=7]="MarketOnClose"}(t=exports.TimeInForce||(exports.TimeInForce={})),function(e){e[e.Buy=1]="Buy",e[e.Sell=2]="Sell"}(o=exports.MarketSide||(exports.MarketSide={})),function(e){e.CommonStock="CS"}(r=exports.SecurityType||(exports.SecurityType={}));
},{}],"dxth":[function(require,module,exports) {
"use strict";var r=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildOrder=void 0;var t=r(require("xml")),e=require("./types"),o=function(r,o,i,d,a,u,c){void 0===a&&(a=e.OrderType.Market),void 0===u&&(u=e.TimeInForce.GTC);var n=[{_attr:{TmInForce:u,Typ:a,Side:o,Acct:r}},{Instrmt:{_attr:{SecTyp:e.SecurityType.CommonStock,Sym:d}}},{OrdQty:{_attr:{Qty:i}}}];void 0!==c&&(n[0]._attr.Px=c);var l=[{FIXML:[{_attr:{xmlns:"http://www.fixprotocol.org/FIXML-5-0-SP2"}},{Order:n}]}];return t.default(l,{declaration:!0})};exports.buildOrder=o;
"use strict";var t=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildOrder=void 0;var r=t(require("xml")),e=require("./types"),o=function(t,o,i,d,a,u,c,n){void 0===a&&(a=e.OrderType.Market),void 0===u&&(u=e.TimeInForce.GTC);var p=[{_attr:{TmInForce:u,Typ:a,Side:o,Acct:t}},{Instrmt:{_attr:{SecTyp:e.SecurityType.CommonStock,Sym:d}}},{OrdQty:{_attr:{Qty:i}}}];void 0!==c&&(p[0]._attr.Px=c),void 0!==n&&(p[0]._attr.StopPx=n);var l=[{FIXML:[{_attr:{xmlns:"http://www.fixprotocol.org/FIXML-5-0-SP2"}},{Order:p}]}];return r.default(l,{declaration:!0})};exports.buildOrder=o;
},{"./types":"UL96"}],"VfBm":[function(require,module,exports) {
"use strict";var t=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,s){function i(t){try{u(r.next(t))}catch(e){s(e)}}function a(t){try{u(r.throw(t))}catch(e){s(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,a)}u((r=r.apply(t,e||[])).next())})},e=this&&this.__generator||function(t,e){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(a){s=[6,a],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});var r=n(require("dotenv")),o=require("querystring"),s=require("oauth"),i=require("./FIXML");r.default.config();var a=function(){function n(t,e,n,r,o){void 0===t&&(t=process.env.CONSUMER_KEY),void 0===e&&(e=process.env.CONSUMER_SECRET),void 0===n&&(n=process.env.OAUTH_TOKEN),void 0===r&&(r=process.env.OAUTH_TOKEN_SECRET),void 0===o&&(o="https://devapi.invest.ally.com/v1"),this.oauthToken=n,this.oauthTokenSecret=r,this.baseURL=o,this.client=new s.OAuth("https://devapi.invest.ally.com/oauth/request_token","https://devapi.invest.ally.com/oauth/access_token",t,e,"1.0",null,"HMAC-SHA1",void 0,{TKI_OVERRIDE:"true"})}return n.prototype.get=function(n,r){return void 0===r&&(r={}),t(this,void 0,Promise,function(){var t=this;return e(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e,s){t.client.get(t.baseURL+"/"+n+".json?"+o.stringify(r),t.oauthToken,t.oauthTokenSecret,function(t,n,r){null!==t&&(console.error(t.statusCode,JSON.parse(t.data)),s(t.statusCode)),e(JSON.parse(n))})})];case 1:return[2,e.sent()]}})})},n.prototype.post=function(n,r){return t(this,void 0,Promise,function(){var t=this;return e(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e,o){t.client.post(t.baseURL+"/"+n+".json",t.oauthToken,t.oauthTokenSecret,r,"application/xml",function(t,n){null!==t&&(console.error(t.statusCode,JSON.parse(t.data)),o(t.statusCode)),e(JSON.parse(n))})})];case 1:return[2,e.sent()]}})})},n.prototype.getAccountID=function(){return t(this,void 0,Promise,function(){var t;return e(this,function(e){switch(e.label){case 0:return void 0!==this.accountID?[2,this.accountID]:[4,this.summary()];case 1:return t=e.sent().account,this.accountID=t,[2,t]}})})},n.prototype.totalValue=function(){return t(this,void 0,Promise,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,this.get("accounts/balances")];case 1:return t=e.sent().response,[2,parseFloat(t.totalbalance.accountvalue)]}})})},n.prototype.totalSecurities=function(){return t(this,void 0,Promise,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,this.summary()];case 1:return t=e.sent().accountholdings,[2,parseFloat(t.totalSecurities)]}})})},n.prototype.holdings=function(){return t(this,void 0,Promise,function(){return e(this,function(t){switch(t.label){case 0:return[4,this.summary()];case 1:return[2,t.sent().accountholdings.holding.map(function(t){return{symbol:t.displaydata.symbol,shares:parseInt(t.displaydata.qty),cost:parseFloat(t.purchaseprice),price:parseFloat(t.price),costBasis:parseFloat(t.costbasis),marketValue:parseFloat(t.marketvalue),gainLoss:parseFloat(t.gainloss)}})]}})})},n.prototype.placeOrder=function(n){return t(this,void 0,Promise,function(){var t,r;return e(this,function(e){switch(e.label){case 0:return[4,this.getAccountID()];case 1:return t=e.sent(),r=i.buildOrder(t,n.action,n.quantity,n.ticker,n.type,n.timeInForce,n.price),[4,this.post("accounts/"+t+"/orders",r)];case 2:return[2,e.sent()]}})})},n.prototype.previewOrder=function(n){return t(this,void 0,Promise,function(){var t,r;return e(this,function(e){switch(e.label){case 0:return[4,this.getAccountID()];case 1:return t=e.sent(),r=i.buildOrder(t,n.action,n.quantity,n.ticker,n.type,n.timeInForce,n.price),[4,this.post("accounts/"+t+"/orders/preview",r)];case 2:return[2,e.sent()]}})})},n.prototype.summary=function(){return t(this,void 0,Promise,function(){return e(this,function(t){switch(t.label){case 0:return[4,this.get("accounts")];case 1:return[2,t.sent().response.accounts.accountsummary]}})})},n}();exports.default=a;
},{"./FIXML":"dxth"}],"QCba":[function(require,module,exports) {
"use strict";var t=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,s){function i(t){try{a(r.next(t))}catch(e){s(e)}}function u(t){try{a(r.throw(t))}catch(e){s(e)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,u)}a((r=r.apply(t,e||[])).next())})},e=this&&this.__generator||function(t,e){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=e.call(t,i)}catch(u){s=[6,u],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});var r=n(require("dotenv")),o=require("querystring"),s=require("oauth"),i=require("./types"),u=require("./FIXML");r.default.config();var a=function(){function n(t,e,n,r,o){void 0===t&&(t=process.env.CONSUMER_KEY),void 0===e&&(e=process.env.CONSUMER_SECRET),void 0===n&&(n=process.env.OAUTH_TOKEN),void 0===r&&(r=process.env.OAUTH_TOKEN_SECRET),void 0===o&&(o="https://devapi.invest.ally.com/v1"),this.oauthToken=n,this.oauthTokenSecret=r,this.baseURL=o,this.client=new s.OAuth("https://devapi.invest.ally.com/oauth/request_token","https://devapi.invest.ally.com/oauth/access_token",t,e,"1.0",null,"HMAC-SHA1",void 0,{TKI_OVERRIDE:"true"})}return n.prototype.get=function(n,r){return void 0===r&&(r={}),t(this,void 0,Promise,function(){var t=this;return e(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e,s){t.client.get(t.baseURL+"/"+n+".json?"+o.stringify(r),t.oauthToken,t.oauthTokenSecret,function(t,n,r){null!==t&&(console.error(t.statusCode,JSON.parse(t.data)),s(t.statusCode)),e(JSON.parse(n))})})];case 1:return[2,e.sent()]}})})},n.prototype.post=function(n,r){return t(this,void 0,Promise,function(){var t=this;return e(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e,o){t.client.post(t.baseURL+"/"+n+".json",t.oauthToken,t.oauthTokenSecret,r,"application/xml",function(t,n){null!==t&&(console.error(t.statusCode,JSON.parse(t.data)),o(t.statusCode)),e(JSON.parse(n))})})];case 1:return[2,e.sent()]}})})},n.prototype.getAccountID=function(){return t(this,void 0,Promise,function(){var t;return e(this,function(e){switch(e.label){case 0:return void 0!==this.accountID?[2,this.accountID]:[4,this.summary()];case 1:return t=e.sent().account,this.accountID=t,[2,t]}})})},n.prototype.quote=function(n){return t(this,void 0,Promise,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,this.get("market/ext/quotes",{symbols:n})];case 1:return t=e.sent().response,[2,i.parseQuote(t.quotes.quote)]}})})},n.prototype.quotes=function(n){return t(this,void 0,Promise,function(){var t,r;return e(this,function(e){switch(e.label){case 0:return[4,this.get("market/ext/quotes",{symbols:n.join(",")})];case 1:return t=e.sent().response,r=t.quotes.quote,[2,(void 0!==r.length?r:[r]).map(i.parseQuote)]}})})},n.prototype.totalValue=function(){return t(this,void 0,Promise,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,this.get("accounts/balances")];case 1:return t=e.sent().response,[2,parseFloat(t.totalbalance.accountvalue)]}})})},n.prototype.totalSecurities=function(){return t(this,void 0,Promise,function(){var t;return e(this,function(e){switch(e.label){case 0:return[4,this.summary()];case 1:return t=e.sent().accountholdings,[2,parseFloat(t.totalsecurities)]}})})},n.prototype.holdings=function(){return t(this,void 0,Promise,function(){return e(this,function(t){switch(t.label){case 0:return[4,this.summary()];case 1:return[2,t.sent().accountholdings.holding.map(function(t){return{symbol:t.displaydata.symbol,shares:parseInt(t.displaydata.qty),cost:parseFloat(t.purchaseprice),price:parseFloat(t.price),costBasis:parseFloat(t.costbasis),marketValue:parseFloat(t.marketvalue),gainLoss:parseFloat(t.gainloss)}})]}})})},n.prototype.placeOrder=function(n){return t(this,void 0,Promise,function(){var t,r;return e(this,function(e){switch(e.label){case 0:return[4,this.getAccountID()];case 1:return t=e.sent(),r=u.buildOrder(t,n.action,n.quantity,n.ticker,n.type,n.timeInForce,n.price,n.stopPrice),[4,this.post("accounts/"+t+"/orders",r)];case 2:return[2,e.sent()]}})})},n.prototype.previewOrder=function(n){return t(this,void 0,Promise,function(){var t,r;return e(this,function(e){switch(e.label){case 0:return[4,this.getAccountID()];case 1:return t=e.sent(),r=u.buildOrder(t,n.action,n.quantity,n.ticker,n.type,n.timeInForce,n.price,n.stopPrice),[4,this.post("accounts/"+t+"/orders/preview",r)];case 2:return[2,e.sent()]}})})},n.prototype.summary=function(){return t(this,void 0,Promise,function(){return e(this,function(t){switch(t.label){case 0:return[4,this.get("accounts")];case 1:return[2,t.sent().response.accounts.accountsummary]}})})},n}();exports.default=a;
},{"./types":"UL96","./FIXML":"dxth"}],"QCba":[function(require,module,exports) {
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),t=this&&this.__exportStar||function(t,r){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(r,i)||e(r,t,i)},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Ally=void 0;var i=require("./Ally");Object.defineProperty(exports,"Ally",{enumerable:!0,get:function(){return r(i).default}}),t(require("./types"),exports);
},{"./Ally":"VfBm","./types":"UL96"}]},{},["QCba"], null)
//# sourceMappingURL=/index.js.map
{
"name": "allypi",
"version": "0.1.0",
"version": "0.2.0",
"description": "A Typescript/Node.js wrapper for the Ally Invest API",
"main": "dist/index.js",
"scripts": {
"lint": "ts-standard",
"fix": "ts-standard --fix",
"lint": "ts-standard --fix",
"test": "jest",

@@ -10,0 +9,0 @@ "build": "tsc --noEmit && parcel build src/index.ts -t node",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc