2024-09-24 16:41:26 -07:00
|
|
|
namespace QuanTAlib;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
2024-10-06 07:24:57 +00:00
|
|
|
public enum OType {
|
2024-09-24 16:41:26 -07:00
|
|
|
NIL = 0, // No position
|
|
|
|
|
BTO = 1, // Buy to Open
|
|
|
|
|
STC = 2, // Sell to Close
|
|
|
|
|
STO = 3, // Sell to Open
|
|
|
|
|
BTC = 4, // Buy to Close
|
|
|
|
|
END = 5, // Exit the trade
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-10-06 07:24:57 +00:00
|
|
|
public class TOrders : List<(DateTime t, OType o)> {
|
2024-09-24 16:41:26 -07:00
|
|
|
|
2024-10-06 07:24:57 +00:00
|
|
|
public void Add((DateTime t, OType o) TOrder, bool update = false) {
|
|
|
|
|
if (update) { this[^1] = TOrder; } else { base.Add(TOrder); }
|
2024-09-24 16:41:26 -07:00
|
|
|
OnEvent(update);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-10-06 07:24:57 +00:00
|
|
|
protected virtual void OnEvent(bool update = false) {
|
2024-09-24 16:41:26 -07:00
|
|
|
Pub?.Invoke(this, new TSeriesEventArgs { update = update });
|
|
|
|
|
}
|
|
|
|
|
public delegate void NewDataEventHandler(object source, TSeriesEventArgs args);
|
|
|
|
|
public event NewDataEventHandler Pub;
|
|
|
|
|
|
|
|
|
|
}
|