Git Product home page Git Product logo

orionx-api-client's Introduction

orionx-api-client

Orionx Api Client es un cliente que permite manejar operaciones en la plataforma de exchange orionx.io

Permite realizar transacciones y mostrar informacion del mercado consultando un endpoint con graphql

pypi

Instalación

Para instalar, usar pip:

$ pip install --upgrade orionx-api-client

Versiones

La librería soporta Python 2.7, 3.4, 3.5, y 3.6.

Ejemplo

Para ejecutar los ejemplos se requieren las API Key y Secret Key que se puede obtener siguiendo estas instrucciones.

# This file is located at: examples/using_manager.py

from orionxapi import client
from pygql import gql
from pygql.dsl import DSLSchema

api_key = 'API_KEY'
secret_key = 'SECRET_KEY'
client = client(api_key, secret_key)

ds = DSLSchema(client)

query_dsl = ds.Query.marketStats.args(
                marketCode="CHACLP",
                aggregation="h1"
              ).select(ds.MarketStatsPoint.open)

print(ds.query(query_dsl))

# marketOrderBook
query = gql('''
  query getOrderBook($marketCode: ID!) {
    orderBook: marketOrderBook(marketCode: $marketCode, limit: 50) {
      buy {
        limitPrice
        amount
        __typename
      }
      sell {
        limitPrice
        amount
        __typename
      }
      spread
      __typename
    }
  }
''')

params = {
  "marketCode": "CHACLP"
}

operation_name = "getOrderBook"

print(client.execute(query, variable_values=params))
  • Para ejecutar mutations usar: ds.mutation(query_dsl)
  • Para ejecutar queries usar: ds.query(query_dsl)
  • Se pueden usar diccionarios en los argumentos para especificar objetos
  • La funcionalidad de DSL es lograda gracias a gql (https://github.com/itolosa/pygql)

Query Batching

Es posible acelerar las consultas realizándolas simultaneamente usando el parametro use_batching=True:

from orionxapi import client, as_completed
from pygql import gql
from pygql.dsl import DSLSchema

api_key = 'API_KEY'
secret_key = 'SECRET_KEY'

client = client(api_key, secret_key, use_batching=True)

ds = DSLSchema(client)

query = gql('''
  query getOrderBook($marketCode: ID!) {
    orderBook: marketOrderBook(marketCode: $marketCode, limit: 50) {
      buy {
        limitPrice
        amount
        __typename
      }
      sell {
        limitPrice
        amount
        __typename
      }
      spread
      __typename
    }
  }
''')

params = {
  "marketCode": "CHACLP"
}

operation_name = "getOrderBook"

print(client.execute(query, variable_values=params).data)

Para más detalles véase examples/using_batcher.py

Implementación basada en: https://dev-blog.apollodata.com/query-batching-in-apollo-63acfd859862

orionx-api-client's People

Contributors

itolosa avatar jmarenas avatar

Watchers

James Cloos avatar

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.