LogoLogo
Back to HaasOnline.comSwitch to Developer API
4.x
4.x
  • Welcome
  • TradeServer Cloud
    • Overview
    • Security
    • Troubleshooting
  • TradeServer Enterprise
    • Overview
    • Updates
    • Security
    • Installation
      • Windows
      • MacOS
      • Linux
    • Configuration
      • License Key
      • Login credentials
      • Hosting
        • Linux VPS Hosting
    • Special features
      • Price history
      • Backups
      • Machine Learning
        • Built-in Machine Learning
        • Custom Machine Learning
      • Scripted Exchange API (Coming Soon)
      • Local API (Coming Soon)
    • Troubleshooting
  • Interface
    • General Interface
      • Left Menu
      • Upper Right Items
        • Account data
        • Execute trade
        • AI Chatbots
          • Chatbot Julia
          • Chatbot David
          • Chatbot Thomas
        • Notifications
        • Menu
          • Exchange accounts
          • Settings
          • License information
          • Change Logs
          • Logout
      • Status bar
        • Price tickers
    • Dashboard
    • Bots
      • Bot management
      • Bot templates
    • HaasScript
      • Web Editor
      • Backtest Lab
        • Lab test setup
      • Backtest History
      • Manage Scripts
      • Manage Signals
    • Tools
      • Marketview
      • Market intelligence
      • Exchange profiler
      • Markets explorer
      • News
    • Finance
      • Portfolio
      • External Wallet
  • Haasscript
    • About
      • Change Log
    • Tutorials
      • Bot building
        • Trade-bot building
        • Visual bot building
        • Scripted bot building
      • Usage
        • HaasScript
          • Interval
          • Markets
          • Input Fields
          • Memory Management
          • Signal Handling
          • Position Information
          • Positions Handling
            • Fee correction
          • Order Handling
          • Trading
          • Charting
          • Optimizations
        • Visual Editor
          • Blocks
          • Parameters
          • Flow Control
          • Interaction
        • Script Editor
          • Classes
        • Managed Trading
        • Unmanaged Trading
    • Commands
      • Trade Bots
        • TradeBot Containers
        • Easy Indicators
        • Easy Safeties
        • Easy Insurances
      • Helpers
        • Array Helpers
        • Custom Command Helpers
        • Enumerations
        • Equations
        • Mathematical
        • Memory Helpers
        • Signal Helpers
        • String Helpers
        • Miscellaneous
        • Technical Analysis Helpers
      • Input data
        • Bot Settings
        • Input fields
        • Price Market Information
        • Script Settings
        • Time Information
        • Trade Market Information
      • Prices
      • Technical Analysis
      • Charting
      • Trading
        • Managed Trade Commands
        • Unmanaged Trade Commands
        • Order Information
        • Order Handeling
        • Position Information
        • Position Price Information
        • Profit Information
        • Wallet Information
      • Social Media
    • Built-in Bots
      • Version 3 bots
        • C# Scripted Bot
        • Email bot
        • Trendline Bot
        • Triangle Arbitrage Bot
      • Accumulation Bot
      • Enhanced RSI bot
      • FlashCrash (Grid) Bot
      • Crypto Index Bot
      • Intellibot Alice
      • Inter Exchange Arbitrage Bot
      • MadHatter Bot
      • Market Making Bot
      • Order Bot
      • PingPong Bot
      • Scalper bot
      • Zone-Recovery Bot
    • Community Bots
      • Simple Grid Bot (SPOT)
      • Simple Grid Bot (FUTURES)
      • Simple Market Maker (SPOT)
      • Simple Market Maker (FUTURES)
  • Usage
    • First Usage
    • Setup Exchange
      • Adding an API to the Platform
      • Binance
      • Binance US
      • Bit2me
      • Bitfinex
      • Bitget
      • BitMEX
      • ❌Bitpanda
      • Bitstamp
      • ❌Bittrex
      • Bybit
      • ❌Cex.IO (Legacy API)
      • ❌Coinbase
      • ❌Crypto.com
      • Deribit
      • Gemini
      • Gleec
      • ❌HitBTC
      • Huobi
      • ❌Ionomy
      • Kraken
      • Kraken Futures
      • KuCoin
      • KuCoin Futures
      • LBank
      • ❌OKCoin
      • OKX
      • OKX-Futures
      • OKX-Swap
      • Phemex
      • Poloniex
      • Poloniex Futures
      • WooX
    • Setup Telegram Notification Bot
    • Setup Discord Notification Bot
    • Use Signals
  • Other Resources
    • YouTube
    • Guides & Tutorials
    • Questions & Answers
    • Community Projects
  • Need Help?
    • Ask on Discord
    • Submit Support Ticket
Powered by GitBook
On this page
  • AdjustVPosition
  • CloseVPosition
  • CreatePosition
  • GetAllOpenPositions
  • GetPositionAmount
  • GetPositionDirection
  • GetPositionEnterPrice
  • GetPositionMarket
  • GetPositionProfit
  • GetPositionROI
  • IsPositionClosed
  • LongAmount
  • PositionContainer
  • ShortAmount

Was this helpful?

  1. Haasscript
  2. Commands
  3. Trading

Position Information

AdjustVPosition

Adjusts a virtual bot position by processing a simulated order using the defined specifications. Works similarly to PlaceExitLongOrder/PlaceExitShortOrder, but will NOT create a real order; only simulated!

Syntax: AdjustVPosition(price, amount, [ positionId ])

Return type: Void

Parameter Name
Parameter Type
Required
Suggestions

price

Number

True

Number,UserPositionContainer

amount

Number

True

Number,UserPositionContainer

positionId

String

False

