Asset
Summary
The asset represents a currency.
Signature
| public abstract interface Asset
|
Namespace
cAlgo.API
Methods
Convert (2)
Convert (1 of 2)
Summary
Converts value to another asset.
Signature
| public abstract double Convert(Asset to, double value)
|
Parameters
Name | Type | Description |
to | Asset | Target asset |
value | double | The value you want to convert from current Asset |
Return Value
double
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 | using cAlgo.API;
using System.Text;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class AssetConversionTest : Robot
{
[Parameter(DefaultValue = "CAD")]
public string ConvertToAssetName { get; set; }
[Parameter(DefaultValue = 10)]
public double AmountToConvert { get; set; }
protected override void OnStart()
{
var convertToAsset = Assets.GetAsset(ConvertToAssetName);
if (convertToAsset == null)
{
Print("Asset {0} not found", ConvertToAssetName);
Stop();
return;
}
var result = Account.Asset.Convert(convertToAsset, AmountToConvert);
Print("Result : {0}", result);
}
}
}
|
See Also
Convert (2 of 2)
Summary
Converts value to another asset.
Signature
| public abstract double Convert(string to, double value)
|
Parameters
Name | Type | Description |
to | string | Target asset |
value | double | The value you want to convert from current Asset |
Return Value
double
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 | using cAlgo.API;
using System.Text;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class AssetConversionTest : Robot
{
[Parameter(DefaultValue = "CAD")]
public string ConvertToAssetName { get; set; }
[Parameter(DefaultValue = 10)]
public double AmountToConvert { get; set; }
protected override void OnStart()
{
var convertToAssetExist = Assets.Exists(ConvertToAssetName);
if (!convertToAssetExist)
{
Print("Asset {0} not found", ConvertToAssetName);
Stop();
return;
}
var result = Account.Asset.Convert(ConvertToAssetName, AmountToConvert);
Print("Result : {0}", result);
}
}
}
|
See Also
Properties
Name
Summary
The asset Name
Signature
| public abstract string Name {get;}
|
Return Value
string
Digits
Summary
Number of asset digits
Signature
| public abstract int Digits {get;}
|
Return Value
int
Last update: November 30, 2023