-
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
25 changed files
with
620 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
|
||
#include "cct_fixedcapacityvector.hpp" | ||
#include "cct_json.hpp" | ||
#include "cct_smallvector.hpp" | ||
#include "cct_vector.hpp" | ||
#include "exchange-names.hpp" | ||
#include "exchangename.hpp" | ||
#include "public-exchange-auto-trade-options.hpp" | ||
|
||
namespace cct { | ||
|
||
class AutoTradeOptions { | ||
public: | ||
using AccountAutoTradeOptionsPtrVector = | ||
SmallVector<const PublicExchangeAutoTradeOptions *, kTypicalNbPrivateAccounts>; | ||
|
||
struct MarketExchanges { | ||
Market market; | ||
ExchangeNames privateExchangeNames; | ||
const MarketAutoTradeOptions *pMarketAutoTradeOptions{}; | ||
}; | ||
|
||
using MarketStatusVector = vector<MarketExchanges>; | ||
|
||
struct MarketExchangeOptions { | ||
MarketStatusVector marketStatusVector; | ||
}; | ||
|
||
struct PublicExchangeMarketOptions { | ||
ExchangeName publicExchangeName; | ||
MarketExchangeOptions marketExchangeOptions; | ||
}; | ||
|
||
using PublicExchangeMarketOptionsVector = FixedCapacityVector<PublicExchangeMarketOptions, kNbSupportedExchanges>; | ||
|
||
AutoTradeOptions() noexcept = default; | ||
|
||
explicit AutoTradeOptions(const json &data); | ||
|
||
auto begin() const { return _options.begin(); } | ||
auto end() const { return _options.end(); } | ||
|
||
ExchangeNames exchangeNames() const; | ||
|
||
PublicExchangeNameVector publicExchanges() const; | ||
|
||
AccountAutoTradeOptionsPtrVector accountAutoTradeOptionsPtr(std::string_view publicExchangeName) const; | ||
|
||
const PublicExchangeAutoTradeOptions &operator[](const ExchangeName &exchangeName) const; | ||
|
||
private: | ||
std::map<ExchangeName, PublicExchangeAutoTradeOptions> _options; | ||
}; | ||
|
||
} // 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 "cct_smallvector.hpp" | ||
#include "cct_vector.hpp" | ||
#include "exchange-names.hpp" | ||
#include "exchange.hpp" | ||
#include "market.hpp" | ||
#include "public-exchange-auto-trade-options.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 MarketAutoTradeOptions* pMarketAutoTradeOptions{}; | ||
}; | ||
|
||
using MarketStatusVector = vector<MarketStatus>; | ||
|
||
struct ExchangeStatus { | ||
MarketStatusVector marketStatusVector; | ||
const PublicExchangeAutoTradeOptions* 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
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,43 @@ | ||
#pragma once | ||
|
||
#include <span> | ||
#include <string_view> | ||
|
||
#include "auto-trade-stop-criterion.hpp" | ||
#include "cct_json.hpp" | ||
#include "cct_string.hpp" | ||
#include "cct_type_traits.hpp" | ||
#include "cct_vector.hpp" | ||
#include "monetaryamount.hpp" | ||
#include "timedef.hpp" | ||
|
||
namespace cct { | ||
|
||
class MarketAutoTradeOptions { | ||
public: | ||
explicit MarketAutoTradeOptions(const json &data); | ||
|
||
std::span<const string> accounts() const { return _accounts; } | ||
|
||
std::string_view algorithmName() const { return _algorithmName; } | ||
|
||
Duration repeatTime() const { return _repeatTime; } | ||
|
||
MonetaryAmount baseStartAmount() const { return _baseStartAmount; } | ||
|
||
MonetaryAmount quoteStartAmount() const { return _quoteStartAmount; } | ||
|
||
std::span<const AutoTradeStopCriterion> stopCriterion() const { return _stopCriteria; } | ||
|
||
using trivially_relocatable = is_trivially_relocatable<string>::type; | ||
|
||
private: | ||
vector<string> _accounts; | ||
string _algorithmName; | ||
Duration _repeatTime; | ||
MonetaryAmount _baseStartAmount; | ||
MonetaryAmount _quoteStartAmount; | ||
vector<AutoTradeStopCriterion> _stopCriteria; | ||
}; | ||
|
||
} // 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,12 @@ | ||
#pragma once | ||
|
||
#include <map> | ||
|
||
#include "market-auto-trade-options.hpp" | ||
#include "market.hpp" | ||
|
||
namespace cct { | ||
|
||
using PublicExchangeAutoTradeOptions = std::map<Market, MarketAutoTradeOptions>; | ||
|
||
} |
Oops, something went wrong.