This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Coygo, SUPPORTED_EXCHANGE_IDS } from 'coygo-api'; | |
const coygo = new Coygo({ | |
apKey: '<coygo api key>', | |
exchanges: [ | |
{ | |
exchangeId: SUPPORTED_EXCHANGE_IDS.KRAKEN, | |
apikey: '<kraken api key>', | |
apiSecret: '<kraken api secret>' | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// configure basic information about your bot strategy | |
coygo.configure({ | |
// which types of orders this strategy supports | |
orderTypes: [ | |
coygo.orderTypes.market, // this indicates your strategy uses market orders | |
coygo.orderTypes.limit // this indicates your strategy uses limit orders | |
] | |
}); | |
// Create configurable input values for this Strategy. On the "Configure" screen you can use | |
// an interface to set these to whatever you'd like. This allows you to re-use the same Strategy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// configure basic information about your bot strategy | |
coygo.configure({ | |
// which types of orders this strategy supports | |
orderTypes: [ | |
coygo.orderTypes.limit // this indicates your strategy uses limit orders | |
] | |
}); | |
// Create configurable input values for this Strategy. On the "Configure" screen you can use | |
// an interface to set these to whatever you'd like. This allows you to re-use the same Strategy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Determine if orders should be submitted or cancelled | |
*/ | |
let shouldSubmitBuyOrder = false; | |
let shouldCancelBuyOrder = false; | |
let shouldSubmitSellOrder = false; | |
let shouldCancelSellOrder = false; | |
// determine if it's time to submit or cancel the buy order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Submit or cancel orders when appropriate | |
*/ | |
// handle submiting or canceling the buy order when instructed | |
if (shouldSubmitBuyOrder) { | |
// calculate the buy order rate using configured inputs | |
// example: if "ask" is 100 and "buyRatePercentBelowAskInput" is 2, buyOrderRate = 100 * (1 - (2 / 100) = 98 | |
let buyOrderRate = orderBook.ask * (1 - (buyRatePercentBelowAskInput / 100)); |