Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3a715f7
Merge pull request #1097 from binary-com/dev
ashkanx Jan 11, 2019
2e0b98f
Merge pull request #1108 from binary-com/dev
ashkanx Jan 15, 2019
fa8efaa
Merge pull request #1125 from binary-com/dev
ashkanx Jan 22, 2019
ff4bd1f
Merge dev
gokula-binary Jan 28, 2019
b6a9127
Merge pull request #1164 from binary-com/dev
Feb 1, 2019
f2cd227
Merge pull request #1166 from binary-com/dev
Feb 1, 2019
76f5d5f
Merge pull request #1190 from binary-com/dev
ashkanx Feb 7, 2019
3bdcc1b
Merge pull request #1193 from binary-com/dev
ashkanx Feb 8, 2019
5a828ed
Merge pull request #1201 from binary-com/dev
ashkanx Feb 11, 2019
0a921c0
Merge branch 'master' into beta
ashkanx Feb 11, 2019
d9bb399
Merge pull request #1202 from binary-com/beta
gokula-krishna-dev Feb 11, 2019
a4acb02
Merge pull request #1266 from binary-com/dev
ashkanx Feb 25, 2019
50783f2
Merge pull request #1273 from binary-com/dev
ashkanx Feb 26, 2019
09780b4
Merge pull request #1277 from binary-com/dev
ashkanx Feb 27, 2019
3150d6e
Merge pull request #1298 from binary-com/beta
ashkanx Mar 5, 2019
2dcaf4d
Merge pull request #1303 from binary-com/dev
ashkanx Mar 6, 2019
4876515
Merge pull request #1306 from binary-com/dev
ashkanx Mar 7, 2019
89dd0d7
Merge pull request #1328 from binary-com/dev
ashkanx Mar 14, 2019
83d836d
Merge pull request #1330 from binary-com/dev
ashkanx Mar 15, 2019
63a560f
Merge pull request #1345 from binary-com/dev
ashkanx Mar 21, 2019
e916ddf
Merge pull request #1359 from binary-com/dev
ashkanx Mar 25, 2019
d7bbc14
Merge branch 'master' into beta
ashkanx Mar 25, 2019
a6c28fa
Merge pull request #1360 from binary-com/beta
ashkanx Mar 26, 2019
8fc36a0
Merge pull request #1393 from binary-com/dev
ashkanx Apr 3, 2019
d82771c
Merge branch 'master' into beta
ashkanx Apr 4, 2019
fffd2e8
Merge pull request #1397 from binary-com/beta
ashkanx Apr 4, 2019
61c06d0
Merge pull request #1400 from binary-com/dev
ashkanx Apr 4, 2019
852de7f
Merge pull request #1413 from binary-com/dev
ashkanx Apr 10, 2019
98657a3
Merge pull request #1426 from binary-com/dev
ashkanx Apr 16, 2019
fb32409
Merge branch 'master' into beta
ashkanx Apr 16, 2019
30b9bb6
Merge pull request #1428 from binary-com/beta
ashkanx Apr 16, 2019
c0d3a16
Merge pull request #1434 from binary-com/dev
ashkanx Apr 19, 2019
6dbc621
Merge branch 'master' into beta
ashkanx Apr 22, 2019
28b4140
Merge pull request #1439 from binary-com/beta
ashkanx Apr 22, 2019
18b3c4c
Merge pull request #1440 from binary-com/dev
ashkanx Apr 22, 2019
1364cca
Merge branch 'master' into beta
ashkanx Apr 22, 2019
8b894da
Merge pull request #1441 from binary-com/beta
ashkanx Apr 22, 2019
1e7cee6
added auto refresh of contracts
Apr 26, 2019
e90db0d
Merge branch 'dev' into refresh-contracts
khalidibrahimio Apr 26, 2019
ed5551d
Set node to v10.15.3 and force npm to 6.9.0
Apr 25, 2019
a9b2ee3
added auto refresh of contracts
Apr 26, 2019
4a07500
Merge branch 'refresh-contracts' of github.com:Khalidxx/binary-bot in…
Apr 29, 2019
05ccace
code cleanup
Apr 29, 2019
2aa1e56
port update
Apr 29, 2019
01bbe73
added auto refresh of contracts
Apr 26, 2019
077b746
code cleanup
Apr 29, 2019
a2672cf
port update
Apr 29, 2019
2560a01
Merge branch 'refresh-contracts' of github.com:Khalidxx/binary-bot in…
khalidibrahimio May 2, 2019
a808528
added contract settled message
khalidibrahimio May 2, 2019
25b5e53
added translate and fixed style
khalidibrahimio May 3, 2019
65cedfb
status color
khalidibrahimio May 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/botPage/bot/TradeEngine/OpenContract.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { roundBalance } from '../../common/tools';
import { doUntilDone } from '../tools';
import { contractStatus, contract as broadcastContract } from '../broadcast';
import { contractStatus, contractSettled, contract as broadcastContract } from '../broadcast';
import { sell, openContractReceived } from './state/actions';

