WU Trading Library 0.2.0
A backtesting and trading strategy library
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1#ifndef WU_TYPES_H
2#define WU_TYPES_H
3
4#include <stdint.h>
5#include <stdbool.h>
6#include "timeutils.h"
7
8/**
9 * WU_Side represents the direction of a signal or a trade.
10 */
11typedef enum {
15} WU_Side;
16
17/**
18 * WU_DataType represents the type of input data, which can be a candle, a
19 * trade, or a single value. All these types include a timestamp field
20 * to represent Unix times. The time scale is not fixed and can be
21 * determined by the user, e.g., it can be in seconds, milliseconds, or
22 * nanoseconds.
23 */
29
30/**
31 * WU_Signal represents a trading signal generated by a strategy. It
32 * includes a timestamp, a side (buy, sell, or hold), a price at which
33 * to execute the trade, and a quantity to trade.
34 *
35 * For multi-asset strategies, the position of the signal in the returned
36 * array indicates which asset it applies to (0-based index).
37 */
38typedef struct {
39 // int64_t timestamp;
42 double price;
43 double quantity;
44} WU_Signal;
45
46/**
47 * WU_CloseReason represents the reason for closing a position, which can
48 * be a trading signal, a stop loss, or a take profit. This enum is used
49 * to categorize the trades in the portfolio statistics, allowing for
50 * analysis of the performance of the strategy based on different exit
51 * reasons.
52 */
58
59#define wu_symbol_list(...) ((const char*[]){__VA_ARGS__, NULL})
60
61#endif // WU_TYPES_H
WU_Signal represents a trading signal generated by a strategy.
Definition types.h:38
double price
Definition types.h:42
double quantity
Definition types.h:43
WU_TimeStamp timestamp
Definition types.h:40
WU_Side side
Definition types.h:41
A timestamp represent a mark in time given relative to unix epoch.
Definition timeutils.h:21
WU_Side
WU_Side represents the direction of a signal or a trade.
Definition types.h:11
@ WU_SIDE_HOLD
Definition types.h:12
@ WU_SIDE_SELL
Definition types.h:14
@ WU_SIDE_BUY
Definition types.h:13
WU_CloseReason
WU_CloseReason represents the reason for closing a position, which can be a trading signal,...
Definition types.h:53
@ WU_CLOSE_REASON_TAKE_PROFIT
Definition types.h:56
@ WU_CLOSE_REASON_STOP_LOSS
Definition types.h:55
@ WU_CLOSE_REASON_SIGNAL
Definition types.h:54
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
@ WU_DATA_TYPE_TRADE
Definition types.h:26
@ WU_DATA_TYPE_SINGLE_VALUE
Definition types.h:27
@ WU_DATA_TYPE_CANDLE
Definition types.h:25