Git Product home page Git Product logo

binance's Introduction

Binance API

  • a test task

Task:

"There is a Binance type crypto-exchange, the user wants to transfer historical data about his trading activity in read-only mode. We need to collect data through the API and output it to the console.

Requirements:

  • mysql database
  • table :credentials (key, secret) created through migration
  • VCR-tests for receiving data from Binance. If the API key is incorrect, write an error to the log.
  • go through all the credentials and pull data for each one.
  • the result should be a hash like this: {credential_id: 123, trades: [{date: 2018-10-11, type: 'BUY / SELL', price: 34, quantity: 10}], balances: []}"

Run the programme

ruby main.rb - runs the programme, it has some explanations and some commented code that perhaps may be useful

Testing

rspec spec/api_requests_spec.rb - runs the specs that test how requests for Binance api works:

  • ping call (public) just for checking connection with Binance API (there is no need API key and secret or any params)
  • three account endpoints (require some kind of params and signature) - included general tests on status 200 and class of returned object and tests for fields that are needed for response_hash

rspec spec/responce_processing_spec.rb - runs the specs which test ResponseProcessing class:

  • method #raw_response should raise an error in case invalid api_key or return response body in other case
  • method #response_hash shoud return a hash with appropriate structure (see in requirements)

binance's People

Contributors

rublen avatar

Watchers

 avatar  avatar

binance's Issues

> 400

Application.log(:error, "401 Unauthorized: #{response_body}") if response.status >= 400

вот тут совершенно точно все ошибки, включая 404, слипнутся в одну невразумительную

rubocop

Тут бы рубокопом пройтись, он явно будет жаловаться на отсутствие пробела перед комментом

validates :key, presence: true#, uniqueness: true

параметры

start_time: options[:start_time],

обязательные параметры лучше передавать не через **options, а в явном виде, например

def initialize(client, symbol_string, start_time, ...)

ну и последующее копирование выглядит сомнительно тоже

API

t[:type] = trade['isBuyerMaker'] ? 'Maker' : 'Taker'

Есть у меня предположение, что тут ты получаешь просто торги на бирже, а не историю конкретного юзера. Глубже проверить не успеваю :(

обработка ошибок

Application.log(:error, "401 Unauthorized: #{response_body}") if response.status == 401

Тут сразу два места для усовершенствований:

  • есть обработка ошибок только для 401, но их то может быть куда больше... Например, разрыв связи
  • если ошибка таки будет, то выполнение продолжится, только пользы от этого уже не будет. Почитай про exceptions плз

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.