Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get assets or trade digits in vix. #93

Open
eodicarvallho opened this issue Jan 31, 2022 · 2 comments
Open

Can't get assets or trade digits in vix. #93

eodicarvallho opened this issue Jan 31, 2022 · 2 comments

Comments

@eodicarvallho
Copy link

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.

@edwinsmasher
Copy link

Hello, Did you manage to solve this? "Got an error, saying that assets is not a function."

@JamesK254
Copy link

this is because this package is kinda depreciated and doesn't go with the changes being made on the deriv api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants