wrong value shows on sell with coinbase pro api - coinbase-api

I am using coinbase pro api using sandbox and testing a sell case.
The order i am placing is
const sellParams:any = {
'side': 'sell',
'product_id': 'BTC-USD',
'type': 'market',
'size': '0.009'
}
the response in order status comes as below
{
"type": "market",
"id": "5846345c-c070-44bf-9d31-ec07a1c9892c",
"product_id": "BTC-USD",
"side": "sell",
"post_only": false,
"created_at": "2019-08-12T04:08:29.845922Z",
"fill_fees": "0.0297509100000000",
"filled_size": "0.00300000",
"executed_value": "9.9169700000000000",
"status": "done",
"settled": true,
"done_at": "2019-08-12T04:08:29.853Z",
"done_reason": "canceled",
"size": "0.00900000"
}
the question is on executed value which shows 9.9169... should not it be around 100 USD ?

so basically sandbox prices are different than the actual prices and thats where the confusion was.

Related

How to add child entities without id to parent in state normalized with normalizr

I've recently started using normalizr with zustand in a new React app. It's been a very good experience so far, having solved most of the painful problems I've had in the past.
I've just bumped into an issue I can't think of a clean way of solving for the past few days.
Imagine I have a normalizr-normalized state looking like:
{
"entities": {
"triggers": {
"1": {
"id": 1,
"condition": "WHEN_CURRENCY_EXCHANGED",
"enabled": true,
"value": "TRY"
},
"2": {
"id": 2,
"condition": "WHEN_CURRENCY_EXCHANGED",
"enabled": true,
"value": "GBP"
},
"3": {
"id": 3,
"condition": "WHEN_TRANSACTION_CREATED",
"enabled": true,
"value": true
}
},
"campaigns": {
"19": {
"id": 19,
"name": "Some campaign name",
"triggers": [
1,
2,
3
]
}
}
},
"result": 19
}
And we have a page that allows a user to add one or more triggers to the campaign and then save them. The problem is that at the time of adding these triggers, they do not have an id until the user clicks the Save button (ids are generated by the database). When the Save button is clicked, the state is being denormalized (via normalizr's denormalize function) and sent as payload to the backend looking like the following:
{
"id": 19,
"name": "Some campaign name",
"triggers": [
{
"id": 1,
"condition": "WHEN_CURRENCY_EXCHANGED",
"enabled": true,
"value": "TRY"
},
{
"id": 2,
"condition": "WHEN_CURRENCY_EXCHANGED",
"enabled": true,
"value": "GBP"
},
{
"id": 3,
"condition": "WHEN_TRANSACTION_CREATED",
"enabled": true,
"value": true
}
]
}
The problem is that if the user adds an entity to the triggers, it does not have an id as ids are generated by the database and I cannot find a proper way to add it to the state (due to the id-based nature of normalized states).
The only workaround I can think of is generating some temporary IDs (e.g. uuid) when a trigger is added on the front-end but is not yet saved and then going over each entity upon denormalization, doing something like if (isUuid(trigger.id)) delete trigger.id, which seems too tedious and workaroundish.
Appreciate your help.
P.S. There is something similar explained here. The problem is that in our case the generateId('comment') logic is happening on the backend.
A simple solution is to split.
The create trigger API call and the add trigger to campaign API call.
Do the first, then save the trigger into the normalized store with the id generated by the backend.
Then add it to the campaign.

Cannot set SKU using Quickbooks API

I’m trying to create an item using the Quickbooks Online API, but the field Sku is just ignored. I send a body like this:
{
"TrackQtyOnHand": true,
"Name": "Garden Supplies",
"Sku": "ITEM-1",
"QtyOnHand": 10,
"IncomeAccountRef": {
"name": "Sales of Product Income",
"value": "79"
},
"AssetAccountRef": {
"name": "Inventory Asset",
"value": "81"
},
"InvStartDate": "2015-01-01",
"Type": "Inventory",
"ExpenseAccountRef": {
"name": "Cost of Goods Sold",
"value": "80"
}
}
However in the object I get back as response, the Sku field is not there.
I set the parameter minorVersion to 45 (which is something I was suggested to do), but still not working.
I think the problem is that the param minorVersion should actually be minorversion (all lowercase).

How to get 'trades' resource from Coinbase API?

I use coinbase-node and got transaction API response.
In this response, I can see something like:
{
...
"created_at": "2019-04-21T13:58:12Z",
"updated_at": "2019-04-21T13:58:12Z",
"resource": "transaction",
"resource_path": "/v2/accounts/68a42d04-2075-529c-8cd8-183cd148c45f/transactions/279db234-ca73-5e66-b70a-94502d44739e",
"instant_exchange": false,
"trade": {
"id": "f4ff2d5d-07b7-5c2c-807d-7b98591b488a",
"resource": "trade",
"resource_path": "/v2/accounts/68a42d04-2075-529c-8cd8-183cd148c45f/trades/f4ff2d5d-07b7-5c2c-807d-7b98591b488a"
},
"details": {
"title": "Converted to Bitcoin Cash",
"subtitle": "Using BTC Wallet",
"payment_method_name": "BTC Wallet"
},
...
}
my goal is to find a way to get a trade by ID
any ideas?
This post should help you.
How to import conversions in coinbase api?
At this moment it is impossible to get trades from API call, but you can construct object yourself using trade Id.

Google Analytics: Is there any way to create the Cohort Analysis report using the Analytics API?

Can't find the cohort dimension or the user acquisition date in the Dimensions and Metrics explorer to feed the data into the Google Script .gs (https://developers.google.com/analytics/devguides/reporting/core/dimsmets)
You should try to use the dateOfSession<> segment notation:
segment=users::sequence::^ga:sessionCount==1;dateOfSession<>2014-05-20_2014-05-30;->>ga:sessionDurationBucket>600
The above segment will give you users who have had their first session between May 20, 2014 and May 30, 2014 and have spent > 600 seconds on the site.
Updated April, 2016
As of April 2016, with the release of Analytics Reporting API V4 it is now possible to create cohort reports by directly querying the API:
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
{
"reportRequests": [
{
"viewId": "XXXX",
"dimensions": [
{"name": "ga:cohort" },
{"name": "ga:cohortNthWeek" }],
"metrics": [
{"expression": "ga:cohortActiveUsers"}
],
"cohortGroup": {
"cohorts": [{
"name": "cohort 1",
"type": "FIRST_VISIT_DATE",
"dateRange": {
"startDate": "2015-08-01",
"endDate": "2015-09-01"
}
},
{
"name": "cohort 2",
"type": "FIRST_VISIT_DATE",
"dateRange": {
"startDate": "2015-07-01",
"end_date": "2015-08-01"
}
}],
}
}]
}
The documentation contains samples in various languages.
It is important to note lifetime value queries ("lifetimeValue": True and all ga:acquisition... dimensions), as noted in the Analytics Help Center, can only be queried for App Views

Why is angularjs code slow?

Is it normal, that angularjs ng-repeat takes 1.5 Seconds to render data from an rest api? The result consists of only 10 rows with in total 1KB of data. How can I improve the speed or where to look for the problem?
ADDED INFOS:
The rest request itself only takes 128ms if I run it directly on the browser.
This is a set of sample data you get from the rest api:
{
"result": [
{
"id": 1224,
"name": "Schokolade-Vanille",
"kcal": 35500,
"displayName": "Schokolade-Vanille"
},
{
"id": 23423,
"name": "Naturreis Uncle Bens",
"kcal": 34400,
"displayName": "Naturreis Uncle Bens"
},
{
"id": 123231,
"name": "Paprikahendl",
"kcal": 4100,
"displayName": "Paprikahendl"
},
{
"id": 434,
"name": "Vanille Kugeln",
"kcal": 53700,
"displayName": "Vanille Kugeln"
},
{
"id": 323423,
"name": "Weihnachtstraum, Lindor-Kugeln",
"kcal": 60800,
"displayName": "Lindor-Kugeln"
},
{
"id": 5435,
"name": "Schokolade",
"kcal": 4300,
"displayName": "Schokolade"
},
{
"id": 23213,
"name": "Hühner-Nuggets",
"kcal": 23400,
"displayName": "Hühner-Nuggets"
},
{
"id": 5534,
"name": "Knödel, Kartoffel",
"kcal": 1230,
"displayName": "Knödel, Kartoffel"
},
{
"id": 23233,
"name": "Curvers",
"kcal": 15400,
"displayName": "Curvers"
},
{
"id": 53434,
"name": "Frites Original",
"kcal": 14100,
"displayName": "Frites Original"
}
],
"count": 12854
}
NEW ADDED INFOS
I have had a closer look now and found out, that not te repeat funktion is the problem.
I used the following code:
$scope.updateResultset = function() {
$scope.result = Food.query({
offset: $scope.offset,
order_by: $scope.orderby,
name: $scope.textfilter,
},function(){
console.log( "response " + (new Date().getTime() - start) );
});
$scope.offset = undefined;
console.log( "updateResultset " + (new Date().getTime() - start) );start = new Date().getTime();
And get the following response:
response 435
But the request itself only takes 131ms. In my opinion, >300ms is a lot of time to waste in a single method?
Compared to my former version, where I showed a plan html list, which was replaced by jquery ajax response html, its much slower?
As others indicated in the comments, the cause in the code is likely something else aside from ng-repeat. However, here are other options to consider, if speed still seems like an issue for ng-repeat:
quick-ng-repeat directive on github: https://github.com/allaud/quick-ng-repeat
ng-scroll, as part of angular-ui: https://github.com/angular-ui/ui-utils/blob/master/modules/scroll/README.md
Ok, I found out the problem. Not the repeatition of the 10 list items was the problem! As you can see in my question, I return not only the 10 results, but also the total amount of results. In my case it was '"count": 12854'.
On the same page, I have a pagination which was the part which slows down the whole page, since it had to render 1286 pager buttons (~12854/10). Now I only show 10 pager-buttons.

Resources