Skip to content

Latest commit

 

History

History
126 lines (87 loc) · 2.97 KB

README.md

File metadata and controls

126 lines (87 loc) · 2.97 KB

Strategies

The strategies are where the results from one or more indicators gets combined to produce a recommended action.

The information provided on this project is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.

Asset

The stragies operates on an Asset with the following members.

interface Asset {
  dates: Date[];
  openings: number[];
  closings: number[];
  highs: number[];
  lows: number[];
  volumes: number[];
}

New Asset with Length

The newAssetWithLength function provides a new asset with each field initialized to the given length.

import {newAssetWithLength} from 'indicatorts';

const asset = newAssetWithLength(2);

asset.closings[0] = 10;
asset.closings[1] = 20;

Concat Assets

The concatAssets function concats the given two assets.

import {concatAssets} from 'indicatorts';

const asset = concatAssets(asset1, asset2);

Strategy Function

The StrategyFunction takes an Asset, and provides an array of Action for each row.

type StrategyFunction = (asset: Asset) => Action[];

Action

The following Action values are currently provided.

enum Action {
  SELL = -1,
  HOLD = 0,
  BUY = 1,
}

Reverse Actions

The reverseActions function returns the reverse of the provided actions.

import {Action, reverseActions} from 'indicatorts';

const actions = [
	Action.SELL,
	Action.HOLD,
	Action.BUY
];

const result = reverseActions(actions);
// [
// 	Actions.BUY,
// 	Actions.HOLD,
// 	Actions.SELL
// ];

Apply Actions

The applyActions function applies the given actions to the given closings and provides the gains at each step.

import {applyActions} from 'indicatorts';

const gains = applyActions(closings, actions);

Buy and Hold Strategy

The buyAndHoldStrategy provides a simple strategy to buy the given asset and hold it. It provides a good indicator for the change of asset's value without any other strategy is used.

import {buyAndHoldStrategy} from 'indicatorts';

const actions = buyAndHoldStrategy(asset);

Disclaimer

The information provided on this project is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.

License

Copyright (c) 2022 Onur Cinar. All Rights Reserved.

The source code is provided under MIT License.