forked from QuantBox/QuantBox_XAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPositionFieldEx.cs
47 lines (41 loc) · 1.1 KB
/
PositionFieldEx.cs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace QuantBox.XAPI
{
public class PositionFieldEx
{
public string Symbol { get; private set; }
public string Instrument { get; private set; }
public string Exchange { get; private set; }
public PositionField Long { get; private set; }
public PositionField Short { get; private set; }
public void AddPosition(PositionField position)
{
Symbol = position.Symbol;
Instrument = position.InstrumentID;
Exchange = position.ExchangeID;
if (position.Side == PositionSide.Long)
{
Long = position;
}
else
{
Short = position;
}
}
public double Qty
{
get { return Long.Position - Short.Position; }
}
public double LongQty
{
get { return Long.Position; }
}
public double ShortQty
{
get { return Short.Position; }
}
}
}