const AFTER_FINISH_TIMEOUT = 5;
Expand All @@ -27,7 +27,9 @@ export default Engine =>
contractStatus({
id : 'contract.sold',
data: contract.transaction_ids.sell,
contract,
});
contractSettled(contract);
this.contractId = '';
this.updateTotals(contract);
if (this.afterPromise) {
Expand Down Expand Up @@ -67,7 +69,9 @@ export default Engine =>
this.unsubscribeOpenContract();

doUntilDone(() => this.api.subscribeToOpenContract(contractId)).then(r => {
({ proposal_open_contract: { id: this.openContractId } } = r);
({
proposal_open_contract: { id: this.openContractId },
} = r);
});
}
resetSubscriptionTimeout(timeout = this.getContractDuration() + AFTER_FINISH_TIMEOUT) {
Expand Down
2 changes: 2 additions & 0 deletions src/botPage/bot/broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const contract = c => globalObserver.emit('bot.contract', c);

export const contractStatus = c => globalObserver.emit('contract.status', c);

export const contractSettled = c => globalObserver.emit('contract.settled', c);

export const info = i => globalObserver.emit('bot.info', i);

export const notify = (className, message) => globalObserver.emit('Notify', { className, message, position: 'right' });
68 changes: 58 additions & 10 deletions src/botPage/view/TradeInfoPanel/TradeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ const getProfit = ({ sell_price: sellPrice, buy_price: buyPrice, currency }) =>
return '';
};

const getTimestamp = date => {
const buyDate = new Date(date * 1000);
return `${buyDate.toISOString().split('T')[0]} ${buyDate.toTimeString().slice(0, 8)} ${
buyDate.toTimeString().split(' ')[1]
}`;
};

const minHeight = 290;
const rowHeight = 25;

const ProfitColor = ({ value }) => <div style={value > 0 ? style.green : style.red}>{value}</div>;
const ProfitColor = ({ value }) => <div style={value > 0 ? style.greenLeft : style.redLeft}>{value}</div>;
const StatusFormat = ({ value }) => <div style={style.left}>{value}</div>;

