1#define _POSIX_C_SOURCE 200809L
10 if (!vec || !pos)
return;
12 for (
int i = 0; i < vec->
capacity; i++) {
21 vec->
active = realloc(vec->
active, new_capacity *
sizeof(
bool));
22 for (
int i = vec->
capacity; i < new_capacity; i++) {
35 if (!vec || index < 0 || index >= vec->
capacity)
return;
36 if (!vec->
active[index])
return;
37 vec->
active[index] =
false;
43 for (
int i = 0; i < vec->
capacity; i++) {
51 if (!vec || index < 0 || index >= vec->capacity || !vec->
active[index]) {
52 if (found) *found =
false;
55 if (found) *found =
true;
56 return vec->positions[index];
62 for (
int i = 0; i < vec->
capacity; i++) {
72 if (!vec)
return NULL;
#define WU_SYMBOL_MAX_LEN
WU_PositionVector * wu_position_vector_new(const char *symbol)
static void add_position(WU_PositionVector *vec, WU_Position pos)
static void remove_position(WU_PositionVector *vec, int index)
static void clear_positions(WU_PositionVector *vec)
static struct WU_Position_ get_position(WU_PositionVector *vec, int index, bool *found)
static double get_total_quantity(WU_PositionVector *vec)
static void wu_position_vector_free(WU_PositionVector *vec)
WU_PositionVector is a data structure that holds multiple positions for a single asset.
struct WU_Position_(* get)(struct WU_PositionVector *vec, int index, bool *found)
void(* remove)(struct WU_PositionVector *vec, int index)
struct WU_Position_ * positions
void(* delete)(struct WU_PositionVector *vec)
void(* clear)(struct WU_PositionVector *vec)
double(* total_quantity)(struct WU_PositionVector *vec)
void(* add)(struct WU_PositionVector *vec, WU_Position pos)
WU_Position represents an open position in the portfolio.