Coder Social home page Coder Social logo

btg-hb-api's Introduction

BTGPactual Home Broker 3rd party api

This is a Python api to connect with BTGPactual Web Home Broker. This api enables users to develop their own tools to support theirs trading strategies.

Configuration keys

Create config.json file, just like bellow:

{
  "SYMBOLS": ["?????"],
  "ACCOUNT": "?????",
  "TKNWF": "?????",
  "ENDPOINT": "wss://webfeeder.btgpactual.com/ws?reconnect="
}

replace "?????" accordingly:

KEY VALUE
SYMBOLS Symbols to be monitored
ACCOUNT Your BTG account number
TKNWF Web Home Broker Token
ENDPOINT Websocket URL

AggregatedBookType example

BID # BID QTY BID $ ASK $ ASK QTY ASK #
1 100.0 98.45 98.5 200.0 2
1 3000.0 98.43 98.54 3500.0 1
... ... ... ... ... ...
3 300.0 98.25 98.7 900.0 4
1 100.0 98.24 98.75 400.0 4

BusinessBookType example

QTY PRICE BUY TIME SELL AGRESSOR
700 22.39 40 Mar 7, 2021 6:11:23 PM 3 I
1000 22.39 40 Mar 7, 2021 6:11:23 PM 1099 I
... ... ... ... ... ...
3000 22.39 40 Mar 7, 2021 6:11:23 PM 386 I
1500 22.39 40 Mar 7, 2021 6:11:23 PM 1099 I

AggregatedBookAnalytics

ANALYTIC RESULT
Bid/Ask Spread $ 0.040
Book depth 15
Book Imbalance -0.016
Balance Ask % 0.508
Weighted Ask $ 22.736
Best Ask $ 22.42
Weighted Price $ 22.474
Weighted Mid Price $ 22.400
Middle Price $ 22.400
Best Bid $ 22.38
Weighted Bid $ 22.209
Balance Bid % 0.492

Broker ranking example

BROKER_ID BROKER_NAME NET QTY AGRESSOR
8 UBS Brasil. CCTVM 18747882.0 2765200 2301
3 XP INVESTIMENTOS CCTVM S.A -52130499.0 2330000 2925
13 MERRILL LYNCH S.A. CTVM -25250738.0 2119500 614
120 BRASIL PLURAL -1282870.0 1462400 1454
1618 IDEAL 9834157.0 1289700 1266
45 CREDIT SUISSE BRASIL S.A. CTVM 91518926.0 1216700 4122
85 BTG PACTUAL CTVM S.A 41743156.0 1074500 1004
40 MORGAN STANLEY D. W. CTVM S.A. -32823650.0 971200 859
77 CITIGROUP -55768921.0 865100 693
72 BRADESCO S.A. CTVM -10668241.0 630900 634
114 ITAU CV S/A -25425228.0 542300 1246
308 CLEAR CTVM LTDA -121657.0 480100 1579
386 OCTO CTVM S/A -3119380.0 384400 733
39 AGORA CTVM S.A. -1111680.0 269000 256
238 GOLDMAN SACHS DO BRASIL CTVM 6045594.0 191400 371
27 SANTANDER S.A. CCT -4072337.0 177200 106
129 PLANNER CV S.A 15209280.0 177100 221
23 NECTON 10825699.0 145800 187
16 J. P. MORGAN CCVM S.A. -557135.0 134100 144
1982 MODAL DTVM 1203867.0 127800 380

Widgets for Limit Order Book statistics

lob widget

Troubleshooting

  • update TKNWF token and restart connection
{'message': 'Usuário não autorizado ou token inválido.', 'code': 111}

Reference

btg-hb-api's People

Contributors

mygs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.