Skip to content

Commit a8a190e

Browse files
committed
Add Heikin Ashi to menus
1 parent 41a1fc2 commit a8a190e

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

.storybook/charts/DynamicOHLCChart.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { LiveEvents } from 'binary-live-api';
3+
import chartTypeToDataType from '../../src/utils/chartTypeToDataType';
34
import BinaryChart from '../../src/BinaryChart';
45
import api from '../ApiSingleton';
56

@@ -61,7 +62,7 @@ export default class DynamicOHLCChart extends React.Component {
6162
}
6263

6364
changeType(type: string): Promise<*> {
64-
const style = (type === 'candlestick' || type === 'ohlc') ? 'candles' : 'ticks';
65+
const style = chartTypeToDataType(type);
6566
return api.getTickHistory('R_100', { subscribe: 1, end: 'latest', count: 100, style })
6667
.then(r => {
6768
let data;

.storybook/charts/TypeSwitchableChart.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import BinaryChart from '../../src/BinaryChart';
33
import api from '../ApiSingleton';
4+
import chartTypeToDataType from '../../src/utils/chartTypeToDataType';
45

56
const token = 'qdJ86Avvrsh0Le4';
67
const getContract = contractID => api.getContractInfo(contractID).then(r => r.proposal_open_contract);
@@ -24,7 +25,7 @@ export default class TypeSwitchChart extends React.Component {
2425
}
2526

2627
changeType(type: string): Promise<*> {
27-
const style = (type === 'candlestick' || type === 'ohlc') ? 'candles' : 'ticks';
28+
const style = chartTypeToDataType(type);
2829
return api.authorize(token).then(() =>
2930
api.getDataForContract(() => getContract(contractId), undefined, style)
3031
).then(r => {

src/toolbar/TypePicker.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ const items = [
1616
{ text: 'Line', value: 'line', img: <LineIcon /> },
1717
{ text: 'Candlestick', value: 'candlestick', img: <CandlestickIcon /> },
1818
{ text: 'Bars', value: 'ohlc', img: <BarIcon /> },
19+
{ text: 'Heikin Ashi', value: 'ha', img: <CandlestickIcon /> },
1920
];
2021

2122
const typeLabel = {
2223
line: 'Line',
2324
area: 'Area',
2425
candlestick: 'Candlestick',
2526
ohlc: 'Bars',
27+
ha: 'Heikin Ashi',
2628
};
2729

2830
export default class TypePicker extends PureComponent {

src/utils/chartTypeToDataType.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default (type: ChartType) => {
33
case 'area':
44
case 'line':
55
return 'ticks';
6+
case 'ha':
67
case 'ohlc':
78
case 'candlestick':
89
return 'candles';

0 commit comments

Comments
 (0)