Git Product home page Git Product logo

orionx-api-client's People

Contributors

itolosa avatar jmarenas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

orionx-api-client's Issues

Conector (usuario/contraseña) para API

La idea es hacer un helper que permita tomar usuario y contraseña del prompt y levantar un crawler o browser para hacer login en el sitio de orionx programáticamente. El helper debe dejar un prompt esperando al codigo de confirmación que es enviado al mail. Con esto se lograría hacer login completo en el sitio, y se pueden capturar los headers y setearlos en el cliente ya existente de forma automática sin interfaz gráfica.
Se puede usar requests con Session y headers (especialmente el user-agent). O bien modificar el siguiente código que esta probado que funciona bien como browser para sitios mañosos:

pip install --upgrade orionx-api-client (error)

Estimado Itolosa,

Tengo el siguiente error en la consola. Por favor me puedes guiar que puede ser:

[root@centos-s-4vcpu-XXXXX html]# pip install --upgrade orionx-api-client
Collecting orionx-api-client
Downloading orionx-api-client-1.0.5.tar.gz
Collecting requests==2.18.4 (from orionx-api-client)
Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
100% |████████████████████████████████| 92kB 3.8MB/s
Collecting six==1.11.0 (from orionx-api-client)
Downloading six-1.11.0-py2.py3-none-any.whl
Requirement already up-to-date: ujson==1.35 in /usr/lib64/python2.7/site-packages (from orionx-api-client)
Collecting graphql-core==2.0 (from orionx-api-client)
Downloading graphql_core-2.0-py2.py3-none-any.whl (202kB)
100% |████████████████████████████████| 204kB 3.0MB/s
Collecting pygql==0.1.4 (from orionx-api-client)
Downloading pygql-0.1.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-hdgRwW/pygql/setup.py", line 35, in
packages=find_packages(include=["pygql*"]),
TypeError: find_packages() got an unexpected keyword argument 'include'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-hdgRwW/pygql/

[root@centos-s-4vcpu-XXXXX html]# python --version
Python 2.7.5

Saludos y gracias!

Boris Durán R.

📄 Create docs for this project

Hello,

If you're interested in contributing to this project, would greatly appreciate your help in enhancing the documentation, whether it's for the code or its usage.

Greetings 🌱

AttributeError: 'module' object has no attribute 'Session'

Hi

I tried to run this code from inside node (using python-shell), also tried to execute using terminal as a python file:

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

api_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))

In both cases the following error happens

Traceback (most recent call last):
  File "/Users/orion/NODE/crypto_fire/functions/python/my.py", line 14, in <module>
    client = client(api_key, secret_key)
  File "/Users/orion/NODE/crypto_fire/functions/python/orionxapi/client.py", line 23, in client
    timeout=timeout
  File "/Users/orion/NODE/crypto_fire/functions/python/orionxapi/transport.py", line 86, in __init__
    super(CustomSessionTransport, self).__init__(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/pygql/transport/session_transport.py", line 16, in __init__
    self.session = requests.Session()
AttributeError: 'module' object has no attribute 'Session'

I am kind of noob in both python and graphql.

It would be awesome if you create a node module for this.
Thanks

Problema de conexión con api keys

Al hacer intentar hacer consultas que requieran conexión con cuenta personal a través de las api y secret key, devuelve error

error: {'message': 'No estas conectado [notLoggedIn]', 'path': ['placeLimitOrder'], 'details': {'code': 'notLoggedIn', 'reason': 'No estas conectado', 'errorType': 'userError'}}

en el archivo orionxapi/client.py cambié de url = 'https://api.orionx.io/graphql' a url = 'https://api2.orionx.io/graphql', y devuelve

502 Server Error: Bad Gateway for url: https://api2.orionx.io/graphql

from orionxapi import client, as_completed
from pygql import gql

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

results = []

# placeLimitOrder
query = gql('''
  mutation placeLimitOrder($marketCode: ID, $amount: BigInt, $limitPrice: BigInt, $sell: Boolean) {
    placeLimitOrder(marketCode: $marketCode, amount: $amount, limitPrice: $limitPrice, sell: $sell) {
      _id
      __typename
    }
  }
''')

params = {
  "marketCode": "CHACLP",
  "amount": 39602780,#con este valor resulto en pruebas
  "limitPrice": 30000,
  "sell": True
}

operation_name = "placeLimitOrder"

results.append(client.execute(query, variable_values=params))

# market
query = gql('''
  query getMarketIdleData($code: ID) {
    market(code: $code) {
      code
      lastTrade {
        price
        __typename
      }
      secondaryCurrency {
        code
        units
        format
        longFormat
        __typename
      }
      __typename
    }
  }
''')

params = {
  "code": "CHACLP"
}

operation_name = "getMarketIdleData"

results.append(client.execute(query, variable_values=params))

for result in as_completed(results):
  if result.errors:
    print("error:", result.errors[0])
  else:
    print('data:', result.data)

error con orionxapi/lib/dsl.py"

Hola!

Intentando usar el connection manager recibo el siguiente error:

Traceback (most recent call last):
  File "orionx_marginator2.py", line 1, in <module>
    from orionxapi.connection_manager import client, orionxapi_builder
  File "/Users/nijirija/Library/Python/2.7/lib/python/site-packages/orionxapi/connection_manager.py", line 8, in <module>
    from .lib.dsl import DSLSchema
  File "/Users/nijirija/Library/Python/2.7/lib/python/site-packages/orionxapi/lib/dsl.py", line 154
    def query(*fields, operation='query'):
                               ^
SyntaxError: invalid syntax

Se te ocurre qué puede ser?

Estoy con python 2.7 en Mac

Gracias!

Nombres/parámetros de las queries disponibles para DSL

Hola, estoy intentando usar este esquema para las queries, pero no esto seguro qué debería tomar como nombre de la query ni en al final en el .open

ds = DSLSchema(client)

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

print(ds.query(query_dsl))

Me funciona impeque el ejemplo, pero intentando seguir el esquema usando los nombres de las queries que están en examples/queries.graphql, siempre me falla:

Traceback (most recent call last):
  File "orionx_marginator3.py", line 24, in <module>
    ).select(ds.CurrenciesPoint.open)
  File "/usr/local/lib/python3.6/site-packages/pygql/dsl.py", line 45, in __getattr__
    formatted_name, field_def = self.get_field(name)
  File "/usr/local/lib/python3.6/site-packages/pygql/dsl.py", line 51, in get_field
    if name in self.type.fields:
