profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/Cattes/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

Cattes/coinbasepro-python 0

The unofficial Python client for the Coinbase Pro API

Cattes/datatable 0

A Python package for manipulating 2-dimensional tabular data structures

Cattes/poetry 0

Python dependency management and packaging made easy.

Cattes/zls 0

Zig LSP implementation + Zig Language Server

INWTlab/filediffs 0

Python package for getting file differences.

issue closedteleprint-me/coinbasepro-python

Get more than 300 candles

Hi @teleprint-me,

great rework on the abandonned original package 👍 Especially the generator approach that lets you get as many pages as you want is really convenient!

For initializing a database I want to getall candles since January 2020, but the cbpro.PublicClient.products.history() method returns only a message, that that is not possible (the default behaviour of the coinbase Pro API). Do you have a plan already on how to approach this?

Here is a reproduceable example:


from datetime import datetime
import cbpro

base_url = "https://api-public.sandbox.pro.coinbase.com"
messenger = cbpro.Messenger(url=base_url)
public = cbpro.PublicClient(messenger)

start = datetime(2020, 1, 1, 0, 0, 0, 0)
end = datetime.now()
granularity = 86400
params = {"start": start.isoformat(), "end": end.isoformat(), "granularity": granularity}

product_id = "BTC-EUR"
history = public.products.history(product_id, params)
# {"message": "granularity too small for the requested time range. Count of aggregations requested exceeds 300"}

closed time in 3 months

Cattes

issue commentteleprint-me/coinbasepro-python

Get more than 300 candles

The feature got implemented with PR: https://github.com/teleprint-me/coinbasepro-python/pull/6 Documentation can be found at https://github.com/teleprint-me/coinbasepro-python#cbpropublichistorycandles

Cattes

comment created time in 3 months

push eventCattes/datatable

Cattes

commit sha 5c6369a49b9876e409610c274d28155efa78c11c

first try on fexpr_gcd.cc that is not working

view details

Cattes

commit sha 8724d6e8df6cd9e231c74e342c85e7bd9d011365

working fexpr_gcd.cc

view details

Cattes

commit sha 96d399bf330d11b7379b8a2f7b09215c32f60617

add comments to fexpr_gcd.cc

view details

push time in 3 months

pull request commentteleprint-me/coinbasepro-python

Feature/4 get more than 300 candles

I'm okay with adding iso8601 as a dep. it leaves the interface intact and doesn't require any changes to what the methods expect which avoids a lot of the pitfalls of doing otherwise.

Alright. I agree, and it is much more fault tolerant than my crude function.

just make sure to update the minor and revision version and add your handle or name to the contributors.txt if you want credit for your contribution. that way I can merge your addition into the master branch.

I updated the version from 2.1.28 to 2.2.0 and updated the contributors.txt

I'll add a tag and we can watch to see how things play out for others interested in using History class. I can also add it to the docs at some point.

I was thinking about creating a docs directory and adding markdown files for each topic in that directory instead of just having one massive readme.

I added a section to the long readme for the History class with an example.

I'm just focused on my web app at the moment and that's taking higher priority right now. I'm only able to work on it a few days a week, so most of my free time is being spent on that.

thanks also for taking the time to put all this together. any future contributions are always more than welcome. lmk if you're interested in becoming a maintainer. I could use the help. I wasn't planning on taking over for this project and am in kind of an awkward situation 🙃.

I just happened to see something that could be improved and wanted to contribute back to the original project. things haven't really played out the way I expected. I'm still hoping to hear back from the original dev to see what they want to do.

if I do take over at some point, then I'm going to need help to keep up with it. that's just the reality of the situation.

Yes I also hope the original project owner will resurface and take over again. I am not yet familiar with working with websockts and hope to gather experience with them using this project. If I find other Issues or feature requests I will open a ticket for them 🙂

As for helping to maintain the package, I have limited time too but I would be happy to gather some more experience contributing to the open source community.

Cattes

comment created time in 3 months

push eventCattes/coinbasepro-python

Cattes

commit sha 2b85be649eedc5e3b08666280fadaa3c73bb037f

#4 update version and contributors.txt

view details

push time in 3 months

issue openedh2oai/datatable

Contributing Example Outdated

Hello Everyone, I think the creating a new FExpr development guideline page is outdated.

