<commit_before># Exchanges

*This is a technical document about adding a new exchange to Gekko and Gekko Broker.*

Gekko arranges all communication about when assets need to be bought or sold between the *strategy* and *Gekko Broker*. All differences between the different API's are abstracted away just below Gekko Broker inside an "exchange wrapper". This document describes all requirements for adding a new exchange wrapper (adding exchange support to Gekko).

## Gekko's expectations

When you add a new exchange to Gekko you need to expose an object that has methods to query the exchange. This exchange file needs to reside in `gekko/exchange/wrappers` and the filename is the slug of the exchange name + `.js`. So for example the exchange for Bitstamp is explained in `gekko/exchange/wrappers/poloniex.js`.

It is advised to use a npm module to query an exchange. This will separate the abstract API calls from the Gekko specific stuff (In the case of Bitstamp there was no module yet, so I [created one](https://www.npmjs.com/package/bitstamp)).

Finally Gekko needs to know how it can interact with the exchange, so add a static method `getCapabilities()` that returns it's properties. They are all described [here](#capabilities).

## Gekko Broker's expectations

*If this documentation is not clear it please look at the examples in `gekko/exchange/wrappers/`.*

Gekko Manager implements an exchange like so:

    var Exchange = require('./wrapper' + [exchange slug]);
    this.exchange = new Exchange({key: '', secret: '', username: '', currency: 'USD', asset: 'BTC'});

It will run the following methods on the exchange object:<commit_msg>use binance as example case, fix #2322<commit_after># Exchanges

*This is a technical document about adding a new exchange to Gekko and Gekko Broker.*

Gekko arranges all communication about when assets need to be bought or sold between the *strategy* and *Gekko Broker*. All differences between the different API's are abstracted away just below Gekko Broker inside an "exchange wrapper". This document describes all requirements for adding a new exchange wrapper (adding exchange support to Gekko).

## Gekko's expectations

When you add a new exchange to Gekko you need to expose an object that has methods to query the exchange. This exchange file needs to reside in `gekko/exchange/wrappers` and the filename is the slug of the exchange name + `.js`. So for example the exchange for Binance is explained in `gekko/exchange/wrappers/binance.js`.

It is advised to use a npm module to query an exchange. This will separate the abstract API calls from the Gekko specific stuff (In the case of Bitstamp there was no module yet, so I [created one](https://www.npmjs.com/package/bitstamp)).

Finally Gekko needs to know how it can interact with the exchange, so add a static method `getCapabilities()` that returns it's properties. They are all described [here](#capabilities).

## Gekko Broker's expectations

*If this documentation is not clear it please look at the examples in `gekko/exchange/wrappers/`.*

Gekko Manager implements an exchange like so:

    var Exchange = require('./wrapper' + [exchange slug]);
    this.exchange = new Exchange({key: '', secret: '', username: '', currency: 'USD', asset: 'BTC'});

It will run the following methods on the exchange object:
{'fraction_non_alphanumeric': 0.07149294082306999, 'fraction_numerical': 0.0012015620306398318, 'mean_word_length': 4.6155143338954465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1343973', 'n_tokens_mistral': 889, 'n_tokens_neox': 851, 'n_words': 475}