Coder Social home page Coder Social logo

py3cw's Introduction

py3cw

Upload Python Package

Unofficial wrapper for the 3Commas API written in Python.


How to install

pip install py3cw

How to use

from py3cw.request import Py3CW

# request_options is optional, as all the keys from the dict
# so you can only change what you want.
#
# default options for request_options are:
# request_timeout: 30s (30 for connect, 30 for read)
# nr_of_retries: 5
# retry_status_codes: [500, 502, 503, 504]
# retry_backoff_factor (optional): It allows you to change how long the processes will sleep between failed requests.
# For example, if the backoff factor is set to:
# 1 second the successive sleeps will be 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 256.
# 2 seconds - 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
# 10 seconds - 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560
# 
# NOTE: Nr of retries and retry_status_codes will also be used if we get 
# an falsy success from 3 commas (eg: { "error": { "status_code": 502 }})
p3cw = Py3CW(
    key='', 
    secret='',
    request_options={
        'request_timeout': 10,
        'nr_of_retries': 1,
        'retry_status_codes': [502],
        'retry_backoff_factor': 0.1
    }
)

# With no action
# Destruct response to error and data
# and check first if we have an error, otherwise check the data
error, data = p3cw.request(
    entity='smart_trades_v2',
    action=''
)

# With payload data
# Destruct response to error and data
# and check first if we have an error, otherwise check the data
error, data  = p3cw.request(
    entity='smart_trades_v2', 
    action='new', 
    payload={
        "account_id": 123456,
        ......
    }
)

# With action_id replaced in URL
# Destruct response to error and data
# and check first if we have an error, otherwise check the data
error, data = p3cw.request(
    entity='smart_trades_v2', 
    action='get_by_id',
    action_id='123456'
)

An entity represents main categories. Meaning, you have accounts, bots, marketplace, deals or smart_trades

An action is represented by a ... well, an action of a specific category. There are multiple actions you can use (check 3commas API)

action_id is used to replace the necessary account_id or bot_id or deal_id (you get the picture) needed on some actions. For example the action sell_all_to_btc requires the account_id (POST /ver1/accounts/{account_id}/load_balances)

payload is the data you send.

Forced mode header could be added with the parameter additional_headers. Allowed values are 'real' or 'paper'. E.g. ... additional_headers={'Forced-Mode': 'paper'} ...


3Commas API helpers.

3Commas Docs: https://github.com/3commas-io/3commas-official-api-docs

Accounts: https://github.com/3commas-io/3commas-official-api-docs/blob/master/accounts_api.md

Bots: https://github.com/3commas-io/3commas-official-api-docs/blob/master/bots_api.md

Deals: https://github.com/3commas-io/3commas-official-api-docs/blob/master/deals_api.md

Marketplace: https://github.com/3commas-io/3commas-official-api-docs/blob/master/marketplace_api.md

Grid Bots: https://github.com/3commas-io/3commas-official-api-docs/blob/master/grid_bots_api.md

Smart Trades: https://github.com/3commas-io/3commas-official-api-docs/blob/master/smart_trades_v2_api.md


Best used with Binance.

buy me a beer ๐Ÿบ

ETH: 0x0c2EA600d8bECE889F998D6a22332298E879940b

py3cw's People

Contributors

bogdanteodoru avatar sgerodes avatar bahlawi89 avatar cj4c0b1 avatar saintpepsi avatar moutikabdessabour avatar carkod avatar dmonllao avatar matsoftware avatar cyberjunky avatar dmkeys12 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.