For example, the stype header file had to be added, which is not in the guide. (Without #include "stype.h" for example, the line case SType::INT32: return make<int32_t>(std::move(a), std::move(b), SType::INT32); is not compiling.

It would be great if the page could end with a finished file that compiles and shows everything needed to create a new FExpression in a compact way.

I already put together a file that is compiling:

#include "_dt.h"
#include "expr/fexpr_func.h"
#include "expr/eval_context.h"
#include "expr/workframe.h"
#include "column/virtual.h"
#include "python/xargs.h"
#include "stype.h"


namespace dt {
namespace expr {


class FExpr_Gcd : public FExpr_Func {
  private:
    ptrExpr a_; // ptrExpr means that the input is also an f expression
    ptrExpr b_; // for col.isin I need one f expression and one Iterable. Type conversion will be a problem though.

  public:
    std::string repr() const override;
    Workframe evaluate_n(EvalContext& ctx) const override;
    FExpr_Gcd(ptrExpr&& a, ptrExpr&& b): a_(std::move(a)), b_(std::move(b)) {}

};

std::string FExpr_Gcd::repr() const {
  std::string out = "gcd(";
  out += a_->repr();
  out += ", ";
  out += b_->repr();
  out += ')';
  return out;
}


template <typename T>
class Column_Gcd : public Virtual_ColumnImpl {
  private:
    Column acol_;
    Column bcol_;

  public:
    Column_Gcd(Column&& a, Column&& b)
      : Virtual_ColumnImpl(a.nrows(), a.stype()),
        acol_(std::move(a)), bcol_(std::move(b))
    {
      xassert(acol_.nrows() == bcol_.nrows());
      xassert(acol_.stype() == bcol_.stype());
      xassert(acol_.can_be_read_as<T>());
    }

    ColumnImpl* clone() const override {
      return new Column_Gcd(Column(acol_), Column(bcol_));
    }

    size_t n_children() const noexcept { return 2; }
    const Column& child(size_t i) { return i==0? acol_ : bcol_; }

    bool get_element(size_t i, T* out) {
      T a, b;
      bool avalid = acol_.get_element(i, &a);
      bool bvalid = bcol_.get_element(i, &b);
      if (avalid && bvalid) {
        while (b) {
          T tmp = b;
          b = a % b;
          a = tmp;
        }
        *out = a;
        return true;
      }
      return false;
    }
};

template <typename T>
Column make(Column&& a, Column&& b, SType stype0) {
  a.cast_inplace(stype0);
  b.cast_inplace(stype0);
  return Column(new Column_Gcd<T>(std::move(a), std::move(b)));
}

Column evaluate1(Column&& a, Column&& b) {
  SType stype1 = a.stype();
  SType stype2 = b.stype();
  SType stype0 = common_stype(stype1, stype2);
  switch (stype0) {
    case SType::BOOL:
    case SType::INT8:
    case SType::INT16:
    case SType::INT32: return make<int32_t>(std::move(a), std::move(b), SType::INT32);
    case SType::INT64: return make<int64_t>(std::move(a), std::move(b), SType::INT64);
    default:
        throw TypeError() << "Invalid columns of types " << stype1 << " and " << stype2;
  }
}


Workframe FExpr_Gcd::evaluate_n(EvalContext& ctx) const {
  Workframe awf = a_->evaluate_n(ctx);
  Workframe bwf = b_->evaluate_n(ctx);
  if (awf.ncols() == 1) awf.repeat_column(bwf.ncols());
  if (bwf.ncols() == 1) bwf.repeat_column(awf.ncols());
  if (awf.ncols() != bwf.ncols()) {
    throw TypeError() << "Incompatible number of columns in " << repr()
        << ": the first argument has " << awf.ncols() << ", while the "
        << "second has " << bwf.ncols();
  }
  awf.sync_grouping_mode(bwf);

  auto gmode = awf.get_grouping_mode();
  Workframe outputs(ctx);
  for (size_t i = 0; i < awf.ncols(); ++i) {
    Column rescol = evaluate1(awf.retrieve_column(i), bwf.retrieve_column(i));
    outputs.add_column(std::move(rescol), std::string(), gmode);
  }

  return outputs;
}

//------------------------------------------------------------------------------
// Python interface
//------------------------------------------------------------------------------

static const char* doc_gcd_astype =
R"(as_type(cols, new_type)
--
.. xfunction:: datatable.gcd
    :src: src/core/fexpr/fexpr_gcd.cc py_gcd
    :tests: tests/expr/test-gcd.py
    :cvar: doc_gcd
    :signature: gcd(a, b)

    Compute the greatest common divisor of `a` and `b`.

    Parameters
    ----------
    a, b: FExpr
        Only integer columns are supported.

    return: FExpr
        The returned column will have stype int64 if either `a` or `b` are
        of type int64, or otherwise it will be int32.)";

static py::oobj py_gcd(const py::XArgs& args) {
  auto a = args[0].to_oobj();
  auto b = args[1].to_oobj();
 return PyFExpr::make(new FExpr_Gcd(as_fexpr(a), as_fexpr(b)));
}

DECLARE_PYFN(&py_gcd)
    ->name("gcd")
    ->docs(doc_gcd_astype)
    ->arg_names({"a", "b"})
    ->n_positional_args(2)
    ->n_required_args(2);

}} // dt::expr