NewGuid,Text,Load

CloseVPosition

Closes a virtual bot position entirely by processing a simulated order using the defined specifications. Works similarly to DoExitPosition and PlaceExitPositionOrder, but will NOT create a real order; only simulated! Use this to "clean up" bot positions if required.

Syntax: CloseVPosition(price, [ positionId ])

Return type: Void

Parameter Name
Parameter Type
Required
Suggestions

price

Number

True

Number,UserPositionContainer

positionId

String

False

NewGuid,Text,Load

CreatePosition

Creates a bot position by processing a simulated order using the defined specifications. By doing this, profit/loss and position details can be used by the script. Use the returned position ID with PositionContainer() to extract position data.

Syntax: CreatePosition(direction, price, amount, [ market ], [ leverage ], [ positionId ])

Returns the position ID.

Return type: String

Parameter Name
Parameter Type
Required
Suggestions

direction

Enum

True

PositionLong,PositionShort

price

Number

True

Number,UserPositionContainer

amount

Number

True

Number,UserPositionContainer,MaxExitLongAmount,MaxExitShortAmount

market

String

False

InputAccountMarket,InputMarket,InputPriceSourceMarket,PriceMarket

leverage

Number

False

Input,Number,Leverage

positionId

String

False

NewGuid,Text,Load

GetAllOpenPositions

Gets all open positions and returns them as PositionContainers.

Syntax: GetAllOpenPositions()

Returns an array of PositionContainers.

Return type: Dynamic

GetPositionAmount

Gets the total amount open in a specific position.

Syntax: GetPositionAmount([ positionId ])

Returns the total amount open in a specific position.

Return type: Number

Parameter Name
Parameter Type
Required
Suggestions

positionId

String

False

Load

GetPositionDirection

Gets the direction of a specific position.

Syntax: GetPositionDirection([ positionId ])

Returns PositionLong, PositionShort or NoPosition.

Return type: Enum

Parameter Name
Parameter Type
Required
Suggestions

positionId

String

False

Load

GetPositionEnterPrice

Gets the average enter price of an open position.

Syntax: GetPositionEnterPrice([ positionId ], [ includeClosed ])

Returns the average enter price.

Return type: Number

Parameter Name
Parameter Type
Required
Suggestions

positionId

String

False

Load

includeClosed

Boolean

False

True,IsTrue,False,IsFalse,Or,Branch,Equals,IsBiggerThan,IsSmallerThan,IsBiggerOrSmallerThan,IsAnyOrderOpen,IsOrderFilled,IsOrderOpen,IsTradeAmountEnough

GetPositionMarket

Gets the market of an open position.

Syntax: GetPositionMarket([ positionId ])

Returns the account, market & leverage as a single string.

Return type: String

Parameter Name
Parameter Type
Required
Suggestions

positionId

String

False

Load

GetPositionProfit

Gets the total realized plus unrealized profit of a specific position.

Syntax: GetPositionProfit([ positionId ], [ targetPrice ])

Returns the total realized plus unrealized profit of a specific position. On spot/margin the result will be in the quote currency. For leverage its in the underlying currency.

Return type: Number

Parameter Name
Parameter Type
Required
Suggestions

positionId

String

False

Load

targetPrice

Number

False

GetBuyPrices,GetSellPrices,GetOpenPrices,GetHighPrices,GetLowPrices,GetClosePrices,GetHighLowPrices,GetHighLowClosePrices,GetOpenClosePrices,GetOpenHighLowClosePrices,GetBodyHighPrices,GetBodyLowPrices

GetPositionROI

Calculates the ROI based on used margin and unrealized + realized profits.

Syntax: GetPositionROI([ positionId ], [ targetPrice ])

Returns the ROI as a percentage.

Return type: Number

Parameter Name
Parameter Type
Required
Suggestions

positionId

String

False

Load

targetPrice

Number

False

GetBuyPrices,GetSellPrices,GetOpenPrices,GetHighPrices,GetLowPrices,GetClosePrices,GetHighLowPrices,GetHighLowClosePrices,GetOpenClosePrices,GetOpenHighLowClosePrices,GetBodyHighPrices,GetBodyLowPrices

IsPositionClosed

Checks whether or not a position is closed.

Syntax: IsPositionClosed([ positionId ])

Returns true if position is closed, otherwise false.

Return type: Boolean

Parameter Name
Parameter Type
Required
Suggestions

positionId

String

False

Load

LongAmount

Gets the total amount open in a long position.

Syntax: LongAmount([ market ])

Returns the total amount open in a long position.

Return type: Number

Parameter Name
Parameter Type
Required
Suggestions

market

String

False

InputAccountMarket,InputMarket,InputPriceSourceMarket,PriceMarket

PositionContainer

Gets all the information from the open bot position.

Syntax: PositionContainer([ positionId ], [ includeClosed ])

Returns an array with position information.

Return type: Dynamic

Parameter Name
Parameter Type
Required
Suggestions

positionId

String

False

Load

includeClosed

Boolean

False

True,IsTrue,False,IsFalse,Or,Branch,Equals,IsBiggerThan,IsSmallerThan,IsBiggerOrSmallerThan,IsAnyOrderOpen,IsOrderFilled,IsOrderOpen,IsTradeAmountEnough

ShortAmount

Gets the total amount open in a short position.

Syntax: ShortAmount([ market ])

Returns the total amount open in a short position.

Return type: Number

Parameter Name
Parameter Type
Required
Suggestions

market

String

False

InputAccountMarket,InputMarket,InputPriceSourceMarket,PriceMarket

PreviousOrder HandelingNextPosition Price Information

Last updated 1 year ago

Was this helpful?