I am using node-binance-api the follwoing function bring me all details of my last order:
binance.trades(“BNBUSD”, (error, trades, symbol) => {
console.info(symbol+" last order:", trades);
}, {limit:1});
How can extract only a the price and sign it up for a variable?
I get the following details:
{
symbol: ‘BNBUSD’,
id: -------,
orderId:-----------,
orderListId: -1,
price: ‘-----------’,
qty: ‘---------’,
quoteQty: ‘------’,
commission: ‘0.00105000’,
commissionAsset: ‘BNB’,
time: ----------,
isBuyer: true,
isMaker: false,
isBestMatch: true
}
]
Looks like you're getting an array of trades, which means there'll be multiple prices.
If you need a collection of prices of all trades, you could assign those prices to a prices
variable like so:
binance.trades("BNBUSD", (error, trades, symbol) => {
let prices = trades.map(trade => trade.price);
// ... do something with `prices` here...
}, {limit:1});
At that point, prices
will be an array of numbers (something like [1, 2.5, 0.7, 3, ...]
depending on what the prices are).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.