AttributeError: 'NoneType' object has no attribute 'fields'

¿Qué debería estar usando?

API no soporta decimales

Tengo el siguiente código, bien simple:

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

#Orionx API
api_key = 'xxx'
secret_key = 'yyy'
client = client(api_key, secret_key)

# market
query = gql('''
  query getMarketIdleData($code: ID) {
    market(code: $code) {
      code
      lastTrade {
        price
      }
    }
  }
''')

params = {
  "code": "LTCBTC"
}

operation_name = "getMarketIdleData"

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


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

params = {
  "marketCode": "LTCBTC"
}

operation_name = "getOrderBook"
orionxValues = client.execute(query, variable_values=params)

print(orionxValues)
print(orionxValues["orderBook"]["buy"][0]["limitPrice"])
print(orionxValues["orderBook"]["sell"][0]["limitPrice"])

Sin embargo, la salida no me entrega decimales:

{'market': {'code': 'LTCBTC', 'lastTrade': {'price': 2699990}}}
{'orderBook': {'buy': [{'limitPrice': 1710001}], 'sell': [{'limitPrice': 6339999}]}}
1710001
6339999

La salida esperada es la siguiente:

{'market': {'code': 'LTCBTC', 'lastTrade': {'price': 0,02699990}}}
{'orderBook': {'buy': [{'limitPrice': 0,01710001}], 'sell': [{'limitPrice': 0,06339999}]}}
0,01710001
0,06339999

¿Hay algún bug en la API client?
¿Es problema de la API de OrionX o es el código el que tiene algo incorrecto?

AttributeError: 'module' object has no attribute 'Session'

I'm trying to use "examples/using_batcher.py" example with my keys and i'm not getting nowhere, I'm getting the following error:

Traceback (most recent call last):
  File "query.py", line 9, in <module>
    client = client(api_key, secret_key, use_batching=True)
  File "/home/danny/.local/lib/python2.7/site-packages/orionxapi/client.py", line 15, in client
    timeout=timeout
  File "/home/danny/.local/lib/python2.7/site-packages/orionxapi/transport.py", line 20, in __init__
    super(CustomBatchTransport, self).__init__(*args, **kwargs)
  File "/home/danny/.local/lib/python2.7/site-packages/pygql/transport/batch_transport.py", line 58, in __init__
    self.session = requests.Session()
AttributeError: 'module' object has no attribute 'Session'

I'm starting to think that this error has something to do with requests, so if i print the module path i get:

<module 'pygql.transport.requests' from '/home/danny/.local/lib/python2.7/site-packages/pygql/transport/requests.pyc'>

but, does not suppouse to be this one:

<module 'requests' from '/home/danny/.local/lib/python2.7/site-packages/requests/__init__.pyc'>

because if i try to use requests.Session() has to be this object, right ?

<requests.sessions.Session object at 0x7f2389f8a410>

so i think maybe there is something going on with " import requests " that don't recognize the file path or something like that, but still, if I try to use the requests that is outside of pygql i'm getting other error so maybe it's just me that i'm not doing thing properly, will be great if you could help to solve this

sorry :) i'm still a noob and i'm trying to understand how to fix my issue, maybe is not just puting keys and there is something that i'm not doing, thanks

Timeouts

Hola,
Me están saliendo hartos TimeOut. ¿No te pasa?

requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.orionx.io', port=443): Read timed out. (read timeout=5)

cache headers

Hola, ¿Cuál debería ser el contenido de cache/cookies.json y headers.json?

Ambos archivos no existen, pero no estoy seguro de como debería armarlos o en dónde buscar los correcto.

Traceback (most recent call last):
  File "orionx_test.py", line 6, in <module>
    cookies_filename='cache/cookies.json')
  File "/Library/Python/2.7/site-packages/orionxapi/connection_manager.py", line 31, in client
    except FileNotFoundError:
NameError: global name 'FileNotFoundError' is not defined

Gracias!

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.