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
63 commits
Select commit Hold shift + click to select a range
89b0c5a
Clean up unused constants
Feb 21, 2019
0bcbe2a
Filter n/a (sub)markets & symbols, implement logic for getting barrie…
Feb 21, 2019
5c0fc94
Always initialise barrier offset + prediction fields
Feb 21, 2019
9eb50e1
Create common function for generating barriers, hide fields by default
Feb 21, 2019
885b171
Combine getTradeType & getSelectedSymbol into common function
Feb 21, 2019
b8c3889
Move custom functions to customBlockly, add attachShadowBlock function
Feb 21, 2019
1dbe490
Remove custom blockly hooks, move them to customBlockly
Feb 21, 2019
eb875ad
Create hideInteractionsFromBlockly function
Feb 21, 2019
4285efb
Refactor tradeOptions, show barrier offset, prediction, durations bas…
Feb 21, 2019
078c3aa
package-lock.json
Feb 21, 2019
9d5039b
Default to smallest barriers if barriers based on duration could not …
Feb 21, 2019
9e860b6
Maintain user-imported duration, but default to smallest duration on …
Feb 21, 2019
2260532
Add args to only change min duration in updateDurationLists args
Feb 21, 2019
07fa8fc
Remove default duration value
Feb 21, 2019
e89288e
Add eslint exception
Feb 21, 2019
5bd5659
Small refactor
Feb 21, 2019
3d61458
Default to smallest durations when changing tradeType
Feb 22, 2019
0d3c321
Don't let haveContractForSymbol bypass isDifferentAccount() and isExp…
Feb 22, 2019
abd1e43
Only get updated data if not already doing so
Feb 22, 2019
23945c9
Lock call to getContractsForSymbolFromApi
Feb 22, 2019
38335d0
Suppress incorrect error
Feb 22, 2019
ca5236a
One-time events don't work
Feb 22, 2019
4f70173
Maintain duration unit when changing tradeType
Feb 27, 2019
2188a8b
Disable frxUSDSEK as we don't offer forward-starting contracts
Feb 27, 2019
de86a46
Add absoluteBarrier
Feb 27, 2019
923cd4e
Refactor tradeOptionToProposal() and add absoluteBarrier prop
Feb 27, 2019
4413754
Set barrier equal to contracts.barrier (req for day-durations)
Feb 27, 2019
8db78cf
Add absoluteBarrier() block generator function
Feb 27, 2019
f87af5e
Create logic to determine ABSOLUTEBARRIER vs (SECOND)BARRIEROFFSET
Feb 27, 2019
a49c17a
Create secondAbsoluteBarrier
Feb 27, 2019
157fa57
Add secondAbsoluteBarrier to proposal
Feb 27, 2019
660e937
Add default inputs
Feb 27, 2019
dbe9e2a
Remove wrapper functions, create common function for generating absol…
Feb 27, 2019
73973f9
Move absoluteBarrierLabels to const.js
Feb 27, 2019
42cb8a0
Add support for absoluteBarriers for day-durations, revert to old blo…
Feb 27, 2019
5b98cd9
Return API values rather than calculating the barrier value
Feb 27, 2019
dc66d16
Typo
Feb 27, 2019
5ad9480
Remove unused labels var
Feb 27, 2019
882615a
Fix test
Feb 27, 2019
8d66dbb
Merge branch 'dev' into from-constants-to-api
Feb 27, 2019
b837494
Remove absoluteBarriers
Feb 28, 2019
5534e6c
Prefix barrier types, remove absoluteBarrier related
Feb 28, 2019
ac091a5
Remove references to absoluteBarriers
Feb 28, 2019
9b021bf
Create logic for allowing absolute barriers
Feb 28, 2019
729cb2c
Remove absoluteBarriers
Feb 28, 2019
cc08325
Update barrierOffsetGenerator, remove absoluteBarrierGenerator
Feb 28, 2019
1ed1905
Refactor barrier logic to accomodate absolute barriers
Feb 28, 2019
c7ccae3
Do not pass barrier returned by 'reset' barrier_category
Mar 1, 2019
f8cf410
Change barrier labels based on barrier number + type, add handlebars
Mar 1, 2019
b542135
Remove duplicate declaration
Mar 1, 2019
092f1fe
Allow same offset types to be set, but don't allow both offset/absolu…
Mar 1, 2019
fa92ffb
Refactor logic for getting barrier values
Mar 4, 2019
95810ce
Move handlebar logic to its own function, refactor barrier logic
Mar 4, 2019
c81578c
Maintain values on moving tradeOptions back into trade if possible
Mar 4, 2019
984e4a3
Check barrier types on tradeType change
Mar 4, 2019
ebbc457
Fixes
Mar 4, 2019
01827d4
Support barrier handlebars for multiple and individual tradeOptions b…
Mar 5, 2019
ebedb9f
Send absolute barrier as string
Mar 5, 2019
7f9fb46
Keep bot running on ContractValidationError
Mar 6, 2019
73f84e8
Fix eslint errors
Mar 6, 2019
cb821ba
Check if contract is available
Mar 6, 2019
4600e30
Merge branch 'dev' into from-constants-to-api
ashkanx Mar 7, 2019
12c0f42
Merge pull request #1247 from aaron-binary/from-constants-to-api
ashkanx Mar 7, 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
43 changes: 12 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 33 additions & 12 deletions src/botPage/bot/TradeEngine/Proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export default Engine =>

