Attention Bitshares Developers: I need help with JSON Trade Data.

in #bitshares8 years ago (edited)

enter image description here

Image Credit

Attention Developers: I need help with Openledger Json Trade Data.

I'm trying to determine how to convert the following JSON trade fill data, so that I can create an entry into Cointracking.info coin detail.

Can anyone help?

[4,
{
"fee":{"amount":2000,"asset_id":"OPEN.EOS"},
"order_id":"1.7.62838114",
"account_id":"1.2.2503",
"pays":{"amount":4700001,"asset_id":"BTS"},
"receives":{"amount":1000000,"asset_id":"OPEN.EOS"},
"fill_price":{"base":{"amount":157093302,"asset_id":"OPEN.EOS"},
"quote":{"amount":738338519,"asset_id":"BTS"}},
"is_maker":false}]

Thanks,

@pairmike

Please Remember to UpVote - ReSteem - Comment


Support Me By Shopping at Amazon

Sort:  

Hiya! Not sure if this is what you are looking for, but first, that is valid JSON. And you can play with it in the console of your browser by hitting F12 and going to the console tab. If you paste in

var arr = [4, { "fee":{"amount":2000,"asset_id":"OPEN.EOS"}, "order_id":"1.7.62838114", "account_id":"1.2.2503", "pays":{"amount":4700001,"asset_id":"BTS"}, "receives":{"amount":1000000,"asset_id":"OPEN.EOS"}, "fill_price":{"base":{"amount":157093302,"asset_id":"OPEN.EOS"}, "quote":{"amount":738338519,"asset_id":"BTS"}}, "is_maker":false}]; arr[1].fee.amount

it will return 2000.

I think if you put that json in a validator you will see its structure more clearly:

https://jsonlint.com/

If you have any question on how to get to any other value in this json, let me know and I'll get it for you. But basically, assign that to a js variable, like arr, and then get what you need by starting with

arr[1].firstLevel.secondLevel.thirdLevel

replacing firstLevel, etc with the name of the variable.

Hey Kenny,

I know it not valid Json. What I'm really looking for is to understand how to convert this info into something like this:

Type Buy Cur. Sell Cur. Fee Cur. Exchange Group Comment Date
Trade 4.46672378 LTC 978.90708337 USD 2.92793744 USD GDAX 2018-02-15 09:00:44

Are you getting this data from a javascript program or are you using something else?

In js, the Buy Currency would be

arr[1].receives.amount + ' ' + arr[1].receives.asset_id

I would think.

cointracking.info says they have "Automatic import via APIs" so I would think there would already be some automatic way to do this, but I'm not familiar with BitShares/OpenLedger APIs. I imagine they have APIs and they probably look like Steemit APIs, but I'd have to look into it. I assume what you show here is the result of a BitShares API call, but maybe cointracking does not support this API?

This data is from the bitshares api. See this link for the explorer to download - http://open-explorer.io/bitshares-account-exporter/index.php

Cointracking.info has not created an import for any of the Bitshares decentralized exchanges.

So when you use that form, you get a CSV file, and it looks like what you posted was the value for the "Operation History - Raw Operation" field.

Mapping from that, to what cointracking needs:

The Type will probably always be "Trade".

Buy Currency is probably the "receives" json data.

Sell Currency is probably "pays".

Fee Currency is probably "fee".

Exchange Group is Open Ledger.

Comment Date is probably the value in the CSV file under the "Block Data - Block Time" heading, for example 2018-04-11T11:27:57

So are you looking for a program to take the CSV file data and output data that cointracking can handle? Or are you just trying to figure out what data in the CSV file corresponds to what cointracking needs? I think what I stated above is the correct map of the CSV data and the data cointracking needs.

If you need some custom coding for something like this, we can talk more by email. I'm at kenny [at] YouTubeStars.com

Best wishes!

post.JPG

Congratulation

Today 2 years ago you joined SteemIt
Thank you, for making SteemIt great and Steem on for more years to come!

(You are being celebrated here)

Coin Marketplace

STEEM 0.09
TRX 0.31
JST 0.034
BTC 110592.94
ETH 3872.80
USDT 1.00
SBD 0.61