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

@dreygur/td365

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dreygur/td365 - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

payloads.js

21

example.ts

@@ -13,3 +13,3 @@ import express from 'express';

};
const cookie = 'ASP.NET_SessionId=4essmxfsj4e05i4opfk2rcqf; PQMFIHXS=cSEoK5uZdaurA4xy6bYML/IMrXmEMB2h7+x5eNifebuu8PbCJxEONKbwgbqgRnFthoSXHuXg+Akk0fX6; PQMFIHXS_exp=2023-08-24T05:18:47.911Z; AWSALB=tEyYYkV7Gt5fBbugSRseRkm6I5tIO/bQ63i/LbqFUBe1UDxJW9EUxas0ODxiGXdS2SwJb0VvDJ9KqET5CJlgh+uNpDvEwrMwz+likjE7oQSlXKPUI1OC2W+rBuCs; AWSALBCORS=tEyYYkV7Gt5fBbugSRseRkm6I5tIO/bQ63i/LbqFUBe1UDxJW9EUxas0ODxiGXdS2SwJb0VvDJ9KqET5CJlgh+uNpDvEwrMwz+likjE7oQSlXKPUI1OC2W+rBuCs';
const cookie = 'EWTEMAJM=ecIEQ/Ow07aAundsJ762KRkNrMoc+MC/rRne6zTw06xQ/GN+WumhGVSJBfzExv9WVlZSm7PfO75EJskn; EWTEMAJM_exp=2023-08-23T10:32:19.542Z; ASP.NET_SessionId=tfoo0lgexvhpbumabjkosqcp; JRLJPMAN=/01aUOf/PeDBTdpbCfdeEXJqDdrCYei9HoHHvtJYDnpDgiEUsTjk4vEMvuXiVIq3xrOrwTOlgiBgpTfO; JRLJPMAN_exp=2023-08-29T05:15:50.429Z; AWSALB=8UdLX1ver2WY3GKmYDrlRDAyPJ6KPV1VY7oIRGaJLQ9WzCXHq+d21sDVUz9u4oE6L3387xaerGbBclKtfon8zCQTuZIEr4+v2+BmV+UAYIFihzo6E2zCSojBl5Le; AWSALBCORS=8UdLX1ver2WY3GKmYDrlRDAyPJ6KPV1VY7oIRGaJLQ9WzCXHq+d21sDVUz9u4oE6L3387xaerGbBclKtfon8zCQTuZIEr4+v2+BmV+UAYIFihzo6E2zCSojBl5Le';

@@ -44,2 +44,21 @@ const subscriptions: SubscriptionItem[] = [];