Sadly I am not an expert in C++ so it is not yet a real working example. It compiles, but I get an error message in python that is not very helpful... NotImplementedError: Cannot retrieve int32 values from a column of type int32. Has anyone an Idea what is going wrong? I get the error running the following code:

from datatable import dt, f, gcd

DT = dt.Frame(A=[1, 2, 3, 4, 5])
RES = DT[:, gcd(f.A, f.A)]

A final working example file at the end of the guide would be of great help for new developers.

Since I am new to working with C++ I already apologize in advance if the tutorial isn't outdated and I am just not familiar enough with C++ to understand it correctly. It would be great if the tutorial would end with a "Here is a final file that works when we put all the explanations above together" part.

Also sorry if "Feature request" is not the right Issue category, it felt wrong to put an outdaten documentation into a "Bug report" Issue category.

created time in 3 months

pull request commentteleprint-me/coinbasepro-python

Feature/4 get more than 300 candles

[...] the con to this is it would create another dependency.

Yes that is why I did not add arrow or another library first, but added a custom function for parsing. But the custom function has more weaknesses than just using an external library.

So if you are ok with an external library we can keep the current solution.

Otherwise we could keep my dt_string_to_datetime function from this commit https://github.com/teleprint-me/coinbasepro-python/pull/6/commits/7198e9ef2f3ee05c33d6402a9491cee91c3c870d

Or move away from the current way of expecting a string from the uer and for the History class the user would have to supply a datetime.datetime object directly.

You can decide.

Cattes

comment created time in 3 months

push eventCattes/coinbasepro-python

Cattes

commit sha da475eeba7600c631f8777607ba4a96b5aef5769

#4 add tzinfo to test because iso8601.parse_date adds utc tzinfo

view details

push time in 3 months

push eventCattes/coinbasepro-python

Cattes

commit sha 3c90cbabc4aeeb10407dcff2b25c819c50d38056

#4 add comma

view details

push time in 3 months

push eventCattes/coinbasepro-python

Cattes

commit sha c451df2ac294b054a62ac579de87c96e860b6bdd

#4 use iso8601 library for input processing

view details

push time in 3 months

push eventCattes/coinbasepro-python

Cattes

commit sha 7198e9ef2f3ee05c33d6402a9491cee91c3c870d

#4 Add dt_string_to_datetime function to be python3.6 compatible; add README.md section

view details

push time in 3 months

pull request commentteleprint-me/coinbasepro-python

Feature/4 get more than 300 candles

The easiest solution would be to expect the start and end values as datetime.datetime objects and not isoformatted strings which I transform to datetime. But this would break from the example in the readme that all work with isoformatted strings(which is matching the input the cbpro api expects)

Cattes

comment created time in 3 months

pull request commentteleprint-me/coinbasepro-python

Feature/4 get more than 300 candles

Hi, sry I did not check the CICD pipeline after creating the PR.

It seems the datetime.datetime.fromisoformat was only implemented in python 3.7, which is why the build is failling for python3.6. I only tested it locally with python3.8 where the CICD pipeline is also succeeding here.

I will have a look at it and modify the code so that it also works for python3.6

Cattes

comment created time in 3 months