Contains the database collection prefix
Contains the database connections
Contains the MongoDB client
Contains the concatinated configuration from the config.yml and strategy.yml files
Contains the utilities class
Adds a 'global' log entry. These logs are not tied to a trade. For trade logs, use addTradeLog() instead.
The title of the log
The type of the log. This type isn't 'typed' so you can use whatever you want.
The data to store with the log
Adds order details to a trade and stores them in the database
The trade reference to get the trade for, this is a stringified mongo object id
The order id as it is returned by the exchange. Always stored as a string.
The type of the order (OrderDetailsType)
The status of the order (OrderDetailsStatus)
The details returned by the exchange
Adds a log entry for a trade. For log entries that are not tied to a trade, use addLog() instead.
The trade reference to get the trade for, this is a stringified mongo object id
The title of the log
The type of the log (TradeLogType)
The data to store with the log
Creates a new trade. This is used to track the state of a trade, along with other trade related data.
The exchange id
The symbol
The interval
The state
The direction
This method allows you to get any data from any collection. It will return an array of results that match the query from the collection specified.
You can override the database name if you want to query a different database that hold trade information from other bots.
The collection name
The query
The database name
Fetches a shortlist by id.
You can override the database name if you want shortlists from other bots.
The shortlist id
The query object
The sort object
The database name
Fetches multiple trades from the database, using a custom query.
This is a standard MongoDB query object. An example query would be:
{ "exchangeId": "binance", "symbol": "BTC/USDT" }
The query
The page number
The number of results per page
If the trades are historical or not
The number of hours back to fetch trades from
The field to sort by
This method allows you to set any data in any collection, in any database. It will look to existing data by the query, and if it exists, it will update it. If it doesn't exist, it will insert it.
The collection name
The query
The data to set
The database name
Sets data in collections in the database which are organized by keys. This can be any data which isn't related to a trade.
The key of the data to set
The value of the data to set
Updates the order details for a trade
The order id as it was returned by the exchange. Always stored as a string.
The status of the order (OrderDetailsStatus)
The details returned by the exchange
This class handles all database related tasks, such as connecting to the database, inserting, updating and deleting records.
Note that in this class, the terms and variables 'trade id', 'trade ref' are used interchangeably. They are the same thing, which is a stringified mongoDB ObjectId.
Active trades reside the 'trade' collection, and referenced by its _id field, while historical trades reside in the 'trade_historical' collection, and referenced by its trade_ref field.
Once a trade is recorded as a historical trade, the original active trade id is used as the trade ref in the historical trade collection.