-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
620 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"kraken": { | ||
"BTC-EUR": { | ||
"accounts": [ | ||
"user1", | ||
"user2" | ||
], | ||
"algorithmName": "example-trader", | ||
"repeatTime": "5s", | ||
"baseStartAmount": "0.5BTC", | ||
"quoteStartAmount": "50%EUR", | ||
"stopCriteria": [ | ||
{ | ||
"type": "duration", | ||
"value": "4h" | ||
}, | ||
{ | ||
"type": "protectLoss", | ||
"value": "-30%" | ||
}, | ||
{ | ||
"type": "secureProfit", | ||
"value": "80%" | ||
} | ||
] | ||
}, | ||
"ETH-EUR": { | ||
"accounts": [ | ||
"user1" | ||
], | ||
"algorithmName": "example-trader", | ||
"repeatTime": "3s", | ||
"baseStartAmount": "45ETH", | ||
"quoteStartAmount": "50%EUR", | ||
"stopCriteria": [ | ||
{ | ||
"type": "duration", | ||
"value": "4h" | ||
}, | ||
{ | ||
"type": "protectLoss", | ||
"value": "-30%" | ||
}, | ||
{ | ||
"type": "secureProfit", | ||
"value": "80%" | ||
} | ||
] | ||
} | ||
}, | ||
"binance": { | ||
"XRP-USDT": { | ||
"accounts": [ | ||
"user1" | ||
], | ||
"algorithmName": "example-trader", | ||
"repeatTime": "1s", | ||
"baseStartAmount": "50000.56XRP", | ||
"quoteStartAmount": "100%USDT", | ||
"stopCriteria": [] | ||
} | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
|
||
#include "auto-trade-config.hpp" | ||
#include "cct_const.hpp" | ||
#include "cct_fixedcapacityvector.hpp" | ||
#include "cct_smallvector.hpp" | ||
#include "cct_vector.hpp" | ||
#include "exchange-names.hpp" | ||
#include "exchangename.hpp" | ||
|
||
namespace cct { | ||
|
||
class AutoTradeOptions { | ||
public: | ||
using AccountAutoTradeOptionsPtrVector = | ||
SmallVector<const schema::AutoTradeExchangeConfig *, kTypicalNbPrivateAccounts>; | ||
|
||
struct MarketExchanges { | ||
Market market; | ||
ExchangeNames privateExchangeNames; | ||
const schema::AutoTradeMarketConfig *pMarketAutoTradeOptions{}; | ||
}; | ||
|
||
using MarketStatusVector = vector<MarketExchanges>; | ||
|
||
struct MarketExchangeOptions { | ||
MarketStatusVector marketStatusVector; | ||
}; | ||
|
||
struct PublicExchangeMarketOptions { | ||
ExchangeName publicExchangeName; | ||
MarketExchangeOptions marketExchangeOptions; | ||
}; | ||
|
||
using PublicExchangeMarketOptionsVector = FixedCapacityVector<schema::AutoTradeExchangeConfig, kNbSupportedExchanges>; | ||
|
||
AutoTradeOptions() noexcept = default; | ||
|
||
explicit AutoTradeOptions(schema::AutoTradeConfig &&autoTradeConfig); | ||
|
||
auto begin() const { return _autoTradeConfig.begin(); } | ||
auto end() const { return _autoTradeConfig.end(); } | ||
|
||
ExchangeNames exchangeNames() const; | ||
|
||
ExchangeNameEnumVector publicExchanges() const; | ||
|
||
AccountAutoTradeOptionsPtrVector accountAutoTradeOptionsPtr(std::string_view publicExchangeName) const; | ||
|
||
const schema::AutoTradeExchangeConfig &operator[](ExchangeNameEnum exchangeNameEnum) const; | ||
|
||
private: | ||
schema::AutoTradeConfig _autoTradeConfig; | ||
}; | ||
|
||
} // namespace cct |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <compare> | ||
#include <functional> | ||
|
||
#include "auto-trade-config.hpp" | ||
#include "cct_smallvector.hpp" | ||
#include "cct_vector.hpp" | ||
#include "exchange-names.hpp" | ||
#include "exchange.hpp" | ||
#include "market.hpp" | ||
#include "timedef.hpp" | ||
|
||
namespace cct { | ||
class AutoTradeOptions; | ||
|
||
class AutoTradeProcessor { | ||
public: | ||
explicit AutoTradeProcessor(const AutoTradeOptions& autoTradeOptions); | ||
|
||
struct SelectedMarket { | ||
ExchangeNames privateExchangeNames; | ||
Market market; | ||
}; | ||
|
||
using SelectedMarketVector = SmallVector<SelectedMarket, kTypicalNbPrivateAccounts>; | ||
|
||
SelectedMarketVector computeSelectedMarkets(); | ||
|
||
private: | ||
struct MarketStatus { | ||
ExchangeNames privateExchangeNames; | ||
Market market; | ||
TimePoint lastQueryTime; | ||
const schema::AutoTradeMarketConfig* pMarketAutoTradeOptions{}; | ||
}; | ||
|
||
using MarketStatusVector = vector<MarketStatus>; | ||
|
||
struct ExchangeStatus { | ||
MarketStatusVector marketStatusVector; | ||
const schema::AutoTradeExchangeConfig* pPublicExchangeAutoTradeOptions{}; | ||
}; | ||
|
||
using ExchangeStatusVector = SmallVector<ExchangeStatus, kTypicalNbPrivateAccounts>; | ||
|
||
ExchangeStatusVector _exchangeStatusVector; | ||
TimePoint _startTs = Clock::now(); | ||
TimePoint _ts{_startTs}; | ||
}; | ||
} // namespace cct |
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
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
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
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
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
Oops, something went wrong.