API Wrapper for Spread City
the spread-city npm package is a nodejs wrapper for the spread city API
Install to your project with:npm install --save spread-city
First import and initialize a new instance of the API, provide your API key and Secret, you can generate keys here
``
const SpreadCityAPI = require('spread-city');
const myApiKey = '123';
const myApiSecret = '456';
const scAPI = new SpreadCityAPI(myApiKey, myApiSecret);
`
Then use the methods of the api object to make requests and get responses
`
const options = await await scAPI.getOptions();
console.log(options);
const instanceID = 'abcdef'
const executor = await scAPI.startInstance(instanceID);
console.log(executor);
`
see ./examples/example.js for full example code
#### config``
{
startQuote, // % change threshold for arbitrage
startUnwind, // flip direction to take profit while % change is above this threshold
maxPositionSize, //max position size in USD
deltaTolerance, // allowed difference between maker and taker positions before error (USD)
tickIncrement,
strategy, // strategy for placing limit orders ('hug' or 'ninja')
loopInterval, // time in between execution loops (milliseconds)
AtoB, // maker order direction
quoteSize, // order size (usd)
}
#### maker / taker``
{
id,
ticker,
testnet,
key,
secret,
keyPair, // id of a saved key pair to use (key/secret are ignored unless this param is null)
password, // password for the desired keyPair (only used if keyPair param is not null)
subaccount
}
#### Returns
``
{
id // id of the executor that has just been created
}
#### Returns
``
{
strategies: , // an array of strategy names ex: ['hug', 'ninja']
config: {...}, // the default configuration
exchanges [ // a list of all supported exchanges
{
name,
id, // ID of an exhange (usually exchange name but all lowercase)
supportTest, // boolean, whether the exchange has a testnet to connect to
supportSub, // boolean, whether the exchange supports subaccount name when creating instances
},
{ ... }
],
tickers: { // for every supported exchange, an array of all of the supported tickers (strings)
exchange1: [...],
exchange2: [...]
}
}
#### Returns
``
[
{
id, // executor ID,
config,
running: // boolean
},
{ ... }
]
#### id
The ID of the instance you would like to start
#### Returns
``
{
message // success message if executor has started
}
#### id
The ID of the instance you would like to start
#### Returns
``
{
message // success message if executor has started
}
#### id
The ID of the instance you would like to stop
#### Returns
``
{
message // success message if executor has stopped
}
#### instanceID
The ID of the instance you would like to set as a favorite
#### favName
The label you would like this favorited instance to hold
#### Returns
``
{
message // success message if favorite was saved
}
#### Returns
``
[
{
id, // executor ID
config,
status, // 'not started' / 'running' / 'destroyed'
fav, // name of fav (string), or null
},
{ ... }
]
#### Returns
``
[
{
id, // executor ID
config,
status, // 'not started' / 'running' / 'destroyed'
fav,
},
{ ... }
]
#### id
The ID of the instance you would like to set as a favorite
#### Returns
```
{
id,
config,
running, // boolean, whether the instance is running
}