Skip to content

Instantly share code, notes, and snippets.

@FagnerMartinsBrack
Last active November 29, 2021 05:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FagnerMartinsBrack/ff7537041bb3b80c09d0024a7c579411 to your computer and use it in GitHub Desktop.
Save FagnerMartinsBrack/ff7537041bb3b80c09d0024a7c579411 to your computer and use it in GitHub Desktop.
##An Open Source Trading Engine For Developers
This is a trading engine (examples in NodeJS) that allows developers to build their own algorithm on top of it. It provides an Event Bus (Engine) which is a service that starts a publish/subscribe model that accept functions. Each function represent a decision point that builds an action containing the buy/sell scores.
The purpose is to remove the burden of the developer to find the optimal architecture to decide when to buy/sell and allow them to just build their own algorithm.
For every tick from an implemented Exchange that returns a transaction, the developer defines one or more “buy” or “sell” score.
Engine.register((transaction) => {
return {
buy: 10, // score 1-100
sell: 30 // score 1-100
};
})
The action execution is done for every transaction that happens in an Exchange, not for every tick (if we use the polling model instead of the push model). This way the developer can decide based on that value which scores to add for buy/sell. For the MVP, it will be the responsibility of the developer to hold state of the transactions in order to make smart calculations.
After n transactions (or time), the system will calculate the average scores for the buy/sell of that pair. If the average score is greater than the threshold, it makes a decision to either buy or sell.
Problems yet to solve:
1. Is it useful to give to the developer the power to define the thresholds?
2. Shouldn't the system feed the scores to a neural network which then decides based on past results if it's a good moment to buy or sell? Are past results reliable? Maybe not?
Conceptual implementation example:
https://gist.github.com/FagnerMartinsBrack/c8ae7f0339d6a6b8dd880d76e6eb9104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment