WU Trading Library 0.2.0
A backtesting and trading strategy library
Loading...
Searching...
No Matches
data.h
Go to the documentation of this file.
1#ifndef WU_DATA_H
2#define WU_DATA_H
3
4#include "types.h"
5
6/**
7 * WU_Candle represents an aggregated data point to represent how prices
8 * moved within a specific time period. It includes the timestamp of the
9 * start of the period, the open price, the high price, the low price,
10 * the close price, and the volume traded during that period. Instead of
11 * directly using the WU_Candle structure, the wu_candle_init function should
12 * be used to create a new WU_Candle instance, ensuring all fields are
13 * properly initialized.
14 */
15typedef struct WU_Candle_ {
17 double open;
18 double high;
19 double low;
20 double close;
21 double volume;
23} WU_Candle;
24
25/**
26 * WU_Trade represents a single trade in the market, including the
27 * timestamp, price, volume, and side (buy or sell) of the trade. This
28 * is a tick-level data point that represents a single transaction
29 * in the market. As with WU_Candle, the wu_trade_init function should be used
30 * to create a new WU_Trade instance.
31 */
39
40/**
41 * WU_Single represents a single value with a timestamp, which can
42 * be a price, an indicator value, or any other scalar value associated
43 * with a specific time. This is a generic data type that can be used to
44 * represent any single-valued time series data. The wu_single_init
45 * function should be used to create a new WU_Single instance.
46 */
52
53WU_Candle wu_candle_init(WU_TimeStamp timestamp, double open, double high, double low,
54 double close, double volume);
55
56WU_Trade wu_trade_init(WU_TimeStamp timestamp, double price, double volume,
57 WU_Side side);
58
59WU_Single wu_single_init(WU_TimeStamp timestamp, double value);
60
61WU_Signal wu_signal_init(WU_TimeStamp timestamp, WU_Side side, double price,
62 double quantity);
63
64bool wu_signal_validate(const WU_Signal* signal);
65
66#define wu_candle_to_single_value(candle) \
67 wu_single_init((candle)->timestamp, (candle)->close)
68
69#define wu_trade_to_single_value(trade) \
70 wu_single_init((trade)->timestamp, (trade)->price)
71
72#endif // WU_DATA_H
bool wu_signal_validate(const WU_Signal *signal)
Definition init.c:48
WU_Single wu_single_init(WU_TimeStamp timestamp, double value)
Definition init.c:31
WU_Signal wu_signal_init(WU_TimeStamp timestamp, WU_Side side, double price, double quantity)
Definition init.c:39
WU_Candle wu_candle_init(WU_TimeStamp timestamp, double open, double high, double low, double close, double volume)
Implementation of data type initialization functions.
Definition init.c:9
WU_Trade wu_trade_init(WU_TimeStamp timestamp, double price, double volume, WU_Side side)
Definition init.c:21
WU_Candle represents an aggregated data point to represent how prices moved within a specific time pe...
Definition data.h:15
double high
Definition data.h:18
double close
Definition data.h:20
WU_TimeStamp timestamp
Definition data.h:16
double low
Definition data.h:19
double volume
Definition data.h:21
WU_DataType data_type
Definition data.h:22
double open
Definition data.h:17
WU_Signal represents a trading signal generated by a strategy.
Definition types.h:38
WU_Single represents a single value with a timestamp, which can be a price, an indicator value,...
Definition data.h:47
WU_DataType data_type
Definition data.h:50
WU_TimeStamp timestamp
Definition data.h:48
double value
Definition data.h:49
A timestamp represent a mark in time given relative to unix epoch.
Definition timeutils.h:21
WU_Trade represents a single trade in the market, including the timestamp, price, volume,...
Definition data.h:32
WU_Side side
Definition data.h:36
WU_TimeStamp timestamp
Definition data.h:33
WU_DataType data_type
Definition data.h:37
double volume
Definition data.h:35
double price
Definition data.h:34
WU_Side
WU_Side represents the direction of a signal or a trade.
Definition types.h:11
WU_DataType
WU_DataType represents the type of input data, which can be a candle, a trade, or a single value.
Definition types.h:24