Skip to content

Assets

Summary

Represents the list of all the assets with the asset names as string values.

Signature

1
public abstract interface Assets

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 using cAlgo.API;
 namespace cAlgo.Robots
 {
     [Robot(AccessRights = AccessRights.None)]
     public class NewcBot2 : Robot
     {
         protected override void OnStart()
         {
             foreach (var assetName in Assets)
             {
                 var asset = Assets.GetAsset(assetName);
                 Print("Asset Name: {0} | Asset Digits: {1} | Is Deposit Asset: {2}", asset.Name, asset.Digits, asset.Name == Account.Asset.Name);
             }
         }
     }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 namespace cAlgo.Robots;
  [Robot(AccessRights = AccessRights.None)]
  public class TestExample : Robot
  {
     protected override void OnStart()
     {
         var eur = Assets.GetAsset("EUR");
         var usd = Assets.GetAsset("USD");
         Print($"1 EUR is {eur.Convert(usd, 1)}");
     }
  }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 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):
         for assetName in api.Assets:
             asset = api.Assets.GetAsset(assetName)
             print(f"Asset Name: {asset.Name} | Asset Digits: {asset.Digits} | Is Deposit Asset: {asset.Name == api.Account.Asset.Name}")
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 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):
         eur = api.Assets.GetAsset("EUR")
         usd = api.Assets.GetAsset("USD");
         print(f"1 EUR is {eur.Convert(usd, 1)}")

Methods

GetAsset

Summary

Gets the asset.

Signature

1
public abstract Asset GetAsset(string assetName)

Parameters

Name Type Description
assetName string Name of the asset you want to get

Return Value

Asset

GetAssets

Summary

Get multiple assets on a single call.

Signature

1
public abstract Asset[] GetAssets(string[] assetNames)

Parameters

Name Type Description
assetNames string[] Names of the assets you want to get

Return Value

Asset[]

Exists

Summary

Defines if the specific asset exists.

Signature

1
public abstract bool Exists(string assetName)

Parameters

Name Type Description
assetName string Name of the asset you want to check

Return Value

bool

Properties

Item

Signature

1
public abstract string Item {get;}

Return Value

string

Count

Summary

Gets the total number of the assets.

Signature

1
public abstract int Count {get;}

Return Value

int