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.
The stragies operates on an Asset with the following members.
interface Asset {
dates: Date[];
openings: number[];
closings: number[];
highs: number[];
lows: number[];
volumes: number[];
}
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;
The concatAssets function concats the given two assets.
import {concatAssets} from 'indicatorts';
const asset = concatAssets(asset1, asset2);
The StrategyFunction takes an Asset, and provides an array of Action for each row.
type StrategyFunction = (asset: Asset) => Action[];
The following Action values are currently provided.
enum Action {
SELL = -1,
HOLD = 0,
BUY = 1,
}
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
// ];
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);
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);
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.
Copyright (c) 2022 Onur Cinar. All Rights Reserved.
The source code is provided under MIT License.