IAccount.Balance
property · IAccount · cAlgo.API.Internals
DesktopCLICloud
Returns the balance of the current account.
Definition
double Balance {get;}
api.Account.Balance: float
Returns double
Examples
Example 1
double balanceBefore;
double balanceAfter;
protected override void OnStart()
{
// store the balance upon start up of the robot
balanceBefore = Account.Balance;
}
protected override void OnStop()
{
// Store the balance upon stop of the robot.
balanceAfter = Account.Balance;
// print the difference
Print("The difference of balanceBefore and balanceAfter is: {0}", balanceBefore-balanceAfter);
}
import clr
clr.AddReference("cAlgo.API")
# Import cAlgo API types
from cAlgo.API import *
# Import trading wrapper functions
from robot_wrapper import *
class Test():
def on_start(self):
# store the balance upon start up of the robot
self.balanceBefore = api.Account.Balance
def on_stop(self):
# Store the balance upon stop of the robot.
balanceAfter = api.Account.Balance
# print the difference
api.Print(f"The difference of balanceBefore and balanceAfter is: {self.balanceBefore-balanceAfter}")
Example 2
if ( Account.Balance <= 0 )
Stop();
if api.Account.Balance <= 0:
api.Stop()