PriceAlerts
Summary
Represents a collection of price alerts.
Signature
| public abstract interface PriceAlerts
|
Namespace
cAlgo.API
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 | using cAlgo.API;
namespace cAlgo.Robots;
[Robot(AccessRights = AccessRights.None)]
public class Test : Robot
{
protected override void OnStart()
{
Print($"Price Alerts Count: {PriceAlerts.Count}");
foreach (var priceAlert in PriceAlerts)
{
Print($"Price Alert Id: {priceAlert.Id}, Symbol: {priceAlert.Symbol.Name}, Price: {priceAlert.Price}, Quote Type: {priceAlert.QuoteType}, Condition: {priceAlert.Condition}");
}
PriceAlerts.Added += args => Print($"Price Alert added: {args.PriceAlert.Id}");
PriceAlerts.Removed += args => Print($"Price Alert removed: {args.PriceAlert.Id}");
PriceAlerts.Updated += args => Print($"Price Alert updated: {args.PriceAlert.Id}");
PriceAlerts.Triggered += args => Print($"Price Alert triggered: {args.PriceAlert.Id}");
var newPriceAlert = PriceAlerts.Add(Symbol, Symbol.Bid + (100 * Symbol.PipSize), PriceAlertQuoteType.Bid, PriceAlertCondition.HigherOrEqual);
newPriceAlert.Update(Symbol, newPriceAlert.Price, newPriceAlert.QuoteType, newPriceAlert.Condition, true, "Price alert message");
Print($"Finding price alert result: {PriceAlerts.Find(newPriceAlert.Id) == newPriceAlert}");
PriceAlerts.Remove(newPriceAlert);
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | 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):
print(f"Price Alerts Count: {api.PriceAlerts.Count}")
for priceAlert in api.PriceAlerts:
print(f"Price Alert Id: {priceAlert.Id}, Symbol: {priceAlert.Symbol.Name}, Price: {priceAlert.Price}, Quote Type: {priceAlert.QuoteType}, Condition: {priceAlert.Condition}")
api.PriceAlerts.Added += lambda args: print(f"Price Alert added: {args.PriceAlert.Id}")
api.PriceAlerts.Removed += lambda args: print(f"Price Alert removed: {args.PriceAlert.Id}")
api.PriceAlerts.Updated += lambda args: print(f"Price Alert updated: {args.PriceAlert.Id}")
api.PriceAlerts.Triggered += lambda args: print(f"Price Alert triggered: {args.PriceAlert.Id}")
newPriceAlert = api.PriceAlerts.Add(api.Symbol, api.Symbol.Bid + (100 * api.Symbol.PipSize), PriceAlertQuoteType.Bid, PriceAlertCondition.HigherOrEqual)
newPriceAlert.Update(api.Symbol, newPriceAlert.Price, newPriceAlert.QuoteType, newPriceAlert.Condition, True, "Price alert message")
print(f"Finding price alert result: {api.PriceAlerts.Find(newPriceAlert.Id) == newPriceAlert}")
api.PriceAlerts.Remove(newPriceAlert)
|
Methods
Add
Summary
Adds a new price alert.
Signature
| public abstract PriceAlert Add(Symbol symbol, double price, PriceAlertQuoteType quoteType, PriceAlertCondition condition)
|
Parameters
| Name | Type | Description |
| symbol | Symbol | Symbol |
| price | double | Price |
| quoteType | PriceAlertQuoteType | Quote type |
| condition | PriceAlertCondition | Condition |
Return Value
PriceAlert
Remove
Summary
Removes a price alert.
Signature
| public abstract bool Remove(PriceAlert priceAlert)
|
Parameters
| Name | Type | Description |
| priceAlert | PriceAlert | Price alert |
Return Value
bool
Find
Summary
Finds a price alert by its Id.
Signature
| public abstract PriceAlert Find(long id)
|
Parameters
| Name | Type | Description |
| id | long | The Id of the price alert. |
Return Value
PriceAlert
FindAll
Summary
Finds all price alerts by their symbol.
Signature
| public abstract PriceAlert[] FindAll(string symbolName)
|
Parameters
| Name | Type | Description |
| symbolName | string | The symbol name of the price alert. |
Return Value
PriceAlert[]
Properties
Count
Summary
Gets the total number of active price alerts.
Signature
| public abstract int Count {get;}
|
Return Value
int
Events
Added
Summary
Occurs when a new price alert is added.
Signature
| public abstract event Action<PriceAlertAddedEventArgs> Added;
|
Removed
Summary
Occurs when a price alert is removed.
Signature
| public abstract event Action<PriceAlertRemovedEventArgs> Removed;
|
Updated
Summary
Occurs when a price alert is updated.
Signature
| public abstract event Action<PriceAlertUpdatedEventArgs> Updated;
|
Triggered
Summary
Occurs when a price alert is triggered.
Signature
| public abstract event Action<PriceAlertTriggeredEventArgs> Triggered;
|