app.get('/trade', async (req, res) => {
const { side, amount, orderType, orderStake, limitStake } = req.query;
if (!allEvents[6374]) return res.status(200).send({ message: 'No events' });
try {
let response;
if (side === 'buy') response = await api.tradeExtra('buy', 'stop', Number(amount), 6374, allEvents, {}, Number(orderStake), Number(limitStake));
else response = await api.tradeExtra('sell', 'stop', Number(amount), 6374, allEvents, {}, Number(orderStake), Number(limitStake));
console.log(response);
return res.status(200).json(response);
} catch (err: any) {
console.log(err.message);
return res.status(500).send({ message: 'Error' });
}
});
app.get('/close', async (req, res) => {

@@ -46,0 +65,0 @@ const { positionID, amount, AccountID } = req.query;

@@ -17,2 +17,4 @@ import { AllEvents, TradeObj } from '../types';

allTrades: AllEvents, orderObj?: TradeObj): Promise<any>;
tradeExtra(tradeMode: "buy" | "sell" | undefined, orderType: "stop" | "trailing" | "limit" | "stopLimit" | undefined, stake: string | number | undefined, quoteID: string | number, // Item ID
allTrades: AllEvents, orderObj?: TradeObj, orderStake?: string | number, limitStake?: string | number): Promise<any>;
/**

@@ -19,0 +21,0 @@ * Exit Position

@@ -49,2 +49,6 @@ "use strict";

}
async tradeExtra(tradeMode = 'buy', orderType = 'stop', stake = 1, quoteID, // Item ID
allTrades, orderObj, orderStake, limitStake) {
return trade.tradeExtra(this._token, tradeMode, orderType, stake, quoteID, allTrades, orderObj, orderStake, limitStake);
}
/**

@@ -51,0 +55,0 @@ * Exit Position

@@ -36,3 +36,3 @@ import { AllEvents, TradeObj } from "../types";

export declare function amend(cookie: string, orderType: "stop" | "trailing" | "limit" | "stopLimit" | undefined, orderStake: string | number | undefined, quoteID: string | number, // Item ID
closePositionID: string | number, accountID: string | number, allTrades: AllEvents, limitStake?: number | string, orderObj?: TradeObj, orderID?: string | number): Promise<any>;
closePositionID: string | number, accountID: string | number, allTrades: AllEvents, limitStake?: number | string, orderObj?: TradeObj, stopTrailingStake?: number | string, orderID?: string | number): Promise<any>;
/**

@@ -49,1 +49,16 @@ *

allTrades: AllEvents, orderObj?: TradeObj): Promise<any>;
/**
* Ammend an order
* @param orderType Type of order
* @param orderStake Amount of stake
* @param quoteID Quote ID or Item ID
* @param closePositionID Postion ID to Close Order
* @param accountID Account ID
* @param allTrades Events state
* @param limitStake Amount of stake for limit
* @param orderObj Order object
* @param orderID Order ID
* @returns
*/
export declare function tradeExtra(cookie: string, tradeMode: "buy" | "sell" | undefined, orderType: "stop" | "trailing" | "limit" | "stopLimit" | undefined, stake: string | number | undefined, quoteID: string | number, // Item ID
allTrades: AllEvents, orderObj?: TradeObj, orderStake?: string | number, limitStake?: string | number): Promise<any>;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.trade = exports.amend = exports.closeOrder = exports.closePosition = void 0;
exports.tradeExtra = exports.trade = exports.amend = exports.closeOrder = exports.closePosition = void 0;
const request_1 = __importDefault(require("../utils/request"));

@@ -80,3 +80,3 @@ const utils_1 = require("./utils");

async function amend(cookie, orderType = 'stop', orderStake = 1, quoteID, // Item ID
closePositionID, accountID, allTrades, limitStake, orderObj, orderID) {
closePositionID, accountID, allTrades, limitStake, orderObj, stopTrailingStake, orderID) {
try {

@@ -105,3 +105,3 @@ const orderObject = {

: Number(price) - Number(orderStake),
stopOrderPrice: orderType === 'limit' ? 0 : Number(price) - Number(orderStake),
stopOrderPrice: orderType === 'limit' ? 0 : Number(price) - Number(stopTrailingStake),
trailingPoint: orderType == 'trailing' ? 1 : 0,

@@ -173,1 +173,60 @@ };

exports.trade = trade;
/**
* Ammend an order
* @param orderType Type of order
* @param orderStake Amount of stake
* @param quoteID Quote ID or Item ID
* @param closePositionID Postion ID to Close Order
* @param accountID Account ID
* @param allTrades Events state
* @param limitStake Amount of stake for limit
* @param orderObj Order object
* @param orderID Order ID
* @returns
*/
async function tradeExtra(cookie, tradeMode = 'buy', orderType = 'stop', stake = 1, quoteID, // Item ID
allTrades, orderObj, orderStake, limitStake) {
try {
const orderObject = {
orderModeID: {
limit: 1,
stop: 2,
trailing: 2,
stopLimit: 3
},
};
const [price, key] = [allTrades[quoteID][`${tradeMode}Price`], allTrades[quoteID].token];
if (orderType === 'stopLimit' && !limitStake)
throw new Error('limitStake is required for stopLimit');
const defaultOrderObj = {
key,
price,
stake,
quoteID,
closePositionID: 0,
hasClosingOrder: true,
isGuaranteed: false,
isKaazingFeed: true,
limitOrderPrice: ['stop', 'trailing'].includes(orderType)
? 0 : orderType === 'limit'
? Number(price) + Number(orderStake)
: orderType === 'stopLimit'
? Number(price) + Number(limitStake)
: Number(price) - Number(orderStake),
stopOrderPrice: orderType === 'limit' ? 0 : Number(price) - Number(orderStake),
marketID: 17068,
orderModeID: orderObject.orderModeID[orderType],
orderPriceModeID: 2,
orderTypeID: 2,
tradeMode: tradeMode.toLowerCase() === 'sell',
tradeType: 1,
trailingPoint: orderType == 'trailing' ? 1 : 0,
userAgent: "Chrome (115.0.0.0)"
};
return (0, request_1.default)('RequestTrade', cookie, Object.assign(defaultOrderObj, orderObj));
}
catch (err) {
throw err;
}
}
exports.tradeExtra = tradeExtra;

7

package.json
{
"name": "@dreygur/td365",
"version": "1.0.2",
"version": "1.0.3",
"description": "A wraper for tradedirect365.com",

@@ -17,3 +17,4 @@ "main": "lib/index.js",

"compile": "tsc",
"build": "esbuild --bundle src/index.ts --outdir=dist --platform=node --target=es2020"
"build": "esbuild --bundle src/index.ts --outdir=dist --platform=node --target=es2020",
"prepare": "tsc"
},

@@ -35,2 +36,2 @@ "devDependencies": {

}
}
}
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