Coinbase API v2 Getting Historic Price for Multiple Days - bitcoin

I'm having some trouble with a Coinbase.com API call for historical data.
Previously, I was getting a variable length of days that would match the amount of space available on a terminal screen with a request URL that looked like this:
https://api.coinbase.com/v2/prices/historic?currency=USD&days=76
This would pull the previous 76 days of price history. An example of the old output is here:
https://gist.github.com/KenDB3/f071a06ab3ef1a899d3cd8df8b40a049#file-coinbase-historic-days-example-2017-12-23-json
This stopped working a few days ago. The closest I can get to this is with this request URL (though I don't get the data I want):
https://api.coinbase.com/v2/prices/BTC-USD/historic?days=76
The output from this can be seen here:
https://gist.github.com/KenDB3/f071a06ab3ef1a899d3cd8df8b40a049#file-coinbase-historic-days-example-2018-07-19-json
In the second example, it is just displaying prices from the day of the query at different times of that day. What I really want is the first example output where it gives a single price per day going back as many days as the request is for.
The project this is connected to is here:
https://github.com/KenDB3/SyncBTC
Links that do not work:
https://api.coinbase.com/v2/prices/historic?currency=BTC-USD&days=76
(No Results)
https://api.coinbase.com/v2/prices/BTC-USD/historic?2018-07-15T00:00:00-04:00
(Does not pull data from 7/15/2018)

Any reason you aren't using coinbase pro?
The new api is very easy to use. Simply add the get command you want followed by the parameters separated with a question mark. Here is the new historic rates api documentation:
https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles
The get command with the new api most similar to prices is "candles". It requires three parameters to be identified, start and stop time in iso format and granularity which is in seconds. Here is an example:
https://api.pro.coinbase.com/products/BTC-USD/candles?start=2018-07-10T12:00:00&end=2018-07-15T12:00:00&granularity=900
EDIT: also, note the time zone is not for your time zone, I believe its GMT.

Here is a wrapper for the CoinBase API for the export of Historical Data: https://pypi.org/project/Historic-Crypto/
It should provide the required outcome through invoking:
pip install Historic-Crypto
from Historic_Crypto import HistoricalData
new = HistoricalData('ETH-USD',300,'2020-06-01-00-00').retrieve_data()
for a full list of cryptocurrencies available:
pip install Historic-Crypto
from Historic_Crypto import Cryptocurrencies
data = Cryptocurrencies(extended_output=False).find_crypto_pairs()

Related

OpenWeatherMap Get data for today

I am trying to create something similar to what the weather apps have which show a graph of the temperatures from today.
I am currently using the onecall endpoint which returns the current weather along with forecasts for the next 48 hours but this doesn't cover my case of showing earlier data from the day.
Am I miss using this endpoint or is there a way to show the data for the current day (both historical from earlier and forecast for later)? Or do I need to use the historical data endpoints?

How to get TeamCity builds statistics for last quarter(3 month) from API or DB(SQL)?

TeamCity issue tracker link https://youtrack.jetbrains.com/issue/TW-50234
I want to calc "builds" latency for last week and compare to avg. last month and avg. last quarter.
last month can be easelly fetch via REST API like so:
https://teamcity/app/rest/builds?locator=buildType:(id:<BUILD_ID>)&fields=count,build(number,status,queuedDate,finishDate)
Latest entrie from payload is 20170502T131511+0300
But how to fetch more data - for last 3 month?
I have access to SQL DB(We use PostgreSQL) and SQL is good solution.
You could come across paginaton of the response: try to include nextHref attribute of the response entity (builds) for items collections (i.e. use &fields=count,nextHref instead of just &fields=count and you'll probably get the link to the second page of the output).
It it is your case, following locator dimensions are available to control the number of the builds in response:
count:<number> - serve only the specified number of builds
start:<number> - list the builds from the list starting from the position specified (zero-based)
lookupLimit:<number> - limit processing to the latest N builds only (the default is 5000). If none of the latest N builds match the other specified criteria of the build locator, 404 response is returned
There should be no limitation of the output based on the date, but in case there're some clean up rules configured, there could be no data, obviously.

How do you get the ticket created date in trac?

I want to play with some really simple queries for a report, but I want to group everything by the creation date. The problem I am having is that time exists in the database, but not the date. From searching around in trac-related resources, it looks like I need to install trac.util.datefmt to be able to extract this information from datetime(time). I can find the API documentation for trac.util.datefmt, but not a download link to get the .egg.
Am I going in the right direction? If I can do what I need (i.e. get the creation month/day/year) without a plugin, what column do I use? I don't see anything else in the schema that is reasonable. If I do need trac.util.datefmt, where do I download it from? And if I really need a different plugin, which one should I be using?
I'll assume Trac >= 1.0. The time column is unix epoch time: the number of seconds that have elapsed since January 1st 1970. You can divide the value by 1e6 and put the value in a converter to see an example of extracting the datetime from the time column. trac.util.datefmt is part of the egg that ships with Trac, but since you are working with reports it doesn't sound like you need to know more about that function to accomplish your aim.
In a Trac report the time column will be automatically formatted as a date. You can look at the default report {1} as an example. I'm not sure how you intend to group by creation date. Do you wish to group tickets created in a certain datetime range?

Cross-project time-record filtering using Active Collab 5 API

For Active Collab team watching this tag.
I am working on a project that uses new Active Collab 5 API, I am having performance issue trying to run reports.
Example I try to build reports on date-range, and currently to achieve that I need to first run a call to get all projects.
Followed by a loop with this call:
API::get('/projects/'.$id.'/time-records/filtered-by-date?' . http_build_query(['from' => $from, 'to' => $to]))
However we have a large number of projects, in addition to high number of active projects we also need to filter Archived projects as well to get correct reports for billing.
Now I work with around 1500 projects in AC.
So I need to make 1500 API calls which takes a huge performance hit. Is there a way that you can possibly build something that would work along these lines.
API::get(/timerecords/filter-by-date);
with a possible passed parameter that will say (all, active, complited) project state.
Please let me know what you can do or if I have missed something in your documentation that already does this.
Thanks
What you need here is not a request that goes through all projects one by one, but a request that it tailored for cross-project reporting. Active Collab 5 has just the right API endpoint for that - /reports/run.
As an example, you can use this command to query time records and expenses from all active projects that were tracked today:
curl -H "X-Angie-AuthApiToken: YOUR-API-TOKEN" "http://your.activecollab.com/api/v1/reports/run?type=TrackingFilter&project_filter=active&tracked_on_filter=today"
Notice the route (/reports/run) and query arguments:
type - specify type of the report, in this case time and expense tracking report,
project_filter - specify project filter. Apart from active, other useful values of this filter are completed (for completed projects), selected_1,2,3,4 (selected projects with a list of project ID-s), client_1,2,3,4 (projects for clients with the given ID-s), category_1,2,3,4 (projects in categories with the given ID-s),
tracked_on_filter - filter by the date when records were tracked. To target a particular date use selected_date_YYYY-MM-DD and to target a date range use selected_range_YYYY-MM-DD:YYYY-MM-DD.
tracked_by_filter - filter by who tracked the time. It can have various values, like anybody, logged_user, selected_1,2,3.
To list only time records, set type_filter to time (or to expenses if you want only expenses to be listed).

Report of actuals entered by date

I need to pull out a report of the actuals that is being entered by each person in my team date-wise in the time span which I am allowed to specify. Its basically not for any accounting purposes but just to monitor the effort entered by each user on a day.
The closest thing I have found based on my preliminary search is the Weekly Actuals custom report(https://help.rallydev.com/weekly-actuals-report).
But it doesn't show the date-wise information. Is there any app already developed for my requirement or should I need to tweak the weekly actuals report?
Note: Not interested to install the time-tracker module since most of the users in my organization are used to tracking effort through actuals.
Rally LookbackAPI will give you historic data. You may write an app using shapshot store intended to retrieve data from the Lookback API.
Here is a LookbackAPI endpoint that returns snapshots where Actuals were updated:
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/111/artifact/snapshot/query.js?find={"Project":222,"_TypeHierarchy":"Task","_PreviousValues.Actuals":{$exists: true},_ValidFrom:{$gte: "2014-05-01T00:00:00.000Z",$lt: "2014-05-13T00:00:00.000Z"}}&fields=["_UnformattedID","Actuals","_PreviousValues.Actuals","_ValidFrom","_ValidTo"]
and an example of the returned result:
Results: [
{
_ValidFrom: "2014-05-12T17:08:27.598Z",
_ValidTo: "9999-01-01T00:00:00.000Z",
_UnformattedID: 157,
Actuals: 4,
_PreviousValues: {
Actuals: 0
}
}
]
where _ValidFrom: "2014-05-12T17:08:27.598Z" indicates the time when the snapshot was created - the Actuals was updated. Since this was the last change to Actuals on this task TA157, the _ValidTo is set to infinity. The result shows both the updated value (4) and previous value (0) of Actuals.
To try this endpoint make sure to change 111 and 222 with valid ObjectIDs of your workspace and project respectively.
There is a similar question about ToDo answered in this post.
It is possible to get some historic data by parsing revision history via Web Services API and looking for CreationDate on a revision where Actuals update was recorded. See 'side note' in this post. But this is expensive and inefficient.
Weekly Actuals is a legacy app based on AppSDK1. AppSDK1 cannot access LookbackAPI.