export default class TradeTable extends Component {
constructor({ accountID }) {
Expand All @@ -39,15 +47,18 @@ export default class TradeTable extends Component {
};
this.columns = [
{ key: 'timestamp', width: 192, resizable: true, name: translate('Timestamp') },
{ key: 'reference', width: 142, resizable: true, name: translate('Reference') },
{ key: 'contract_type', width: 104, resizable: true, name: translate('Trade type') },
{ key: 'entry_tick', width: 80, resizable: true, name: translate('Entry spot') },
{ key: 'exit_tick', width: 70, resizable: true, name: translate('Exit spot') },
{ key: 'reference', width: 110, resizable: true, name: translate('Reference') },
{ key: 'contract_type', width: 70, resizable: true, name: translate('Trade type') },
{ key: 'entry_tick', width: 75, resizable: true, name: translate('Entry spot') },
{ key: 'exit_tick', width: 75, resizable: true, name: translate('Exit spot') },
{ key: 'buy_price', width: 80, resizable: true, name: translate('Buy price') },
{ key: 'profit', width: 80, resizable: true, name: translate('Profit/Loss'), formatter: ProfitColor },
{ key: 'contract_status', width: 70, resizable: true, name: translate('Status'), formatter: StatusFormat },
];
}
componentWillMount() {
const { api } = this.props;

globalObserver.register('summary.export', () => {
const accountData = this.state[this.props.accountID];
if (accountData && accountData.rows.length > 0) {
Expand All @@ -68,16 +79,14 @@ export default class TradeTable extends Component {
if (!info) {
return;
}
const buyDate = new Date(info.date_start * 1000);
const timestamp = `${buyDate.toISOString().split('T')[0]} ${buyDate.toTimeString().slice(0, 8)} ${
buyDate.toTimeString().split(' ')[1]
}`;
const timestamp = getTimestamp(info.date_start);
const tradeObj = { reference: info.transaction_ids.buy, ...info, timestamp };
const { accountID } = tradeObj;

const trade = {
...tradeObj,
profit: getProfit(tradeObj),
profit : getProfit(tradeObj),
contract_status: translate('Pending'),
};

const accountStat = this.getAccountStat(accountID);
Expand All @@ -93,6 +102,45 @@ export default class TradeTable extends Component {
this.setState({ [accountID]: appendRow(trade, accountStat) });
}
});
globalObserver.register('contract.settled', contract => {
this.registerTimeout(api, contract);
});
}
registerTimeout = (api, contract) => {
setTimeout(() => {
const contractID = contract.contract_id;
this.refreshContract(api, contractID);
}, 3000);
};
refreshContract(api, contractID) {
api.getContractInfo(contractID).then(r => {
const contract = r.proposal_open_contract;
const timestamp = getTimestamp(contract.date_start);
const tradeObj = { reference: contract.transaction_ids.buy, ...contract, timestamp };
const { accountID } = this.props;

const trade = {
...tradeObj,
profit: getProfit(tradeObj),
};

if (trade.is_expired && trade.is_sold && !trade.exit_tick) trade.exit_tick = '-';

const { id } = this.state[accountID];
const rows = this.state[accountID].rows.slice();
const updatedRows = rows.map(row => {
const { reference } = row;
if (reference === trade.reference) {
return {
contract_status: translate('Settled'),
reference,
...trade,
};
}
return row;
});
this.setState({ [accountID]: { id, rows: updatedRows } });
});
}
rowGetter(i) {
const { accountID } = this.props;
Expand Down
2 changes: 1 addition & 1 deletion src/botPage/view/TradeInfoPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default class TradeInfoPanel extends Component {
<AnimateTrade />
</div>
<div className="content-row">
<TradeTable accountID={accountID} />
<TradeTable accountID={accountID} api={this.props.api} />
</div>
<div className="content-row">
<Summary accountID={accountID} />
Expand Down
2 changes: 1 addition & 1 deletion src/botPage/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,6 @@ function renderReactComponents() {
/>,
$('#footer')[0]
);
ReactDOM.render(<TradeInfoPanel />, $('#summaryPanel')[0]);
ReactDOM.render(<TradeInfoPanel api={api} />, $('#summaryPanel')[0]);
ReactDOM.render(<LogTable />, $('#logTable')[0]);
}
6 changes: 6 additions & 0 deletions src/botPage/view/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ export const bottomWarningLink = { textDecoration: 'underline' };

export const green = { color: 'green' };

export const greenLeft = { color: 'green', float: 'left' };

export const red = { color: 'red' };

export const redLeft = { color: 'red', float: 'left' };

export const tradePanelAccount = { float: 'right' };

export const left = { float: 'left' };

export const warningText = {
'font-size': '12px',
color : 'lightgray',
Expand Down
2 changes: 1 addition & 1 deletion static/css/_panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $disabled-color: #F2F2F2;
margin-bottom: 1em;
}
p {
margin: 0em;
margin: 0em;
}
#sync-warning {
font-size: 11px;
Expand Down