Open Order Binance PowerShell API

In this article, we will see how to get an open order to complete this series. As a result, we get the orderId of all open trades. This allows us, for example, to check an open trade with New-Order or to cancel the one with the Set-Order function in Binance using the API and PowerShell.

If you already have read the previous article, you’ll notice that there is nothing new under the sun. You should be able now to handle all the news functions you would need for your project. Again, this example Get-OpenOrder corresponds to my needs, you can modify it according to yours.

function Get-OpenOrders{
    <#
		.SYNOPSIS
		Return the open orders

        .PARAMETER Symbol
        Indicate the pair of which you wish to obtain the open order

        .EXAMPLE
        Get-OpenOrders

        .EXAMPLE
        $OpenOrders = Get-OpenOrders -Symbol BTCUSDT      
	#>

    [cmdletbinding()]
    param(
        [Parameter(Mandatory=$false)] 
        [string]$Symbol
    )

    BEGIN{
        # Check prerequisit
        try{
            Get-Command -Name Get-UnixTimeStamp -ErrorAction Stop | out-null
            Get-Command -name Get-BinanceAPISignature -ErrorAction Stop | Out-Null
            Get-Command -Name Get-BinanceAPIHeader -ErrorAction Stop | Out-Null
            Get-Command -Name Request-API -ErrorAction Stop | Out-Null
        }
        catch{
            Write-Host "Load Get-UnixTimeStamp, Get-BinanceAPISignature, Get-BinanceAPIHeader, Request-API  first prior to laod the current script" -b red
            Break
        }

        $TimeStamp = Get-UnixTimeStamp

        if($PSBoundParameters.ContainsKey('Symbol')){
            $QueryString = "symbol=$Symbol&timestamp=$TimeStamp&recvWindow=5000" 
        }
        else{
            $QueryString = "timestamp=$TimeStamp&recvWindow=5000"
        }  
    }
    
    PROCESS{
        $URI = Get-BinanceAPISignature -QueryString $QueryString -EndPoint "/api/v3/openOrders"
        $Headers = Get-BinanceAPIHeader
        $ObjResults = $null

        $ObjResults = Request-API -Method Get -URI $URI -Headers $Headers
    }

    END{
       return $ObjResults
    }
}

About this function

Examples

Open Order Binance PowerShell API Example 1
Open Order Binance PowerShell API example 2

Serie of post blog Crypto Binance API PowerShell

  1. Retrieve prices from Binance API PowerShell
  2. Get trading info from Binance API PowerShell
  3. Interact with Binance using API PowerShell
  4. New-Order API Binance PowerShell
  5. Retrieve Binance Balance API PowerShell
  6. Open Order Binance PowerShell API

4 thoughts on “Open Order Binance PowerShell API”

Leave a Comment