WU Trading Library 0.2.0
A backtesting and trading strategy library
Loading...
Searching...
No Matches
strategies.h File Reference
#include "types.h"
#include "data.h"
#include "indicators.h"

Go to the source code of this file.

Data Structures

struct  WU_Strategy
struct  WU_CrossOverStrat
 WU_CrossOverStrat is a simple crossover strategy that generates buy and sell signals based on the crossover of two moving averages. More...
struct  WU_PairsTradingStrat
 WU_PairsTradingStrat implements a classic pairs trading strategy that trades the spread between two correlated assets (statistical arbitrage). More...

Macros

#define WU_STRATEGY(strategy)
#define wu_strategy_update(strategy, inputs)
#define wu_strategy_delete(strategy)
#define wu_strategy_num_inputs(strategy)
#define wu_strategy_input_type(strategy, idx)
#define wu_strategy_num_outputs(strategy)
#define wu_strategy_output_symbol(strategy, idx)

Functions

WU_CrossOverStrat wu_crossover_strat_new (int short_window, int long_window, double threshold)
WU_PairsTradingStrat wu_pairs_trading_strat_new (int window, double threshold, double ratio)
 Creates a new pairs trading strategy.

Macro Definition Documentation

◆ WU_STRATEGY

#define WU_STRATEGY ( strategy)
Value:
((WU_Strategy)(strategy))

Definition at line 19 of file strategies.h.

◆ wu_strategy_delete

#define wu_strategy_delete ( strategy)
Value:
do { \
if ((strategy)->delete) \
(strategy)->delete((WU_Strategy)(strategy)); \
} while(0)

Definition at line 24 of file strategies.h.

◆ wu_strategy_input_type

#define wu_strategy_input_type ( strategy,
idx )
Value:
((strategy)->input_types[idx])

Definition at line 30 of file strategies.h.

◆ wu_strategy_num_inputs

#define wu_strategy_num_inputs ( strategy)
Value:
((strategy)->num_inputs)

Definition at line 29 of file strategies.h.

◆ wu_strategy_num_outputs

#define wu_strategy_num_outputs ( strategy)
Value:
((strategy)->num_outputs)

Definition at line 31 of file strategies.h.

◆ wu_strategy_output_symbol

#define wu_strategy_output_symbol ( strategy,
idx )
Value:
((strategy)->output_symbols[idx])

Definition at line 32 of file strategies.h.

◆ wu_strategy_update

#define wu_strategy_update ( strategy,
inputs )
Value:
((strategy)->update((strategy), (inputs)))

Definition at line 21 of file strategies.h.

Function Documentation

◆ wu_crossover_strat_new()

WU_CrossOverStrat wu_crossover_strat_new ( int short_window,
int long_window,
double threshold )

Definition at line 43 of file crossover.c.

◆ wu_pairs_trading_strat_new()

WU_PairsTradingStrat wu_pairs_trading_strat_new ( int window,
double threshold,
double ratio )

Creates a new pairs trading strategy.

Parameters
windowLookback period for spread statistics
thresholdNumber of standard deviations for entry (e.g., 2.0)
ratioHedge ratio between assets
Returns
New pairs trading strategy instance

Definition at line 106 of file pairs_trading.c.