Author Topic: How to fetch required fees for trading  (Read 2356 times)

0 Members and 1 Guest are viewing this topic.

Offline svk

Thankyou @xeroc and @svk,

Is there any documentation of js library?

As I dont feel good in asking each and everything from you guys. Right now I want to trade currency like sell bts for USD through js library and I dont know from where to start. I have successfully transferred assets from one account to another but dont know how to trade currency in same account.
:(

Thanks guys

Yw. I'm afraid there's very little documentation at the moment, but the js library is being refactored by jcalfee as part of the work being done to add the  stealth transfers. This will hopefully make it more modular and also make it easier to write documentation and tests for it. The stealth development is happening in this branch: https://github.com/cryptonomex/graphene-ui/commits/650-stealth-wallet

In the meantime feel free to ask, we're also available on slack and telegram where it's easier to keep a conversation going!
Worker: dev.bitsharesblocks

Offline madforstrength

Thankyou @xeroc and @svk,

Is there any documentation of js library?

As I dont feel good in asking each and everything from you guys. Right now I want to trade currency like sell bts for USD through js library and I dont know from where to start. I have successfully transferred assets from one account to another but dont know how to trade currency in same account.
:(

Thanks guys

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Hi @xeroc,

Thanks for your valuable reply, however we are not using python library instead we are using js library.
Would appreciate if you can provide equivalent code in js or any documentation of js library.

Currently we are using below code to fetch the required fee for currency conversion:

Code: [Select]
Apis.instance().db_api().exec("get_required_fees", [
                        [[1,{}]],"1.3.0"
                    ])

It is giving us 23386 and after dividing with the bts precision 0.23386.

Is this method Ok?

Thanks and Regards

Yes that's the current fee so that should be correct.
It seems to be correct .. now you also need to know that if you add a memo or anything else that is allowed in your operation and increase the *size* (as in kilobytes) .. then that fee might rise if there is a "per_kilobyte_fee" defined for that particular operation .. as it is for the Transfer operation!
But you don't need to deal with any of it since the "get_required_fees" will derive the exact value for your operation (if you replace the empty "{}" with your actual operation content)

Offline svk

Hi @xeroc,

Thanks for your valuable reply, however we are not using python library instead we are using js library.
Would appreciate if you can provide equivalent code in js or any documentation of js library.

Currently we are using below code to fetch the required fee for currency conversion:

Code: [Select]
Apis.instance().db_api().exec("get_required_fees", [
                        [[1,{}]],"1.3.0"
                    ])

It is giving us 23386 and after dividing with the bts precision 0.23386.

Is this method Ok?

Thanks and Regards

Yes that's the current fee so that should be correct.
Worker: dev.bitsharesblocks

Offline madforstrength

Hi @xeroc,

Thanks for your valuable reply, however we are not using python library instead we are using js library.
Would appreciate if you can provide equivalent code in js or any documentation of js library.

Currently we are using below code to fetch the required fee for currency conversion:

Code: [Select]
Apis.instance().db_api().exec("get_required_fees", [
                        [[1,{}]],"1.3.0"
                    ])

It is giving us 23386 and after dividing with the bts precision 0.23386.

Is this method Ok?

Thanks and Regards

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
you need to put the operation as an Array!!

Code: [Select]
from grapheneapi.grapheneclient import GrapheneClient
from pprint import pprint

class Config():
    wallet_host       = "localhost"
    wallet_port       = 8092
    witness_url       = "wss://bitshares.openledger.info/ws"


if __name__ == '__main__':
    client = GrapheneClient(Config)
    op = client.rpc.get_prototype_operation("limit_order_create_operation")
    pprint(client.ws.get_required_fees([op], "1.3.0"))

Offline sharique-knysys

  • Newbie
  • *
  • Posts: 19
    • View Profile
I put above params in get_required_fees method but it gives this error Invalid cast from uint64_type to Array. Can you give me exact example if I want to sell EURO and get USD. What parameters will I send in get_required_fees method?

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
you need to put the *actual* operation into the parameters .. something
along the lines of:

Code: [Select]
[0,{"fee":{"amount":0,"asset_id":"1.3.0"},"from":"1.2.0","to":"1.2.0","amount":{"amount":0,"asset_id":"1.3.0"},"extensions":[]}]

not the name and the asset of the operation

Offline sharique-knysys

  • Newbie
  • *
  • Posts: 19
    • View Profile
Hi,

I want to know about fees which applies on trading operation. For example if I want to sell USD and get BTS it requires some fees for this operation. I am using  get_required_fees function from database api but I am not sure what arguments this function take as an input. I am using like this but it is not working

{"id":1,"method":"get_required_fees","params":[ ["transfer", "1.3.0"] ]}
« Last Edit: March 07, 2016, 09:15:12 am by sharique-knysys »