this.data.get('proposals').forEach(proposal => {
if (proposal.contractType === contractType) {
toBuy = proposal;
if (proposal.error) {
throw Error(proposal.error.error.error.message);
} else {
toBuy = proposal;
}
}
});

Expand All @@ -42,19 +46,33 @@ export default Engine =>
this.store.dispatch(clearProposals());
}
requestProposals() {
Promise.all(
this.proposalTemplates.map(proposal =>
doUntilDone(() =>
this.api.subscribeToPriceForContractProposal({
this.proposalTemplates.map(proposal =>
doUntilDone(() =>
this.api
.subscribeToPriceForContractProposal({
...proposal,
passthrough: {
contractType: proposal.contract_type,
uuid : getUUID(),
},
})
)
.catch(e => {
if (e.error.error.code === 'ContractBuyValidationError') {
const { uuid } = e.error.echo_req.passthrough;

if (!this.data.hasIn(['forgetProposals', uuid])) {
this.data = this.data.setIn(['proposals', uuid], {
...proposal,
contractType: proposal.contract_type,
error : e,
});
}
} else {
this.$scope.observer.emit('Error', e);
}
})
)
).catch(e => this.$scope.observer.emit('Error', e));
);
}
observeProposals() {
this.listen('proposal', r => {
Expand Down Expand Up @@ -84,12 +102,15 @@ export default Engine =>
return Promise.all(
proposals.map(proposal => {
const { uuid: id } = proposal;
const removeProposal = uuid => {
this.data = this.data.deleteIn(['forgetProposals', uuid]);
};

this.data = this.data.setIn(['forgetProposals', id], true);

return doUntilDone(() => this.api.unsubscribeByID(proposal.id)).then(() => {
this.data = this.data.deleteIn(['forgetProposals', id]);
});
if (proposal.error) {
removeProposal(id);
return Promise.resolve();
}
return doUntilDone(() => this.api.unsubscribeByID(proposal.id)).then(() => removeProposal(id));
})
);
}
Expand Down
48 changes: 23 additions & 25 deletions src/botPage/bot/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,30 @@ import { notify } from './broadcast';

export const noop = () => {};

const castBarrierToString = barrier => (barrier > 0 ? `+${barrier}` : `${barrier}`);

export const tradeOptionToProposal = tradeOption =>
tradeOption.contractTypes.map(type => ({
duration_unit: tradeOption.duration_unit,
basis : 'stake',
currency : tradeOption.currency,
symbol : tradeOption.symbol,
duration : tradeOption.duration,
amount : roundBalance({ currency: tradeOption.currency, balance: tradeOption.amount }),
contract_type: type,
...(tradeOption.prediction !== undefined && {
selected_tick: tradeOption.prediction,
}),
...(type !== 'TICKLOW' &&
type !== 'TICKHIGH' &&
tradeOption.prediction !== undefined && {
barrier: tradeOption.prediction,
}),
...(tradeOption.barrierOffset !== undefined && {
barrier: castBarrierToString(tradeOption.barrierOffset),
}),
...(tradeOption.secondBarrierOffset !== undefined && {
barrier2: castBarrierToString(tradeOption.secondBarrierOffset),
}),
}));
tradeOption.contractTypes.map(type => {
const proposal = {
duration_unit: tradeOption.duration_unit,
basis : 'stake',
currency : tradeOption.currency,
symbol : tradeOption.symbol,
duration : tradeOption.duration,
amount : roundBalance({ currency: tradeOption.currency, balance: tradeOption.amount }),
contract_type: type,
};
if (tradeOption.prediction !== undefined) {
proposal.selected_tick = tradeOption.prediction;
}
if (!['TICKLOW', 'TICKHIGH'].includes(type) && tradeOption.prediction !== undefined) {
proposal.barrier = tradeOption.prediction;
} else if (tradeOption.barrierOffset !== undefined) {
proposal.barrier = tradeOption.barrierOffset;
}
if (tradeOption.secondBarrierOffset !== undefined) {
proposal.barrier2 = tradeOption.secondBarrierOffset;
}
return proposal;
});

export const getDirection = ticks => {
const { length } = ticks;
Expand Down
43 changes: 3 additions & 40 deletions src/botPage/common/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const config = {
},
],
},
barrierTypes: [['+', '+'], ['-', '-']],
barrierTypes: [['Offset +', '+'], ['Offset -', '-']],
ohlcFields : [
[translate('Open'), 'open'],
[translate('High'), 'high'],
Expand All @@ -165,45 +165,8 @@ const config = {
[translate('8 hours'), '28800'],
[translate('1 day'), '86400'],
],
mainBlocks : ['trade', 'before_purchase', 'after_purchase', 'during_purchase'],
durationTypes: {
RISEFALL: [
[translate('Ticks'), 't'],
[translate('Seconds'), 's'],
[translate('Minutes'), 'm'],
[translate('Hours'), 'h'],
],
RISEFALLEQUALS: [
[translate('Ticks'), 't'],
[translate('Seconds'), 's'],
[translate('Minutes'), 'm'],
[translate('Hours'), 'h'],
],
HIGHERLOWER: [
[translate('Ticks'), 't'],
[translate('Seconds'), 's'],
[translate('Minutes'), 'm'],
[translate('Hours'), 'h'],
],
RESET: [
[translate('Ticks'), 't'],
[translate('Seconds'), 's'],
[translate('Minutes'), 'm'],
[translate('Hours'), 'h'],
],
TOUCHNOTOUCH : [[translate('Ticks'), 't'], [translate('Minutes'), 'm'], [translate('Hours'), 'h']],
ENDSINOUT : [[translate('Minutes'), 'm'], [translate('Hours'), 'h']],
STAYSINOUT : [[translate('Minutes'), 'm'], [translate('Hours'), 'h']],
ASIANS : [[translate('Ticks'), 't']],
MATCHESDIFFERS: [[translate('Ticks'), 't']],
EVENODD : [[translate('Ticks'), 't']],
OVERUNDER : [[translate('Ticks'), 't']],
HIGHLOWTICKS : [[translate('Ticks'), 't']],
},
hasPrediction : ['MATCHESDIFFERS', 'OVERUNDER', 'HIGHLOWTICKS'],
hasBarrierOffset : ['HIGHERLOWER', 'TOUCHNOTOUCH', 'ENDSINOUT', 'STAYSINOUT'],
hasSecondBarrierOffset: ['ENDSINOUT', 'STAYSINOUT'],
conditionsCategory : {
mainBlocks : ['trade', 'before_purchase', 'after_purchase', 'during_purchase'],
conditionsCategory: {
callput : ['risefall', 'higherlower'],
callputequal: ['risefallequals'],
touchnotouch: ['touchnotouch'],
Expand Down
Loading