WU Trading Library 0.2.0
A backtesting and trading strategy library
Loading...
Searching...
No Matches
pairs_trading.c File Reference
#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include "wu.h"

Go to the source code of this file.

Macros

#define NUM_INPUTS   2
#define NUM_OUTPUTS   2

Functions

static WU_Signalpairs_trading_strat_update (struct WU_Strategy_ *strat_, const void *inputs[])
static void pairs_trading_strat_free (struct WU_Strategy_ *strategy)
WU_PairsTradingStrat wu_pairs_trading_strat_new (int window, double threshold, double ratio)
 Creates a new pairs trading strategy.

Variables

static const WU_DataType input_types []
static WU_Signal signal_buffer [NUM_OUTPUTS]

Macro Definition Documentation

◆ NUM_INPUTS

#define NUM_INPUTS   2

Definition at line 6 of file pairs_trading.c.

◆ NUM_OUTPUTS

#define NUM_OUTPUTS   2

Definition at line 7 of file pairs_trading.c.

Function Documentation

◆ pairs_trading_strat_free()

void pairs_trading_strat_free ( struct WU_Strategy_ * strategy)
static

Definition at line 99 of file pairs_trading.c.

◆ pairs_trading_strat_update()

WU_Signal * pairs_trading_strat_update ( struct WU_Strategy_ * strat_,
const void * inputs[] )
static

Definition at line 16 of file pairs_trading.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.

Variable Documentation

◆ input_types

const WU_DataType input_types[]
static
Initial value:

Definition at line 9 of file pairs_trading.c.

◆ signal_buffer

WU_Signal signal_buffer[NUM_OUTPUTS]
static

Definition at line 14 of file pairs_trading.c.