Skip to content

Commit 5010640

Browse files
committed
My trades for the margin account
1 parent 28e1162 commit 5010640

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,33 @@ For order operations, use `binance.mgCancel()`, `binance.mgCancelOrders()`, `bin
18951895
18961896
Usage and callbacks are the same as the 'regular account' counterparts.
18971897
1898+
#### Get your Trade History for the Margin account
1899+
Use `binance.mgTrades()` instead of `binance.trades()`.
1900+
1901+
```javascript
1902+
binance.mgTrades("ETHUSDT", (error, trades, symbol) => {
1903+
console.info(symbol+" trade history", trades);
1904+
});
1905+
```
1906+
<details>
1907+
<summary>View Response</summary>
1908+
1909+
```js
1910+
[ { symbol: 'ETHUSDT',
1911+
id: 9572,
1912+
orderId: 47884,
1913+
price: '2063.07',
1914+
qty: '1.44877',
1915+
commission: '2.98891392',
1916+
commissionAsset: 'USDT',
1917+
time: 1617900638521,
1918+
isBuyer: false,
1919+
isMaker: false,
1920+
isBestMatch: true,
1921+
isIsolated: true }]
1922+
```
1923+
</details>
1924+
18981925
#### Margin account details
18991926
```javascript
19001927
binance.mgAccount((error, response) => {

node-binance-api.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4581,6 +4581,35 @@ let api = function Binance( options = {} ) {
45814581
}, 'POST' );
45824582
},
45834583

4584+
/**
4585+
* Get trades for a given symbol - margin account
4586+
* @param {string} symbol - the symbol
4587+
* @param {function} callback - the callback function
4588+
* @param {object} options - additional options
4589+
* @return {promise or undefined} - omitting the callback returns a promise
4590+
*/
4591+
mgTrades: ( symbol, callback, options = {} ) => {
4592+
let parameters = Object.assign( { symbol: symbol }, options );
4593+
if ( !callback ) {
4594+
return new Promise( ( resolve, reject ) => {
4595+
callback = ( error, response ) => {
4596+
if ( error ) {
4597+
reject( error );
4598+
} else {
4599+
resolve( response );
4600+
}
4601+
}
4602+
signedRequest( sapi + 'v1/margin/myTrades', parameters, function ( error, data ) {
4603+
return callback.call( this, error, data, symbol );
4604+
} );
4605+
} )
4606+
} else {
4607+
signedRequest( sapi + 'v1/margin/myTrades', parameters, function ( error, data ) {
4608+
return callback.call( this, error, data, symbol );
4609+
} );
4610+
}
4611+
},
4612+
45844613
/**
45854614
* Transfer from main account to delivery account
45864615
* @param {string} asset - the asset

0 commit comments

Comments
 (0)