You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, Tried to operate digits, but dont get return, if i change from DIGITOVER to CALL, it works fine.
`async function main() {
try {
let gstake = 1;
const account = await api.account(token);
const { balance, currency } = account;
console.log(`Your current balance is: ${balance.currency} ${balance.display}`);
balance.onUpdate(() => {
console.log(`Your new balance is: ${balance.currency} ${balance.display}`);
});
let data = {
contract_type: 'DIGITOVER',
currency,
amount: gstake,
duration: 5,
duration_unit: 't',
symbol: 'R_100',
basis: 'stake',
barrier: 2,
};
let contract = await api.contract(data);
contract.onUpdate(({ status, payout, bid_price }) => {
switch (status) {
case 'proposal':
return console.log(
`Current payout: ${payout.currency} ${payout.display}`);
case 'open':
return console.log(
`Current bid price: ${bid_price.currency} ${bid_price.display}`);
default:
break;
};
});
// Wait until payout is greater than USD 19
await contract.onUpdate().pipe(find(({ payout }) => payout.value >= expected_payout)).toPromise();
const buy = await contract.buy();
console.log(`Buy price is: ${buy.price.currency} ${buy.price.display}`);
// Wait until the contract is sold
await contract.onUpdate().pipe(find(({ is_sold }) => is_sold)).toPromise();
await api.basic.forgetAll();
const { profit, status } = contract;
console.log(`You ${status}: ${profit.currency} ${profit.display}`);
if(status == "loss") {
gstake = gstake * 2.15;
} else {
gstake = 1;
}
api.basic.forgetAll('proposal', 'proposal_open_contract');
} catch (err) {
console.error(err);
} finally {
// Close the connection and exit
//api.basic.disconnect();
}
}`
Second, tried to get assets and open markets, with const assets = await api.assets(); const open_markets = assets.open_markets; const trading_times = assets.trading_times;
Got an error, saying that assets is not a function.
The text was updated successfully, but these errors were encountered:
First, Tried to operate digits, but dont get return, if i change from DIGITOVER to CALL, it works fine.
`async function main() {
try {
let gstake = 1;
}`
Second, tried to get assets and open markets, with
const assets = await api.assets(); const open_markets = assets.open_markets; const trading_times = assets.trading_times;
Got an error, saying that assets is not a function.
The text was updated successfully, but these errors were encountered: