├── Monitoring-Server ├── Front-End │ ├── src │ │ ├── vite-env.d.ts │ │ ├── assets │ │ │ └── images │ │ │ │ ├── logo.png │ │ │ │ └── balance-bg.png │ │ ├── App.tsx │ │ ├── index.css │ │ ├── components │ │ │ ├── loader │ │ │ │ ├── PageLoader.tsx │ │ │ │ └── Splash.tsx │ │ │ ├── base │ │ │ │ ├── Image.tsx │ │ │ │ ├── IconifyIcon.tsx │ │ │ │ └── ReactEchart.tsx │ │ │ ├── sections │ │ │ │ └── dashboard │ │ │ │ │ ├── top-cards │ │ │ │ │ ├── index.tsx │ │ │ │ │ ├── spent │ │ │ │ │ │ └── index.tsx │ │ │ │ │ ├── activity │ │ │ │ │ │ ├── index.tsx │ │ │ │ │ │ └── ActivityChart.tsx │ │ │ │ │ ├── earnings │ │ │ │ │ │ └── index.tsx │ │ │ │ │ └── Total_Trades │ │ │ │ │ │ ├── index.tsx │ │ │ │ │ │ └── ClientChart.tsx │ │ │ │ │ ├── total-spent │ │ │ │ │ └── index.tsx │ │ │ │ │ ├── earnings │ │ │ │ │ ├── index.tsx │ │ │ │ │ └── EarningsChart.tsx │ │ │ │ │ ├── spent-this-month │ │ │ │ │ └── index.tsx │ │ │ │ │ ├── transaction-history │ │ │ │ │ └── index.tsx │ │ │ │ │ ├── tasks │ │ │ │ │ └── index.tsx │ │ │ │ │ ├── credit-balance │ │ │ │ │ └── CreditBalanceChart.tsx │ │ │ │ │ ├── balance │ │ │ │ │ └── index.tsx │ │ │ │ │ └── transactions │ │ │ │ │ └── index.tsx │ │ │ └── common │ │ │ │ └── DataGridFooter.tsx │ │ ├── theme │ │ │ ├── styles │ │ │ │ ├── echart.ts │ │ │ │ ├── simplebar.ts │ │ │ │ └── scrollbar.ts │ │ │ ├── components │ │ │ │ ├── layout │ │ │ │ │ └── Stack.tsx │ │ │ │ ├── buttons │ │ │ │ │ ├── Toolbar.tsx │ │ │ │ │ ├── ButtonBase.tsx │ │ │ │ │ ├── IconButton.tsx │ │ │ │ │ └── Button.tsx │ │ │ │ ├── list │ │ │ │ │ ├── List.tsx │ │ │ │ │ ├── Collapse.tsx │ │ │ │ │ ├── ListItemIcon.tsx │ │ │ │ │ ├── ListItemText.tsx │ │ │ │ │ ├── ListItemButton.tsx │ │ │ │ │ └── MenuItem.tsx │ │ │ │ ├── data-display │ │ │ │ │ ├── Badge.tsx │ │ │ │ │ └── Chip.tsx │ │ │ │ ├── inputs │ │ │ │ │ ├── FilledInput.tsx │ │ │ │ │ ├── OutlinedInput.tsx │ │ │ │ │ ├── FormControlLabel.tsx │ │ │ │ │ ├── InputAdornment.tsx │ │ │ │ │ ├── Select.tsx │ │ │ │ │ ├── Checkbox.tsx │ │ │ │ │ └── InputBase.tsx │ │ │ │ ├── surfaces │ │ │ │ │ └── Paper.tsx │ │ │ │ ├── pagination │ │ │ │ │ └── PaginationItem.tsx │ │ │ │ ├── navigation │ │ │ │ │ ├── Drawer.tsx │ │ │ │ │ └── Link.tsx │ │ │ │ ├── utils │ │ │ │ │ └── CssBaseline.tsx │ │ │ │ └── data-grid │ │ │ │ │ └── DataGrid.tsx │ │ │ ├── shadows.ts │ │ │ ├── colors.ts │ │ │ ├── typography.ts │ │ │ └── palette.ts │ │ ├── routes │ │ │ ├── paths.ts │ │ │ ├── sitemap.ts │ │ │ └── router.tsx │ │ ├── pages │ │ │ ├── portfolio │ │ │ │ └── Portfolio.tsx │ │ │ └── dashboard │ │ │ │ └── Dashbaord.tsx │ │ ├── main.tsx │ │ └── layouts │ │ │ └── main-layout │ │ │ ├── index.tsx │ │ │ ├── sidebar │ │ │ ├── index.tsx │ │ │ ├── list-items │ │ │ │ ├── ListItem.tsx │ │ │ │ └── CollapseListItem.tsx │ │ │ └── DrawerItems.tsx │ │ │ └── topbar │ │ │ └── index.tsx │ ├── .prettierignore │ ├── public │ │ └── venus.ico │ ├── tsconfig.node.json │ ├── .gitignore │ ├── index.html │ ├── .prettierrc.cjs │ ├── vite.config.ts │ ├── tsconfig.json │ ├── tsconfig.app.json │ ├── .eslintrc.cjs │ └── package.json └── app.py ├── Computing-Server ├── include │ ├── Utilities │ │ ├── OHLCV.hpp │ │ ├── Logger.hpp │ │ ├── Utilities.hpp │ │ ├── Bar.hpp │ │ ├── SignalResult.hpp │ │ ├── ReplayMemory.hpp │ │ ├── Trade.hpp │ │ ├── Quote.hpp │ │ └── ModelTransfer.hpp │ ├── Velocity-Bot │ │ └── bot.hpp │ ├── AlgoEngine-Core │ │ ├── algorithm │ │ │ ├── OBV.hpp │ │ │ ├── VWAP.hpp │ │ │ ├── MA.hpp │ │ │ ├── EMA.hpp │ │ │ ├── MFI.hpp │ │ │ ├── RSI.hpp │ │ │ ├── FibonacciRetracement.hpp │ │ │ ├── ADX.hpp │ │ │ ├── ATR.hpp │ │ │ ├── SMA.hpp │ │ │ ├── PERatio.hpp │ │ │ ├── DividendYield.hpp │ │ │ ├── APO.hpp │ │ │ ├── CCI.hpp │ │ │ ├── BollingerBands.hpp │ │ │ └── StochasticOscillator.hpp │ │ ├── Reinforcement_models │ │ │ ├── QNetwork.hpp │ │ │ ├── Deep_Q-Learning.hpp │ │ │ ├── Agent_QNetwork.hpp │ │ │ └── Agent_Deep_Q-Learning.hpp │ │ ├── statistical_models │ │ │ ├── BayesianSVM.hpp │ │ │ ├── BayesianAnomalyDetection.hpp │ │ │ ├── BayesianMomentumTrading.hpp │ │ │ ├── BayesianDecisionTreeTrading.hpp │ │ │ ├── BayesianGARCHTrading.hpp │ │ │ ├── BayesianTrendDetection.hpp │ │ │ ├── BayesianCorrelationEstimation.hpp │ │ │ ├── BayesianCausalInferenceTrading.hpp │ │ │ ├── BayesianModelAveragingTrading.hpp │ │ │ ├── BayesianStochasticVolatility.hpp │ │ │ └── BayesianKernelRegression.hpp │ │ ├── time_series_models │ │ │ ├── VAR.hpp │ │ │ ├── GARCH.hpp │ │ │ ├── ARIMA.hpp │ │ │ └── SARIMA.hpp │ │ └── indicator │ │ │ └── Indicator.hpp │ ├── Data-Fetcher-Core │ │ ├── DataFetcher-Sub.hpp │ │ ├── WebSocket.hpp │ │ └── DataFetcher.hpp │ ├── Risk-Analysis-Core │ │ ├── VaRCalculator.hpp │ │ ├── CorrelationAnalyzer.hpp │ │ ├── PortfolioManager.hpp │ │ └── RiskAdjustedMetrics.hpp │ ├── Orderbook │ │ ├── transactions.hpp │ │ ├── order_.hpp │ │ └── order_book.hpp │ ├── IO-Broker-Core │ │ └── RedisDBManager.hpp │ └── Order-Manager-Core │ │ └── order_manager.hpp └── src │ ├── Velocity-Bot │ └── test │ │ └── multi-provider.cpp │ ├── Orderbook │ ├── transactions.cpp │ └── order_.cpp │ ├── Utilities │ ├── Logger.cpp │ └── Utilities.cpp │ ├── AlgoEngine-Core │ ├── Reinforcement_models │ │ └── QNetwork.cpp │ ├── indicators │ │ ├── PERatio.cpp │ │ ├── DividendYield.cpp │ │ ├── MA.cpp │ │ ├── OBV.cpp │ │ ├── VWAP.cpp │ │ ├── EMA.cpp │ │ ├── FibonacciRetracement.cpp │ │ ├── ATR.cpp │ │ ├── SMA.cpp │ │ ├── RSI.cpp │ │ ├── BollingerBands.cpp │ │ └── APO.cpp │ ├── time_series_models │ │ ├── VAR.cpp │ │ ├── GARCH.cpp │ │ ├── ARIMA.cpp │ │ └── SARIMA.cpp │ └── statistical models │ │ ├── BayesianGARCHTrading.cpp │ │ ├── BayesianMomentumTrading.cpp │ │ ├── BayesianTrendDetection.cpp │ │ ├── BayesianSVM.cpp │ │ ├── BayesianDecisionTreeTrading.cpp │ │ ├── BayesianAnomalyDetection.cpp │ │ ├── BayesianStochasticVolatility.cpp │ │ ├── BayesianModelAveragingTrading.cpp │ │ ├── BayesianCausalInferenceTrading.cpp │ │ ├── BayesianCorrelationEstimation.cpp │ │ └── BayesianKernelRegression.cpp │ ├── Data-Fetcher-Core │ └── DataFetcher-Sub.cpp │ └── Risk-Analysis-Core │ ├── VaRCalculator.cpp │ └── CorrelationAnalyzer.cpp ├── DataBroker-Server └── include │ └── Utilities │ ├── OHLCV.hpp │ ├── Bar.hpp │ ├── Trade.hpp │ └── Quote.hpp ├── .gitignore ├── IO-Server └── CMakeLists.txt └── Order-Manager-Server ├── include ├── Executor-Manager-Core │ ├── OrderDetails.hpp │ └── executor_manager.hpp ├── Scheduler │ └── scheduler.hpp └── Queue │ └── TSQueue.hpp └── src └── main.cpp /Monitoring-Server/Front-End/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/.prettierignore: -------------------------------------------------------------------------------- 1 | .next/ 2 | .vscode-test/ 3 | out/ 4 | dist/ 5 | node_modules/ 6 | public/ 7 | build/ -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/public/venus.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jitanshuraut/Velocity-Vortex/HEAD/Monitoring-Server/Front-End/public/venus.ico -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jitanshuraut/Velocity-Vortex/HEAD/Monitoring-Server/Front-End/src/assets/images/logo.png -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { Outlet } from 'react-router-dom'; 2 | 3 | const App = () => { 4 | return ; 5 | }; 6 | 7 | export default App; 8 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/assets/images/balance-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jitanshuraut/Velocity-Vortex/HEAD/Monitoring-Server/Front-End/src/assets/images/balance-bg.png -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/OHLCV.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | struct OHLCV { 6 | double open; 7 | double high; 8 | double low; 9 | double close; 10 | double volume; 11 | std::string timestamp; 12 | }; -------------------------------------------------------------------------------- /Computing-Server/include/Velocity-Bot/bot.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOT_HPP 2 | #define BOT_HPP 3 | 4 | class Bot { 5 | public: 6 | 7 | virtual void initialize() = 0; 8 | virtual void run() = 0; 9 | virtual void stop() = 0; 10 | 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /Computing-Server/src/Velocity-Bot/test/multi-provider.cpp: -------------------------------------------------------------------------------- 1 | #include "Data-Fetcher-Core/DataFetcher-Sub.hpp" 2 | 3 | int main() 4 | { 5 | 6 | DataFetcherSub dataFetcher("tcp://localhost:5555"); 7 | dataFetcher.subscribe(""); 8 | dataFetcher.receive(); 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/index.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); 2 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "strict": true 9 | }, 10 | "include": ["vite.config.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /Computing-Server/src/Orderbook/transactions.cpp: -------------------------------------------------------------------------------- 1 | #include "Orderbook/transactions.hpp" 2 | 3 | Trade_::Trade_(const TradeInfo& bidTrade, const TradeInfo& askTrade) 4 | : bidTrade_{bidTrade}, askTrade_{askTrade} {} 5 | 6 | const TradeInfo& Trade_::GetBidTrade() const { return bidTrade_; } 7 | const TradeInfo& Trade_::GetAskTrade() const { return askTrade_; } -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/loader/PageLoader.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import LinearProgress from '@mui/material/LinearProgress'; 3 | 4 | const PageLoader = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default PageLoader; 13 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/styles/echart.ts: -------------------------------------------------------------------------------- 1 | const echart = () => ({ 2 | '.echarts-for-react': { 3 | overflow: 'hidden', 4 | '&:not(&.echart-map)': { 5 | '> div': { 6 | '&:first-of-type': { 7 | height: '100% !important', 8 | }, 9 | }, 10 | }, 11 | }, 12 | }); 13 | 14 | export default echart; 15 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/layout/Stack.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const Stack: Components>['MuiStack'] = { 5 | defaultProps: { 6 | useFlexGap: true, 7 | direction: 'row', 8 | }, 9 | }; 10 | 11 | export default Stack; 12 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/shadows.ts: -------------------------------------------------------------------------------- 1 | declare module '@mui/material/styles' { 2 | interface Theme { 3 | customShadows: string[]; 4 | } 5 | interface ThemeOptions { 6 | customShadows?: string[]; 7 | } 8 | } 9 | 10 | const customShadows = ['0px 18px 40px 0px #7090B01F', '2px 2px 10px 0px rgba(10,10,10,0.2)']; 11 | 12 | export default customShadows; 13 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/buttons/Toolbar.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const Toolbar: Components>['MuiToolbar'] = { 5 | styleOverrides: { 6 | root: { 7 | padding: '0 !important', 8 | }, 9 | }, 10 | }; 11 | 12 | export default Toolbar; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/list/List.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const List: Components>['MuiList'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | padding: theme.spacing(1), 8 | }), 9 | }, 10 | }; 11 | 12 | export default List; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/routes/paths.ts: -------------------------------------------------------------------------------- 1 | export const rootPaths = { 2 | root: '/', 3 | pageRoot: 'pages', 4 | authRoot: 'auth', 5 | errorRoot: 'error', 6 | }; 7 | 8 | export default { 9 | dashboard: `/${rootPaths.pageRoot}/`, 10 | logs: `/${rootPaths.pageRoot}/logs`, 11 | Portfolio: `/${rootPaths.pageRoot}/Portfolio`, 12 | 404: `/${rootPaths.errorRoot}/404`, 13 | }; 14 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | velocity-vortex 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/Logger.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LOGGER_HPP 2 | #define LOGGER_HPP 3 | 4 | #include "IO-Broker-Core/RedisDBManager.hpp" 5 | class Logger 6 | { 7 | public: 8 | Logger() = default; 9 | static void initialize(); 10 | static std::shared_ptr &getInstance(); 11 | 12 | private: 13 | static std::shared_ptr logger; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /DataBroker-Server/include/Utilities/OHLCV.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct OHLCV { 6 | double open; // Opening price 7 | double high; // Highest price 8 | double low; // Lowest price 9 | double close; // Closing price 10 | double volume; // Trading volume 11 | std::string timestamp; // Timestamp of the data 12 | }; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/loader/Splash.tsx: -------------------------------------------------------------------------------- 1 | import Stack from '@mui/material/Stack'; 2 | import CircularProgress from '@mui/material/CircularProgress'; 3 | 4 | const Splash = () => { 5 | return ( 6 | 7 | 8 | 9 | ); 10 | }; 11 | 12 | export default Splash; 13 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/base/Image.tsx: -------------------------------------------------------------------------------- 1 | import { Box, SxProps } from '@mui/material'; 2 | import { ImgHTMLAttributes } from 'react'; 3 | 4 | interface ImageProps extends ImgHTMLAttributes { 5 | sx?: SxProps; 6 | } 7 | 8 | const Image = ({ sx, ...rest }: ImageProps) => { 9 | return ; 10 | }; 11 | 12 | export default Image; 13 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/data-display/Badge.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const Badge: Components>['MuiBadge'] = { 5 | styleOverrides: { 6 | root: {}, 7 | badge: { 8 | top: 4, 9 | right: 4, 10 | }, 11 | }, 12 | }; 13 | 14 | export default Badge; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/OBV.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class OBV : public Indicator 7 | { 8 | public: 9 | OBV(const std::string &indicatorName) 10 | : Indicator(indicatorName, 1) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &data); 14 | }; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/base/IconifyIcon.tsx: -------------------------------------------------------------------------------- 1 | import { Box, BoxProps } from '@mui/material'; 2 | import { Icon, IconProps } from '@iconify/react'; 3 | 4 | interface IconifyProps extends BoxProps { 5 | icon: IconProps['icon']; 6 | } 7 | 8 | const IconifyIcon = ({ icon, ...rest }: IconifyProps) => { 9 | return ; 10 | }; 11 | 12 | export default IconifyIcon; 13 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/VWAP.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class VWAP : public Indicator 7 | { 8 | public: 9 | VWAP(const std::string &indicatorName) 10 | : Indicator(indicatorName, 0) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &data); 14 | }; -------------------------------------------------------------------------------- /Computing-Server/src/Utilities/Logger.cpp: -------------------------------------------------------------------------------- 1 | #include "Utilities/Logger.hpp" 2 | 3 | std::shared_ptr Logger::logger = nullptr; 4 | 5 | void Logger::initialize() 6 | { 7 | logger = std::make_shared(); 8 | logger->connect(); 9 | } 10 | 11 | std::shared_ptr& Logger::getInstance() 12 | { 13 | if (!logger) 14 | { 15 | initialize(); 16 | } 17 | return logger; 18 | } -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/MA.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class MA : public Indicator 7 | { 8 | public: 9 | MA(const std::string &indicatorName, int period) 10 | : Indicator(indicatorName, period) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &data, int period); 14 | }; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/EMA.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class EMA : public Indicator { 7 | public: 8 | EMA(const std::string& indicatorName, int period) 9 | : Indicator(indicatorName, period) {} 10 | 11 | SignalResult calculateSignal() override; 12 | static std::vector calculate(const std::vector& data, std::size_t period); 13 | }; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/MFI.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class MFI : public Indicator 7 | { 8 | public: 9 | MFI(const std::string &indicatorName, int period) 10 | : Indicator(indicatorName, period) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &data, int period); 14 | }; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/pages/portfolio/Portfolio.tsx: -------------------------------------------------------------------------------- 1 | import Grid from '@mui/material/Grid'; 2 | import TransactionHistory from 'components/sections/dashboard/transaction-history'; 3 | 4 | const Portfolio = () => { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | ); 12 | }; 13 | 14 | export default Portfolio; 15 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/RSI.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class RSI : public Indicator { 7 | public: 8 | RSI(const std::string& indicatorName, int period) 9 | : Indicator(indicatorName, period) {} 10 | 11 | SignalResult calculateSignal() override; 12 | static std::vector calculate(const std::vector& historicalData, std::size_t period); 13 | }; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/FibonacciRetracement.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class FibonacciRetracement : public Indicator 7 | { 8 | public: 9 | FibonacciRetracement(const std::string &indicatorName) 10 | : Indicator(indicatorName, 0) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &data); 14 | }; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/Reinforcement_models/QNetwork.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QNETWORK_HPP 2 | #define QNETWORK_HPP 3 | 4 | #include 5 | 6 | const int STATE_SIZE = 300; 7 | const int NUM_ACTIONS = 3; 8 | 9 | class QNetwork : public torch::nn::Module 10 | { 11 | public: 12 | QNetwork(); 13 | torch::Tensor forward(torch::Tensor x); 14 | 15 | private: 16 | torch::nn::Linear layer1{nullptr}, layer2{nullptr}, layer3{nullptr}; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Computing-Server/include/Data-Fetcher-Core/DataFetcher-Sub.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DATAFETCHER_SUB_HPP 2 | #define DATAFETCHER_SUB_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class DataFetcherSub 9 | { 10 | public: 11 | DataFetcherSub(const std::string &address); 12 | void subscribe(const std::string &topic); 13 | void receive(); 14 | 15 | private: 16 | zmq::context_t context; 17 | zmq::socket_t subscriber; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/ADX.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include "Utilities/SignalResult.hpp" 6 | 7 | class ADX : public Indicator 8 | { 9 | public: 10 | ADX(const std::string &indicatorName, int period) 11 | : Indicator(indicatorName, period) {} 12 | 13 | SignalResult calculateSignal() override; 14 | static std::vector calculate(const std::vector &data, int period); 15 | }; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/ATR.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class ATR : public Indicator 7 | { 8 | public: 9 | ATR(const std::string &indicatorName, int period) 10 | : Indicator(indicatorName, period) {} 11 | 12 | SignalResult calculateSignal() override; 13 | std::vector calculate(const std::vector &ohlcvData, int period); 14 | 15 | private: 16 | double previousClose = 0.0; 17 | }; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/buttons/ButtonBase.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const ButtonBase: Components>['MuiButtonBase'] = { 5 | defaultProps: { 6 | disableRipple: false, 7 | }, 8 | styleOverrides: { 9 | root: { 10 | '&:hover': { 11 | backgroundColor: 'transparent', 12 | }, 13 | }, 14 | }, 15 | }; 16 | 17 | export default ButtonBase; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Ignore build files 35 | **/build/ 36 | **/node_modules/ 37 | .vscode 38 | *.sh 39 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/list/Collapse.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const Collapse: Components>['MuiCollapse'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | padding: theme.spacing(0, 2), 8 | 9 | '& .MuiList-root': { 10 | padding: 0, 11 | margin: theme.spacing(1, 0), 12 | }, 13 | }), 14 | }, 15 | }; 16 | 17 | export default Collapse; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianSVM.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include "Utilities/SignalResult.hpp" 6 | 7 | class BayesianSVM : public Indicator 8 | { 9 | public: 10 | BayesianSVM(const std::string &indicatorName, int period) 11 | : Indicator(indicatorName, period) {} 12 | 13 | SignalResult calculateSignal() override; 14 | static std::vector applySVM(const std::vector &data, int period); 15 | }; 16 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/SMA.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class SMA : public Indicator 7 | { 8 | public: 9 | SMA(const std::string &indicatorName, int period) 10 | : Indicator(indicatorName, period) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &historicalData, int period); 14 | 15 | private: 16 | static const size_t PARALLEL_THRESHOLD = 1000; 17 | }; -------------------------------------------------------------------------------- /IO-Server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(IOBroker) 3 | 4 | set(CMAKE_CXX_STANDARD 20) 5 | set(CMAKE_CXX_STANDARD_REQUIRED True) 6 | 7 | find_library(HIREDIS_LIB hiredis REQUIRED) 8 | find_library(SQLITE3_LIB sqlite3 REQUIRED) 9 | find_package(spdlog REQUIRED) 10 | find_package(fmt REQUIRED) 11 | 12 | add_executable(subscriber src/subscriber.cpp) 13 | 14 | target_link_libraries(subscriber ${HIREDIS_LIB} ${SQLITE3_LIB} spdlog::spdlog fmt::fmt) 15 | 16 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/..) -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/PERatio.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class PERatio : public Indicator 7 | { 8 | public: 9 | PERatio(const std::string &indicatorName, double earningsPerShare) 10 | : Indicator(indicatorName, 0), eps(earningsPerShare) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &data, double earningsPerShare); 14 | 15 | private: 16 | double eps; 17 | }; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/styles/simplebar.ts: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | 3 | const simplebar = (theme: Theme) => ({ 4 | '& .simplebar-track': { 5 | '&.simplebar-vertical': { 6 | '& .simplebar-scrollbar': { 7 | '&:before': { 8 | backgroundColor: theme.palette.grey[300], 9 | }, 10 | '&.simplebar-visible': { 11 | '&:before': { 12 | opacity: 1, 13 | }, 14 | }, 15 | }, 16 | }, 17 | }, 18 | }); 19 | 20 | export default simplebar; 21 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | printWidth: 100, 3 | singleQuote: true, 4 | trailingComma: 'all', 5 | overrides: [ 6 | { 7 | files: ['docs/**/*.md', 'docs/src/pages/**/*.{js,tsx}', 'docs/data/**/*.{js,tsx}'], 8 | options: { 9 | printWidth: 85, 10 | }, 11 | }, 12 | { 13 | files: ['docs/pages/blog/**/*.md'], 14 | options: { 15 | printWidth: 82, 16 | }, 17 | }, 18 | ], 19 | }; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/list/ListItemIcon.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const ListItemIcon: Components>['MuiListItemIcon'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | minWidth: '0 !important', 8 | marginRight: theme.spacing(1.75), 9 | color: theme.palette.text.disabled, 10 | fontSize: theme.typography.h5.fontSize, 11 | }), 12 | }, 13 | }; 14 | 15 | export default ListItemIcon; -------------------------------------------------------------------------------- /Order-Manager-Server/include/Executor-Manager-Core/OrderDetails.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ORDER_DETAILS_HPP 2 | #define ORDER_DETAILS_HPP 3 | 4 | #include 5 | #include 6 | 7 | struct OrderDetails 8 | { 9 | std::string side; 10 | std::string type; 11 | std::string timeInForce; 12 | std::string symbol; 13 | std::string qty; 14 | std::optional limitPrice; 15 | std::optional stopPrice; 16 | std::optional trailPrice; 17 | std::optional trailPercent; 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/DividendYield.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class DividendYield : public Indicator 7 | { 8 | public: 9 | DividendYield(const std::string &indicatorName, double dividendPerShare) 10 | : Indicator(indicatorName, 0), dps(dividendPerShare) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &data, double dividendPerShare); 14 | 15 | private: 16 | double dps; 17 | }; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/APO.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class APO : public Indicator 7 | { 8 | public: 9 | APO(const std::string &indicatorName, int shortPeriod, int longPeriod) 10 | : Indicator(indicatorName, shortPeriod), longPeriod(longPeriod) {} 11 | 12 | SignalResult calculateSignal() override; 13 | static std::vector calculate(const std::vector &ohlcvData, int shortPeriod, int longPeriod); 14 | 15 | private: 16 | int longPeriod; 17 | }; -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/Utilities.hpp: -------------------------------------------------------------------------------- 1 | #ifndef UTILITIES_HPP 2 | #define UTILITIES_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "./OHLCV.hpp" 14 | #include "./Bar.hpp" 15 | 16 | OHLCV barToOHLCV(const Bar& bar); 17 | 18 | Bar ohlcvToBar(const OHLCV& ohlcv, const std::string& symbol); 19 | 20 | OHLCV buildAggregatedCandle(const std::vector& candles); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/list/ListItemText.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const ListItemText: Components>['MuiListItemText'] = { 5 | styleOverrides: { 6 | root: {}, 7 | primary: ({ theme }) => ({ 8 | marginTop: theme.spacing(0.15), 9 | color: theme.palette.text.disabled, 10 | fontSize: theme.typography.body1.fontSize, 11 | fontWeight: 500, 12 | }), 13 | }, 14 | }; 15 | 16 | export default ListItemText; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianAnomalyDetection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include "Utilities/SignalResult.hpp" 6 | 7 | class BayesianAnomalyDetection : public Indicator 8 | { 9 | public: 10 | BayesianAnomalyDetection(const std::string &indicatorName, int period) 11 | : Indicator(indicatorName, period) {} 12 | 13 | SignalResult calculateSignal() override; 14 | static std::vector detectAnomalies(const std::vector &data, int period); 15 | }; 16 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianMomentumTrading.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include "Utilities/SignalResult.hpp" 6 | 7 | class BayesianMomentumTrading : public Indicator 8 | { 9 | public: 10 | BayesianMomentumTrading(const std::string &indicatorName, int period) 11 | : Indicator(indicatorName, period) {} 12 | 13 | SignalResult calculateSignal() override; 14 | static std::vector calculateMomentum(const std::vector &data, int period); 15 | }; 16 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/inputs/FilledInput.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const FilledInput: Components>['MuiFilledInput'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | borderRadius: theme.shape.borderRadius * 2, 8 | }), 9 | input: { 10 | padding: 0, 11 | }, 12 | sizeSmall: ({ theme }) => ({ 13 | paddingLeft: theme.spacing(1.25), 14 | }), 15 | }, 16 | }; 17 | 18 | export default FilledInput; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/inputs/OutlinedInput.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const OutlinedInput: Components>['MuiOutlinedInput'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | borderRadius: theme.shape.borderRadius * 2, 8 | }), 9 | input: { 10 | padding: 0, 11 | }, 12 | sizeSmall: ({ theme }) => ({ 13 | paddingLeft: theme.spacing(1.25), 14 | }), 15 | }, 16 | }; 17 | 18 | export default OutlinedInput; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianDecisionTreeTrading.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include "Utilities/SignalResult.hpp" 6 | 7 | class BayesianDecisionTreeTrading : public Indicator 8 | { 9 | public: 10 | BayesianDecisionTreeTrading(const std::string &indicatorName, int period) 11 | : Indicator(indicatorName, period) {} 12 | 13 | SignalResult calculateSignal() override; 14 | static std::vector evaluateDecisionTree(const std::vector &data, int period); 15 | }; 16 | -------------------------------------------------------------------------------- /Computing-Server/include/Risk-Analysis-Core/VaRCalculator.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VARCALCULATOR_HPP 2 | #define VARCALCULATOR_HPP 3 | 4 | #include 5 | 6 | class VaRCalculator 7 | { 8 | private: 9 | std::vector historical_returns; 10 | double confidence_level; 11 | double var_value; 12 | 13 | public: 14 | VaRCalculator(double confidence_level, double var_val) : confidence_level(confidence_level), var_value(var_val) {}; 15 | void calculate_var(); 16 | double get_var(); 17 | void set_historical_returns(const std::vector &returns); 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/Reinforcement_models/QNetwork.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/Reinforcement_models/QNetwork.hpp" 2 | 3 | QNetwork::QNetwork() 4 | { 5 | layer1 = register_module("layer1", torch::nn::Linear(STATE_SIZE, 64)); 6 | layer2 = register_module("layer2", torch::nn::Linear(64, 64)); 7 | layer3 = register_module("layer3", torch::nn::Linear(64, NUM_ACTIONS)); 8 | } 9 | 10 | torch::Tensor QNetwork::forward(torch::Tensor x) 11 | { 12 | x = torch::relu(layer1->forward(x)); 13 | x = torch::relu(layer2->forward(x)); 14 | return layer3->forward(x); 15 | } 16 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/CCI.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | 6 | class CCI : public Indicator 7 | { 8 | public: 9 | CCI(const std::string &indicatorName, int period) 10 | : Indicator(indicatorName, period) {} 11 | 12 | SignalResult calculateSignal() override; 13 | std::vector calculate(const std::vector &data, int period); 14 | 15 | private: 16 | void calculateCCIRange(size_t start, size_t end, const std::vector &data, double constant, std::vector &cciValues); 17 | }; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianGARCHTrading.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | #include 7 | #include "Utilities/SignalResult.hpp" 8 | 9 | class BayesianGARCHTrading : public Indicator 10 | { 11 | public: 12 | BayesianGARCHTrading(const std::string &indicatorName, int period) 13 | : Indicator(indicatorName, period) {} 14 | 15 | SignalResult calculateSignal() override; 16 | static std::vector estimateGARCH(const std::vector &data, int period); 17 | }; 18 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianTrendDetection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include "Utilities/SignalResult.hpp" 6 | #include 7 | #include 8 | 9 | class BayesianTrendDetection : public Indicator 10 | { 11 | public: 12 | BayesianTrendDetection(const std::string &indicatorName, int period) 13 | : Indicator(indicatorName, period) {} 14 | 15 | SignalResult calculateSignal() override; 16 | static std::vector calculate(const std::vector &data, int period); 17 | }; 18 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianCorrelationEstimation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include "Utilities/SignalResult.hpp" 6 | 7 | class BayesianCorrelationEstimation : public Indicator 8 | { 9 | public: 10 | BayesianCorrelationEstimation(const std::string &indicatorName, int period) 11 | : Indicator(indicatorName, period) {} 12 | 13 | SignalResult calculateSignal() override; 14 | static std::vector calculate(const std::vector &data1, const std::vector &data2, int period); 15 | }; 16 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/time_series_models/VAR.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | #include 7 | #include "Utilities/SignalResult.hpp" 8 | 9 | class VAR : public Indicator 10 | { 11 | private: 12 | int lagOrder; 13 | 14 | public: 15 | VAR(const std::string &indicatorName, int lagOrder) 16 | : Indicator(indicatorName, lagOrder), lagOrder(lagOrder) {} 17 | 18 | SignalResult calculateSignal() override; 19 | std::vector> fitVAR(const std::vector> &data); 20 | }; 21 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianCausalInferenceTrading.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | #include "Utilities/SignalResult.hpp" 7 | 8 | class BayesianCausalInferenceTrading : public Indicator 9 | { 10 | public: 11 | BayesianCausalInferenceTrading(const std::string &indicatorName, int period) 12 | : Indicator(indicatorName, period) {} 13 | 14 | SignalResult calculateSignal() override; 15 | static std::map performCausalInference(const std::vector &data, int period); 16 | }; 17 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianModelAveragingTrading.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | #include "Utilities/SignalResult.hpp" 7 | 8 | class BayesianModelAveragingTrading : public Indicator 9 | { 10 | public: 11 | BayesianModelAveragingTrading(const std::string &indicatorName, int period) 12 | : Indicator(indicatorName, period) {} 13 | 14 | SignalResult calculateSignal() override; 15 | static double computeModelAverage(const std::vector &modelPredictions, const std::vector &weights); 16 | }; 17 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianStochasticVolatility.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | #include 7 | #include "Utilities/SignalResult.hpp" 8 | 9 | class BayesianStochasticVolatility : public Indicator 10 | { 11 | public: 12 | BayesianStochasticVolatility(const std::string &indicatorName, int period) 13 | : Indicator(indicatorName, period) {} 14 | 15 | SignalResult calculateSignal() override; 16 | static std::vector estimateVolatility(const std::vector &data, int period); 17 | }; 18 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/inputs/FormControlLabel.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const FormControlLabel: Components>['MuiFormControlLabel'] = { 5 | styleOverrides: { 6 | root: { 7 | marginLeft: 0, 8 | }, 9 | label: ({ theme }) => ({ 10 | marginLeft: 0, 11 | letterSpacing: 0.25, 12 | color: theme.palette.text.secondary, 13 | fontSize: theme.typography.body2.fontSize, 14 | userSelect: 'none', 15 | }), 16 | }, 17 | }; 18 | 19 | export default FormControlLabel; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import router from 'routes/router'; 4 | import { RouterProvider } from 'react-router-dom'; 5 | import { ThemeProvider } from '@emotion/react'; 6 | import { CssBaseline } from '@mui/material'; 7 | import { theme } from 'theme/theme.ts'; 8 | import './index.css'; 9 | 10 | ReactDOM.createRoot(document.getElementById('root')!).render( 11 | 12 | 13 | 14 | 15 | 16 | , 17 | ); 18 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/list/ListItemButton.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const ListItemButton: Components>['MuiListItemButton'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | color: theme.palette.text.disabled, 8 | marginBottom: theme.spacing(1), 9 | padding: theme.spacing(0.875, 1.25), 10 | borderRadius: theme.shape.borderRadius * 1.25, 11 | '&:hover': { backgroundColor: theme.palette.info.main }, 12 | }), 13 | }, 14 | }; 15 | 16 | export default ListItemButton; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/time_series_models/GARCH.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | #include 7 | #include "Utilities/SignalResult.hpp" 8 | 9 | class GARCH : public Indicator 10 | { 11 | private: 12 | int p; // Order of the GARCH term 13 | int q; // Order of the ARCH term 14 | 15 | public: 16 | GARCH(const std::string &indicatorName, int p, int q) 17 | : Indicator(indicatorName, 0), p(p), q(q) {} 18 | 19 | SignalResult calculateSignal() override; 20 | std::vector fitGARCH(const std::vector &returns); 21 | }; 22 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/list/MenuItem.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const MenuItem: Components>['MuiMenuItem'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | fontWeight: 500, 8 | padding: theme.spacing(0.75, 1.25), 9 | fontSize: theme.typography.body2.fontSize, 10 | borderRadius: theme.shape.borderRadius * 1.5, 11 | transition: 'all 0.3s ease-in-out', 12 | '&:hover': { backgroundColor: theme.palette.info.dark }, 13 | }), 14 | }, 15 | }; 16 | 17 | export default MenuItem; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/pages/dashboard/Dashbaord.tsx: -------------------------------------------------------------------------------- 1 | import Grid from '@mui/material/Grid'; 2 | import TopCards from 'components/sections/dashboard/top-cards'; 3 | import Balance from 'components/sections/dashboard/balance'; 4 | 5 | const Dashbaord = () => { 6 | return ( 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ); 20 | }; 21 | 22 | export default Dashbaord; 23 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/BollingerBands.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../indicator/Indicator.hpp" 3 | #include 4 | #include 5 | 6 | class BollingerBands : public Indicator 7 | { 8 | private: 9 | double numStdDev; 10 | 11 | public: 12 | BollingerBands(const std::string &indicatorName, int period, double numStdDev) 13 | : Indicator(indicatorName, period), numStdDev(numStdDev) {} 14 | 15 | SignalResult calculateSignal() override; 16 | std::pair calculate() const; 17 | static std::pair calculate(const std::vector &prices, int period, double numStdDev); 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import react from '@vitejs/plugin-react-swc'; 3 | import tsconfigPaths from 'vite-tsconfig-paths'; 4 | import checker from 'vite-plugin-checker'; 5 | 6 | // https://vitejs.dev/config/ 7 | export default defineConfig({ 8 | plugins: [ 9 | react(), 10 | tsconfigPaths(), 11 | checker({ 12 | typescript: true, 13 | eslint: { 14 | lintCommand: 'eslint "./src/**/*.{ts,tsx}"', 15 | }, 16 | }), 17 | ], 18 | server: { 19 | host: '0.0.0.0', 20 | port: 3000, 21 | }, 22 | preview: { 23 | port: 5000, 24 | }, 25 | base: '/Velocity-Vortex', 26 | }); 27 | -------------------------------------------------------------------------------- /Computing-Server/include/Orderbook/transactions.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TRADE_H 2 | #define TRADE_H 3 | 4 | #include 5 | #include 6 | 7 | using OrderId = std::uint64_t; 8 | using Quantity = std::uint32_t; 9 | using Price = std::int32_t; 10 | 11 | struct TradeInfo 12 | { 13 | OrderId orderId_; 14 | Quantity quantity_; 15 | Price price_; 16 | }; 17 | 18 | class Trade_ 19 | { 20 | public: 21 | Trade_(const TradeInfo &bidTrade, const TradeInfo &askTrade); 22 | const TradeInfo &GetBidTrade() const; 23 | const TradeInfo &GetAskTrade() const; 24 | 25 | private: 26 | TradeInfo bidTrade_; 27 | TradeInfo askTrade_; 28 | }; 29 | 30 | using Trades_ = std::vector; 31 | 32 | #endif -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/algorithm/StochasticOscillator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | 7 | class StochasticOscillator : public Indicator 8 | { 9 | public: 10 | StochasticOscillator(const std::string &indicatorName, int period, int smoothK, int smoothD) 11 | : Indicator(indicatorName, period), smoothK(smoothK), smoothD(smoothD) {} 12 | 13 | SignalResult calculateSignal() override; 14 | static std::vector> calculate(const std::vector &historicalData, int period, int smoothK, int smoothD); 15 | 16 | private: 17 | int smoothK; 18 | int smoothD; 19 | }; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/surfaces/Paper.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | import customShadows from 'theme/shadows'; 4 | 5 | const Paper: Components>['MuiPaper'] = { 6 | styleOverrides: { 7 | root: ({ theme }) => ({ 8 | padding: theme.spacing(3.5), 9 | backgroundColor: theme.palette.info.light, 10 | borderRadius: theme.shape.borderRadius * 3, 11 | boxShadow: 'none', 12 | 13 | '&.MuiMenu-paper': { 14 | padding: 0, 15 | boxShadow: customShadows[1], 16 | }, 17 | }), 18 | }, 19 | }; 20 | 21 | export default Paper; 22 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/pagination/PaginationItem.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const PaginationItem: Components>['MuiPaginationItem'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | color: theme.palette.text.primary, 8 | fontSize: theme.typography.body2.fontSize, 9 | '&.Mui-selected': { 10 | color: theme.palette.info.lighter, 11 | backgroundColor: theme.palette.primary.main, 12 | '&:hover': { backgroundColor: theme.palette.primary.main }, 13 | }, 14 | }), 15 | }, 16 | }; 17 | 18 | export default PaginationItem; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/styles/scrollbar.ts: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | 3 | const scrollbar = (theme: Theme) => ({ 4 | '@supports (-moz-appearance:none)': { 5 | scrollbarColor: `${theme.palette.grey[300]} transparent`, 6 | }, 7 | '*::-webkit-scrollbar': { 8 | width: 5, 9 | height: 5, 10 | WebkitAppearance: 'none', 11 | backgroundColor: 'transparent', 12 | visibility: 'hidden', 13 | }, 14 | '*::-webkit-scrollbar-track': { 15 | marginTop: 120, 16 | }, 17 | '*::-webkit-scrollbar-thumb': { 18 | borderRadius: 3, 19 | backgroundColor: theme.palette.info.dark, 20 | visibility: 'hidden', 21 | }, 22 | }); 23 | 24 | export default scrollbar; 25 | -------------------------------------------------------------------------------- /Computing-Server/include/Risk-Analysis-Core/CorrelationAnalyzer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CORRELATIONANALYZER_HPP 2 | #define CORRELATIONANALYZER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class CorrelationAnalyzer 10 | { 11 | private: 12 | std::vector stock_symbols; 13 | std::unordered_map> price_data; 14 | 15 | public: 16 | CorrelationAnalyzer() {}; 17 | void load_price_data(std::map> historicalData); 18 | double calculate_correlation(const std::string &stock1, const std::string &stock2); 19 | std::vector> get_correlation_matrix(); 20 | }; 21 | 22 | #endif -------------------------------------------------------------------------------- /Computing-Server/include/Risk-Analysis-Core/PortfolioManager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PORTFOLIOMANAGER_HPP 2 | #define PORTFOLIOMANAGER_HPP 3 | 4 | #include "CorrelationAnalyzer.hpp" 5 | #include "RiskAdjustedMetrics.hpp" 6 | #include "VaRCalculator.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | class PortfolioManager 12 | { 13 | private: 14 | std::map> StockData; 15 | 16 | public: 17 | PortfolioManager() {} 18 | 19 | void Add_StockData(const std::string &symbol, const std::vector &returns) 20 | { 21 | StockData[symbol] = returns; 22 | } 23 | 24 | void Risk_Analysis_All(); 25 | void Risk_Analysis_Specific(const std::string &symbol); 26 | }; 27 | 28 | #endif -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/time_series_models/ARIMA.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | #include 7 | #include "Utilities/SignalResult.hpp" 8 | 9 | class ARIMA : public Indicator 10 | { 11 | private: 12 | int p; // Order of the autoregressive part 13 | int d; // Degree of differencing 14 | int q; // Order of the moving average part 15 | 16 | public: 17 | ARIMA(const std::string &indicatorName, int p, int d, int q) 18 | : Indicator(indicatorName, p + d + q), p(p), d(d), q(q) {} 19 | 20 | SignalResult calculateSignal() override; 21 | static std::vector fitARIMA(const std::vector &data, int p, int d, int q); 22 | }; 23 | -------------------------------------------------------------------------------- /Computing-Server/src/Data-Fetcher-Core/DataFetcher-Sub.cpp: -------------------------------------------------------------------------------- 1 | #include "Data-Fetcher-Core/DataFetcher-Sub.hpp" 2 | 3 | DataFetcherSub::DataFetcherSub(const std::string& address) 4 | : context(1), subscriber(context, ZMQ_SUB) 5 | { 6 | subscriber.connect(address); 7 | } 8 | 9 | void DataFetcherSub::subscribe(const std::string& topic) 10 | { 11 | subscriber.setsockopt(ZMQ_SUBSCRIBE, topic.c_str(), topic.size()); 12 | } 13 | 14 | void DataFetcherSub::receive() 15 | { 16 | zmq::message_t message; 17 | while (true) 18 | { 19 | subscriber.recv(message, zmq::recv_flags::none); 20 | std::string receivedMessage(static_cast(message.data()), message.size()); 21 | std::cout << "Received: " << receivedMessage << std::endl; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/navigation/Drawer.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const Drawer: Components>['MuiDrawer'] = { 5 | styleOverrides: { 6 | root: { 7 | '&:hover, &:focus': { 8 | '*::-webkit-scrollbar, *::-webkit-scrollbar-thumb': { 9 | visibility: 'visible', 10 | }, 11 | }, 12 | }, 13 | paper: ({ theme }) => ({ 14 | padding: 0, 15 | width: '290px', 16 | height: '100vh', 17 | border: 0, 18 | borderRadius: 0, 19 | backgroundColor: theme.palette.info.light, 20 | boxShadow: 'none', 21 | boxSizing: 'border-box', 22 | }), 23 | }, 24 | }; 25 | 26 | export default Drawer; 27 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/statistical_models/BayesianKernelRegression.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include "Utilities/SignalResult.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class BayesianKernelRegression : public Indicator 14 | { 15 | public: 16 | BayesianKernelRegression(const std::string &indicatorName, int period) 17 | : Indicator(indicatorName, period) {} 18 | 19 | SignalResult calculateSignal() override; 20 | static std::vector performRegression(const std::vector &data, int period); 21 | static std::chrono::system_clock::time_point parseTimestamp(const std::string ×tamp); 22 | }; 23 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true, 22 | 23 | "paths": { 24 | "*": ["./src/*"] 25 | } 26 | }, 27 | "include": ["src"], 28 | "references": [{ "path": "./tsconfig.node.json" }] 29 | } 30 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/navigation/Link.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom'; 4 | import { forwardRef } from 'react'; 5 | 6 | const LinkBehavior = forwardRef< 7 | HTMLAnchorElement, 8 | Omit & { href: RouterLinkProps['to'] } 9 | >((props, ref) => { 10 | const { href, ...other } = props; 11 | // Map href (Material UI) -> to (react-router) 12 | return ; 13 | }); 14 | 15 | const Link: Components>['MuiLink'] = { 16 | defaultProps: { 17 | underline: 'none', 18 | component: LinkBehavior, 19 | }, 20 | }; 21 | 22 | export default Link; -------------------------------------------------------------------------------- /Computing-Server/src/Risk-Analysis-Core/VaRCalculator.cpp: -------------------------------------------------------------------------------- 1 | #include "Risk-Analysis-Core/VaRCalculator.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | void VaRCalculator::set_historical_returns(const std::vector &returns) 7 | { 8 | historical_returns = returns; 9 | } 10 | void VaRCalculator::calculate_var() 11 | { 12 | if (historical_returns.empty()) 13 | { 14 | var_value = 0.0; 15 | return; 16 | } 17 | std::vector sorted_returns = historical_returns; 18 | std::sort(sorted_returns.begin(), sorted_returns.end()); 19 | 20 | size_t index = static_cast((1.0 - confidence_level) * sorted_returns.size()); 21 | var_value = -sorted_returns[index]; 22 | } 23 | 24 | double VaRCalculator::get_var() 25 | { 26 | return var_value; 27 | } -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/top-cards/index.tsx: -------------------------------------------------------------------------------- 1 | import Grid from '@mui/material/Grid'; 2 | import Spent from './spent'; 3 | import Total_Trades from './Total_Trades'; 4 | import Earnings from './earnings'; 5 | import Activity from './activity'; 6 | 7 | const TopCards = () => { 8 | return ( 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | ); 24 | }; 25 | 26 | export default TopCards; 27 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", 5 | "target": "ES2020", 6 | "useDefineForClassFields": true, 7 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 8 | "module": "ESNext", 9 | "skipLibCheck": true, 10 | 11 | /* Bundler mode */ 12 | "moduleResolution": "bundler", 13 | "allowImportingTsExtensions": true, 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "moduleDetection": "force", 17 | "noEmit": true, 18 | "jsx": "react-jsx", 19 | 20 | /* Linting */ 21 | "strict": true, 22 | "noUnusedLocals": true, 23 | "noUnusedParameters": true, 24 | "noFallthroughCasesInSwitch": true 25 | }, 26 | "include": ["src"] 27 | } 28 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/inputs/InputAdornment.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const InputAdornment: Components>['MuiInputAdornment'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | margin: '0 !important', 8 | color: theme.palette.text.primary, 9 | fontSize: theme.typography.h5.fontSize, 10 | 11 | '&.MuiInputAdornment-sizeSmall': { 12 | '& .MuiBox-root': { 13 | fontSize: theme.typography.h6.fontSize, 14 | }, 15 | }, 16 | }), 17 | positionStart: ({ theme }) => ({ 18 | paddingRight: theme.spacing(1), 19 | }), 20 | positionEnd: ({ theme }) => ({ 21 | paddingRight: theme.spacing(0.25), 22 | }), 23 | }, 24 | }; 25 | 26 | export default InputAdornment; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/colors.ts: -------------------------------------------------------------------------------- 1 | export const gray = { 2 | 500: '#A3AED0', 3 | }; 4 | 5 | export const red = { 6 | 500: '#E31A1A', 7 | }; 8 | 9 | export const green = { 10 | 500: '#05CD99', 11 | }; 12 | 13 | export const blue = { 14 | 300: '#707EAE', 15 | 400: '#2B3674', 16 | 500: '#1B2559', 17 | }; 18 | 19 | export const skyblue = { 20 | 500: '#1C6CB7', 21 | }; 22 | 23 | export const purple = { 24 | 300: '#868CFF', 25 | 500: '#4318FF', 26 | }; 27 | 28 | export const yellow = { 29 | 500: '#FFB547', 30 | }; 31 | 32 | export const white = { 33 | 100: '#FFFFFF', 34 | 200: '#F4F7FE', 35 | 300: '#E9EDF7', 36 | }; 37 | 38 | export const transparentRed = { 39 | 500: '#EE5D501A', 40 | }; 41 | 42 | export const transparentGreen = { 43 | 500: '#05CD991A', 44 | }; 45 | 46 | export const transparentYellow = { 47 | 500: '#FFB01633', 48 | }; 49 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/utils/CssBaseline.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | import simplebar from 'theme/styles/simplebar'; 4 | import scrollbar from 'theme/styles/scrollbar'; 5 | import echart from 'theme/styles/echart'; 6 | 7 | const CssBaseline: Components>['MuiCssBaseline'] = { 8 | defaultProps: {}, 9 | styleOverrides: (theme) => ({ 10 | '*, *::before, *::after': { 11 | margin: 0, 12 | padding: 0, 13 | }, 14 | html: { 15 | scrollBehavior: 'smooth', 16 | }, 17 | body: { 18 | fontVariantLigatures: 'none', 19 | backgroundColor: theme.palette.info.main, 20 | ...scrollbar(theme), 21 | }, 22 | ...simplebar(theme), 23 | ...echart(), 24 | }), 25 | }; 26 | 27 | export default CssBaseline; 28 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/Reinforcement_models/Deep_Q-Learning.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef CONV_NETWORKS_HPP 3 | #define CONV_NETWORKS_HPP 4 | 5 | #include 6 | 7 | class ConvDQN : public torch::nn::Module 8 | { 9 | private: 10 | torch::nn::Sequential layers{nullptr}; 11 | int input_dimension; 12 | int action_number; 13 | 14 | public: 15 | ConvDQN(int input_dim, int action_number); 16 | 17 | torch::Tensor forward(torch::Tensor x); 18 | }; 19 | 20 | class ConvDuelingDQN : public torch::nn::Module 21 | { 22 | private: 23 | torch::nn::Sequential value_stream{nullptr}; 24 | torch::nn::Sequential advantage_stream{nullptr}; 25 | int input_dimension; 26 | int action_number; 27 | 28 | public: 29 | ConvDuelingDQN(int input_dim, int action_number); 30 | 31 | torch::Tensor forward(torch::Tensor x); 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/buttons/IconButton.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const IconButton: Components>['MuiIconButton'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | color: theme.palette.text.primary, 8 | backgroundColor: theme.palette.info.lighter, 9 | marginLeft: 0, 10 | }), 11 | sizeLarge: ({ theme }) => ({ 12 | padding: theme.spacing(1), 13 | fontSize: theme.typography.h3.fontSize, 14 | }), 15 | sizeMedium: ({ theme }) => ({ 16 | padding: theme.spacing(0.75), 17 | fontSize: theme.typography.h4.fontSize, 18 | }), 19 | sizeSmall: ({ theme }) => ({ 20 | padding: theme.spacing(0.5), 21 | fontSize: theme.typography.h6.fontSize, 22 | }), 23 | }, 24 | }; 25 | 26 | export default IconButton; 27 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/top-cards/spent/index.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import Stack from '@mui/material/Stack'; 3 | import Paper from '@mui/material/Paper'; 4 | import Typography from '@mui/material/Typography'; 5 | import SpentChart from './SpentChart'; 6 | 7 | const Spent = ({ balance }: { balance: number }) => { 8 | return ( 9 | 10 | 11 | 12 | Trades this month 13 | 14 | 15 | ${balance} 16 | 17 | 18 | 19 | 20 | 21 | ); 22 | }; 23 | 24 | export default Spent; 25 | -------------------------------------------------------------------------------- /Order-Manager-Server/include/Scheduler/scheduler.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SCHEDULER_HPP 2 | #define SCHEDULER_HPP 3 | #include 4 | #include 5 | #include 6 | #include "Queue/TSQueue.hpp" 7 | #include "Executor-Manager-Core/OrderDetails.hpp" 8 | #include "Executor-Manager-Core/OrderDetails.hpp" 9 | 10 | class Scheduler 11 | { 12 | public: 13 | void RoundRobin(std::string order); 14 | void Equalizer(std::string order); 15 | void Latency_Based(std::string order); 16 | void Liquidity_Based(std::string order); 17 | 18 | void Register_Provider(std::string name, TSQueue *Pointer_Queue) 19 | { 20 | Provider_Map[name] = Pointer_Queue; 21 | Provider_pointer.push_back(Pointer_Queue); 22 | } 23 | 24 | private: 25 | std::map *> Provider_Map; 26 | std::vector *> Provider_pointer; 27 | TSQueue orderQueue; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/base/ReactEchart.tsx: -------------------------------------------------------------------------------- 1 | import { forwardRef } from 'react'; 2 | import { Box, BoxProps } from '@mui/material'; 3 | import { EChartsReactProps } from 'echarts-for-react'; 4 | import EChartsReactCore from 'echarts-for-react/lib/core'; 5 | import ReactEChartsCore from 'echarts-for-react/lib/core'; 6 | 7 | export interface ReactEchartProps extends BoxProps { 8 | echarts: EChartsReactProps['echarts']; 9 | option: EChartsReactProps['option']; 10 | } 11 | 12 | const ReactEchart = forwardRef( 13 | ({ option, ...rest }, ref) => { 14 | return ( 15 | 27 | ); 28 | }, 29 | ); 30 | 31 | export default ReactEchart; 32 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/inputs/Select.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const Select: Components>['MuiSelect'] = { 5 | styleOverrides: { 6 | root: { 7 | padding: 0, 8 | '&.MuiInputBase-root': { 9 | backgroundColor: 'transparent !important', 10 | border: 'none', 11 | }, 12 | }, 13 | select: ({ theme }) => ({ 14 | padding: theme.spacing(1), 15 | paddingLeft: theme.spacing(1.25), 16 | paddingRight: '0 !important', 17 | backgroundColor: 'transparent !important', 18 | fontSize: theme.typography.body2.fontSize, 19 | color: theme.palette.text.disabled, 20 | fontWeight: 600, 21 | }), 22 | icon: ({ theme }) => ({ 23 | color: theme.palette.text.disabled, 24 | fontSize: theme.typography.h4.fontSize, 25 | }), 26 | }, 27 | }; 28 | 29 | export default Select; 30 | -------------------------------------------------------------------------------- /Computing-Server/include/IO-Broker-Core/RedisDBManager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef REDIS_DB_MANAGER_HPP 2 | #define REDIS_DB_MANAGER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class RedisDBManager 10 | { 11 | public: 12 | RedisDBManager(const std::string &host = "127.0.0.1", int port = 6379); 13 | ~RedisDBManager(); 14 | 15 | bool connect(); 16 | void publishCreateMessage(const std::string &dbFileName, const std::string &sqlStructure, const std::vector &channels); 17 | void publishInsertMessage(const std::string &dbFileName, const std::string &dataToInsert, const std::vector &channels); 18 | void publishLogMessage(const std::string &dataToInsert, const std::vector &channels); 19 | 20 | private : redisContext *context; 21 | std::string host; 22 | int port; 23 | 24 | bool publishMessage(const std::string &channel, const std::string &message); 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/layouts/main-layout/index.tsx: -------------------------------------------------------------------------------- 1 | import { useState, PropsWithChildren } from 'react'; 2 | import Stack from '@mui/material/Stack'; 3 | import Sidebar from 'layouts/main-layout/sidebar'; 4 | import Topbar from 'layouts/main-layout/topbar'; 5 | 6 | const MainLayout = ({ children }: PropsWithChildren) => { 7 | const [mobileOpen, setMobileOpen] = useState(false); 8 | const [isClosing, setIsClosing] = useState(false); 9 | 10 | return ( 11 | 12 | 13 | 20 | 21 | {children} 22 | 23 | 24 | ); 25 | }; 26 | 27 | export default MainLayout; 28 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/inputs/Checkbox.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | import IconifyIcon from 'components/base/IconifyIcon'; 4 | 5 | const Checkbox: Components>['MuiCheckbox'] = { 6 | defaultProps: { 7 | icon: , 8 | checkedIcon: , 9 | indeterminateIcon: , 10 | }, 11 | styleOverrides: { 12 | root: ({ theme }) => ({ 13 | color: theme.palette.info.dark, 14 | }), 15 | sizeMedium: ({ theme }) => ({ 16 | padding: theme.spacing(0.75), 17 | '& .MuiBox-root': { 18 | fontSize: theme.typography.h5.fontSize, 19 | }, 20 | }), 21 | sizeSmall: ({ theme }) => ({ 22 | '& .MuiBox-root': { 23 | fontSize: theme.typography.h6.fontSize, 24 | }, 25 | }), 26 | }, 27 | }; 28 | 29 | export default Checkbox; -------------------------------------------------------------------------------- /Computing-Server/src/Orderbook/order_.cpp: -------------------------------------------------------------------------------- 1 | #include "Orderbook/order_.hpp" 2 | 3 | Order_::Order_(OrderType orderType, OrderId orderId, Side side, Price price, Quantity quantity) 4 | : orderType_{orderType}, orderId_{orderId}, side_{side}, price_{price}, initialQuantity_{quantity}, remainingQuantity_{quantity} {} 5 | 6 | OrderId Order_::GetOrderId() const { return orderId_; } 7 | OrderType Order_::GetOrderType() const { return orderType_; } 8 | Side Order_::GetSide() const { return side_; } 9 | Price Order_::GetPrice() const { return price_; } 10 | Quantity Order_::GetInitialQuantity() const { return initialQuantity_; } 11 | Quantity Order_::GetRemainingQuantity() const { return remainingQuantity_; } 12 | Quantity Order_::GetFilledQuantity() const { return initialQuantity_ - remainingQuantity_; } 13 | bool Order_::IsFilled() const { return GetRemainingQuantity() == 0; } 14 | 15 | void Order_::Fill(Quantity quantity) 16 | { 17 | if (quantity > GetRemainingQuantity()) 18 | { 19 | 20 | return; 21 | } 22 | remainingQuantity_ -= quantity; 23 | } -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/time_series_models/SARIMA.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../indicator/Indicator.hpp" 4 | #include 5 | #include 6 | #include "Utilities/SignalResult.hpp" 7 | 8 | class SARIMA : public Indicator 9 | { 10 | private: 11 | int p; // Order of the autoregressive part 12 | int d; // Degree of differencing 13 | int q; // Order of the moving average part 14 | int P; // Seasonal order of the autoregressive part 15 | int D; // Seasonal degree of differencing 16 | int Q; // Seasonal order of the moving average part 17 | int s; // Seasonal period 18 | 19 | public: 20 | SARIMA(const std::string &indicatorName, int p, int d, int q, int P, int D, int Q, int s) 21 | : Indicator(indicatorName, p + d + q + P + D + Q), p(p), d(d), q(q), P(P), D(D), Q(Q), s(s) {} 22 | 23 | SignalResult calculateSignal() override; 24 | static std::vector fitSARIMA(const std::vector &data, int p, int d, int q, int P, int D, int Q, int s); 25 | }; 26 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/Reinforcement_models/Agent_QNetwork.hpp: -------------------------------------------------------------------------------- 1 | #ifndef Agent_HPP 2 | #define Agent_HPP 3 | 4 | #include "AlgoEngine-Core/Reinforcement_models/QNetwork.hpp" 5 | #include 6 | #include 7 | 8 | class Agent 9 | { 10 | public: 11 | Agent(double alpha, double gamma, double epsilon); 12 | void train(const std::vector> &market_data, double &total_balance); 13 | 14 | private: 15 | torch::Tensor get_state(const std::vector &market_data); 16 | int choose_action(const torch::Tensor &state); 17 | void update_q_network(const torch::Tensor &state, int action, double reward, const torch::Tensor &next_state); 18 | void update_epsilon(); 19 | void execute_action(int action, double &total_balance, const std::vector &bids, const std::vector &asks); 20 | 21 | double alpha_; 22 | double gamma_; 23 | double epsilon_; 24 | double epsilon_min_ = 0.01; 25 | double epsilon_decay_ = 0.995; 26 | std::shared_ptr model_; 27 | torch::optim::Adam optimizer_; 28 | torch::Device device_; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Order-Manager-Server/include/Queue/TSQueue.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TSQUEUE_HPP 2 | #define TSQUEUE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | template 9 | class TSQueue 10 | { 11 | private: 12 | std::queue m_queue; 13 | mutable std::mutex m_mutex; 14 | std::condition_variable m_cond; 15 | 16 | public: 17 | void push(T item) 18 | { 19 | std::unique_lock lock(m_mutex); 20 | m_queue.push(std::move(item)); 21 | m_cond.notify_one(); 22 | } 23 | 24 | T pop() 25 | { 26 | std::unique_lock lock(m_mutex); 27 | m_cond.wait(lock, [this] 28 | { return !m_queue.empty(); }); 29 | T item = std::move(m_queue.front()); 30 | m_queue.pop(); 31 | return item; 32 | } 33 | 34 | bool empty() const 35 | { 36 | std::lock_guard lock(m_mutex); 37 | return m_queue.empty(); 38 | } 39 | 40 | size_t size() const 41 | { 42 | std::lock_guard lock(m_mutex); 43 | return m_queue.size(); 44 | } 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/top-cards/activity/index.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import Stack from '@mui/material/Stack'; 3 | import Paper from '@mui/material/Paper'; 4 | import Typography from '@mui/material/Typography'; 5 | import ActivityChart from './ActivityChart'; 6 | 7 | const Activity = () => { 8 | return ( 9 | ({ 14 | px: 3, 15 | py: 2.5, 16 | background: `linear-gradient(135deg, ${theme.palette.gradients.primary.state} 0%, ${theme.palette.gradients.primary.main} 100%)`, 17 | })} 18 | > 19 | 20 | 21 | Activity 22 | 23 | 24 | $540.50 25 | 26 | 27 | 28 | 29 | 30 | ); 31 | }; 32 | 33 | export default Activity; 34 | -------------------------------------------------------------------------------- /Computing-Server/include/Orderbook/order_.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ORDER_H 2 | #define ORDER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | enum class OrderType 9 | { 10 | GoodTillCancel, 11 | FillAndKill 12 | }; 13 | 14 | enum class Side 15 | { 16 | Buy, 17 | Sell 18 | }; 19 | 20 | using Price = std::int32_t; 21 | using Quantity = std::uint32_t; 22 | using OrderId = std::uint64_t; 23 | 24 | class Order_ 25 | { 26 | public: 27 | Order_(OrderType orderType, OrderId orderId, Side side, Price price, Quantity quantity); 28 | OrderId GetOrderId() const; 29 | OrderType GetOrderType() const; 30 | Side GetSide() const; 31 | Price GetPrice() const; 32 | Quantity GetInitialQuantity() const; 33 | Quantity GetRemainingQuantity() const; 34 | Quantity GetFilledQuantity() const; 35 | bool IsFilled() const; 36 | void Fill(Quantity quantity); 37 | 38 | private: 39 | OrderType orderType_; 40 | OrderId orderId_; 41 | Side side_; 42 | Price price_; 43 | Quantity initialQuantity_; 44 | Quantity remainingQuantity_; 45 | }; 46 | 47 | using OrderPointer = std::shared_ptr; 48 | 49 | #endif -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:@typescript-eslint/recommended', 7 | 'plugin:react-hooks/recommended', 8 | 'plugin:prettier/recommended', 9 | ], 10 | ignorePatterns: ['dist', '.eslintrc.cjs'], 11 | parser: '@typescript-eslint/parser', 12 | plugins: ['react-refresh'], 13 | rules: { 14 | 'react-refresh/only-export-components': [ 15 | 'warn', 16 | { allowConstantExport: true }, 17 | ], 18 | 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], 19 | 'react/react-in-jsx-scope': 'off', 20 | 'react/no-unescaped-entities': 'off', 21 | 'prettier/prettier': ['error', { endOfLine: 'auto' }], 22 | 'prettier/prettier': 'off', 23 | 'no-unused-vars': 'off', 24 | '@typescript-eslint/no-unused-vars': 'error', 25 | '@typescript-eslint/no-empty-interface': 'off', 26 | 'react-refresh/only-export-components': 'off', 27 | 'react-hooks/exhaustive-deps': 'off', 28 | 'react-hooks/rules-of-hooks': 'off', 29 | '@typescript-eslint/ban-ts-comment': 'off', 30 | }, 31 | } -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/PERatio.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/PERatio.hpp" 2 | #include 3 | #include 4 | 5 | SignalResult PERatio::calculateSignal() 6 | { 7 | if (historicalData.empty()) 8 | { 9 | throw std::runtime_error("Historical data is empty."); 10 | } 11 | 12 | if (eps <= 0) 13 | { 14 | throw std::runtime_error("Earnings per share must be greater than zero."); 15 | } 16 | 17 | std::vector peRatios; 18 | for (const auto &bar : historicalData) 19 | { 20 | double peRatio = bar.close / eps; 21 | peRatios.push_back(peRatio); 22 | signals.push_back(SignalResult(peRatio)); 23 | } 24 | 25 | return SignalResult(signals.back()); 26 | } 27 | 28 | std::vector PERatio::calculate(const std::vector &data, double earningsPerShare) 29 | { 30 | if (data.empty() || earningsPerShare <= 0) 31 | return {}; 32 | 33 | std::vector peRatios; 34 | for (const auto &bar : data) 35 | { 36 | double peRatio = bar.close / earningsPerShare; 37 | peRatios.push_back(peRatio); 38 | } 39 | 40 | return peRatios; 41 | } -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/routes/sitemap.ts: -------------------------------------------------------------------------------- 1 | 2 | export interface SubMenuItem { 3 | name: string; 4 | pathName: string; 5 | path: string; 6 | icon?: string; 7 | active?: boolean; 8 | items?: SubMenuItem[]; 9 | } 10 | 11 | export interface MenuItem { 12 | id: string; 13 | subheader: string; 14 | path?: string; 15 | icon?: string; 16 | avatar?: string; 17 | active?: boolean; 18 | items?: SubMenuItem[]; 19 | } 20 | 21 | const sitemap: MenuItem[] = [ 22 | { 23 | id: 'dashboard', 24 | subheader: 'Dashboard', 25 | path: '/', 26 | icon: 'ri:dashboard-fill', 27 | active: true, 28 | }, 29 | { 30 | id: 'Logs', 31 | subheader: 'Logs', 32 | path: '/logs', 33 | icon: 'ic:baseline-show-chart', 34 | active: false, 35 | }, 36 | { 37 | id: 'Portfolio', 38 | subheader: 'Portfolio', 39 | path: '/Portfolio', 40 | icon: 'lineicons:bar-chart-dollar', 41 | active: false, 42 | }, 43 | 44 | 45 | 46 | 47 | ]; 48 | 49 | const updateActiveState = (id: string) => { 50 | sitemap.forEach((item) => { 51 | item.active = item.id === id; 52 | }); 53 | }; 54 | 55 | export { updateActiveState }; 56 | 57 | export default sitemap; 58 | -------------------------------------------------------------------------------- /Order-Manager-Server/include/Executor-Manager-Core/executor_manager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ORDERMANAGER_HPP 2 | #define ORDERMANAGER_HPP 3 | 4 | #include "order.hpp" 5 | #include "APIClient.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "Queue/TSQueue.hpp" 12 | #include "OrderDetails.hpp" 13 | 14 | class ExecutorManager 15 | { 16 | private: 17 | APIClient apiClient; 18 | TSQueue orderQueue; 19 | 20 | public: 21 | ExecutorManager() 22 | : apiClient(std::getenv("APCA_API_KEY_ID"), std::getenv("APCA_API_SECRET_KEY")) {} 23 | 24 | void createOrder(OrderDetails order_Details); 25 | 26 | void processOrderQueue(); 27 | void getAllOrders(); 28 | void deleteAllOrders(); 29 | void getOrderById(const std::string &orderId); 30 | void deleteOrderById(const std::string &orderId); 31 | 32 | std::string getOpenPosition(const std::string &symbol); 33 | std::string closePosition(const std::string &symbol); 34 | 35 | TSQueue *getOrderQueuePointer() 36 | { 37 | return &orderQueue; 38 | } 39 | 40 | private: 41 | Order parseOrderFromJson(const std::string &response); 42 | }; 43 | 44 | #endif -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/DividendYield.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/DividendYield.hpp" 2 | #include 3 | #include 4 | 5 | SignalResult DividendYield::calculateSignal() 6 | { 7 | if (historicalData.empty()) 8 | { 9 | throw std::runtime_error("Historical data is empty."); 10 | } 11 | 12 | if (dps <= 0) 13 | { 14 | throw std::runtime_error("Dividend per share must be greater than zero."); 15 | } 16 | 17 | signals.reserve(historicalData.size()); 18 | for (const auto &bar : historicalData) 19 | { 20 | double dividendYield = dps / bar.close; 21 | signals.push_back(dividendYield); 22 | } 23 | 24 | return SignalResult(signals.back()); 25 | } 26 | 27 | std::vector DividendYield::calculate(const std::vector &data, double dividendPerShare) 28 | { 29 | if (data.empty() || dividendPerShare <= 0) 30 | return {}; 31 | 32 | std::vector dividendYields; 33 | dividendYields.reserve(data.size()); 34 | 35 | for (const auto &bar : data) 36 | { 37 | double dividendYield = dividendPerShare / bar.close; 38 | dividendYields.push_back(dividendYield); 39 | } 40 | 41 | return dividendYields; 42 | } -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/MA.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/MA.hpp" 2 | #include 3 | #include 4 | 5 | SignalResult MA::calculateSignal() 6 | { 7 | if (historicalData.size() < period) 8 | { 9 | throw std::runtime_error("Not enough data to calculate MA."); 10 | } 11 | 12 | double sum = std::accumulate(historicalData.end() - period, historicalData.end(), 0.0, 13 | [](double accumulator, const OHLCV &data) { 14 | return accumulator + data.close; 15 | }); 16 | double ma = sum / period; 17 | 18 | signals.push_back(SignalResult(ma)); 19 | return SignalResult(ma); 20 | } 21 | 22 | std::vector MA::calculate(const std::vector &data, int period) 23 | { 24 | std::vector maValues; 25 | if (data.size() < period) 26 | return maValues; 27 | 28 | for (size_t i = period - 1; i < data.size(); ++i) 29 | { 30 | double sum = 0.0; 31 | for (size_t j = 0; j < period; ++j) 32 | { 33 | sum += data[i - j].close; 34 | } 35 | maValues.push_back(sum / period); 36 | } 37 | 38 | return maValues; 39 | } -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/Bar.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BAR_HPP 2 | #define BAR_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "./OHLCV.hpp" 8 | 9 | class Bar { 10 | public: 11 | std::string time; 12 | std::string symbol; 13 | double open; 14 | double high; 15 | double low; 16 | double close; 17 | long volume; 18 | 19 | // Constructor that initializes all member variables 20 | Bar(const std::string& sys) 21 | : symbol(sys), open(0.0), high(0.0), low(0.0), close(0.0), volume(0) {} 22 | 23 | void fromJson(const Json::Value& json) { 24 | time = json["t"].asString(); 25 | open = json["o"].asDouble(); 26 | high = json["h"].asDouble(); 27 | low = json["l"].asDouble(); 28 | close = json["c"].asDouble(); 29 | volume = json["v"].asInt64(); 30 | } 31 | 32 | void print() const { 33 | std::cout << "Time: " << time 34 | << ", Symbol: " << symbol 35 | << ", Open: " << open 36 | << ", High: " << high 37 | << ", Low: " << low 38 | << ", Close: " << close 39 | << ", Volume: " << volume << std::endl; 40 | } 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/typography.ts: -------------------------------------------------------------------------------- 1 | import { TypographyOptions } from '@mui/material/styles/createTypography'; 2 | 3 | export const fontFamily = { 4 | poppins: ['Poppins', 'sans-serif'].join(','), 5 | DMSans: ['DM Sans', 'sans-serif'].join(','), 6 | }; 7 | 8 | const typography: TypographyOptions = { 9 | fontFamily: fontFamily.DMSans, 10 | h1: { 11 | fontSize: '3rem', 12 | fontWeight: 700, 13 | }, 14 | h2: { 15 | fontSize: '2.125rem', 16 | fontWeight: 700, 17 | }, 18 | h3: { 19 | fontSize: '1.75rem', 20 | fontWeight: 700, 21 | }, 22 | h4: { 23 | fontSize: '1.5rem', 24 | fontWeight: 700, 25 | }, 26 | h5: { 27 | fontSize: '1.25rem', 28 | fontWeight: 700, 29 | }, 30 | h6: { 31 | fontSize: '1.125rem', 32 | fontWeight: 700, 33 | }, 34 | subtitle1: { 35 | fontSize: '1rem', 36 | fontWeight: 400, 37 | }, 38 | subtitle2: { 39 | fontSize: '0.875rem', 40 | fontWeight: 500, 41 | }, 42 | body1: { 43 | fontSize: '1rem', 44 | fontWeight: 400, 45 | }, 46 | body2: { 47 | fontSize: '0.875rem', 48 | fontWeight: 400, 49 | }, 50 | caption: { 51 | fontSize: '0.75rem', 52 | fontWeight: 600, 53 | }, 54 | button: { 55 | fontSize: '1rem', 56 | fontWeight: 500, 57 | }, 58 | }; 59 | 60 | export default typography; 61 | -------------------------------------------------------------------------------- /Computing-Server/include/Risk-Analysis-Core/RiskAdjustedMetrics.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RISKADJUSTEDMETRICS_HPP 2 | #define RISKADJUSTEDMETRICS_HPP 3 | 4 | #include 5 | 6 | class RiskAdjustedMetrics 7 | { 8 | private: 9 | double total_return; 10 | double total_risk; 11 | double sharpe_ratio; 12 | double sortino_ratio; 13 | double calmar_ratio; 14 | double information_ratio; 15 | double treynor_ratio; 16 | 17 | double calculate_max_drawdown(const std::vector &returns); 18 | 19 | public: 20 | RiskAdjustedMetrics() : total_return(0.0), total_risk(0.0), sharpe_ratio(0.0), 21 | sortino_ratio(0.0), calmar_ratio(0.0), 22 | information_ratio(0.0), treynor_ratio(0.0) {} 23 | 24 | double calculate_standard_deviation(const std::vector &returns); 25 | double calculate_sharpe_ratio(double risk_free_rate); 26 | double calculate_sortino_ratio(const std::vector &returns, double target_return); 27 | double calculate_calmar_ratio(const std::vector &returns); 28 | double calculate_information_ratio(double benchmark_return); 29 | double calculate_treynor_ratio(double risk_free_rate, double portfolio_beta); 30 | 31 | void set_total_return(double return_value); 32 | void set_total_risk(double risk_value); 33 | }; 34 | 35 | #endif -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/SignalResult.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SIGNALRESULT_HPP 2 | #define SIGNALRESULT_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class SignalResult 10 | { 11 | public: 12 | using ResultType = std::variant>; 13 | 14 | SignalResult(double singleValue) : value(singleValue) {} 15 | SignalResult(const std::vector &vectorValue) : value(vectorValue) {} 16 | 17 | SignalResult(const SignalResult &other) = default; 18 | 19 | SignalResult &operator=(const SignalResult &other) = default; 20 | 21 | bool isSingleValue() const 22 | { 23 | return std::holds_alternative(value); 24 | } 25 | 26 | double getSingleValue() const 27 | { 28 | if (isSingleValue()) 29 | { 30 | return std::get(value); 31 | } 32 | std::cerr << "Error: SignalResult does not hold a single value (double)." << std::endl; 33 | throw std::bad_variant_access(); 34 | } 35 | 36 | std::vector getVectorValue() const 37 | { 38 | if (!isSingleValue()) 39 | { 40 | return std::get>(value); 41 | } 42 | throw std::bad_variant_access(); 43 | } 44 | 45 | private: 46 | ResultType value; 47 | }; 48 | 49 | #endif -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/common/DataGridFooter.tsx: -------------------------------------------------------------------------------- 1 | import Stack from '@mui/material/Stack'; 2 | import Typography from '@mui/material/Typography'; 3 | import Pagination from '@mui/material/Pagination'; 4 | import { 5 | gridPageSelector, 6 | gridPageCountSelector, 7 | useGridApiContext, 8 | useGridSelector, 9 | gridPageSizeSelector, 10 | } from '@mui/x-data-grid'; 11 | 12 | const DataGridFooter = () => { 13 | const apiRef = useGridApiContext(); 14 | const page = useGridSelector(apiRef, gridPageSelector); 15 | const pageCount = useGridSelector(apiRef, gridPageCountSelector); 16 | const pageSize = useGridSelector(apiRef, gridPageSizeSelector); 17 | const rowsCount = apiRef.current.getRowsCount(); 18 | 19 | return ( 20 | 21 | {`${page * pageSize + 1}-${page * pageSize + pageSize} of ${rowsCount}`} 25 | { 30 | event.preventDefault(); 31 | apiRef.current.setPage(value - 1); 32 | }} 33 | /> 34 | 35 | ); 36 | }; 37 | 38 | export default DataGridFooter; 39 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/time_series_models/VAR.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/time_series_models/VAR.hpp" 2 | #include 3 | #include 4 | 5 | std::vector> VAR::fitVAR(const std::vector> &data) 6 | { 7 | if (data.size() < lagOrder + 1) 8 | throw std::invalid_argument("Insufficient data to fit VAR model."); 9 | 10 | std::vector> predictions(data[0].size(), std::vector(data.size())); 11 | for (size_t i = lagOrder; i < data[0].size(); ++i) 12 | { 13 | for (size_t j = 0; j < data.size(); ++j) 14 | { 15 | predictions[j][i] = data[j][i].close; 16 | } 17 | } 18 | 19 | return predictions; 20 | } 21 | 22 | SignalResult VAR::calculateSignal() 23 | { 24 | if (historicalData.empty()) 25 | return SignalResult(0.0); 26 | 27 | std::vector> multiData; 28 | for (const OHLCV &ohlcv : historicalData) 29 | { 30 | multiData.push_back({ohlcv}); 31 | } 32 | 33 | std::vector> predictions = fitVAR(multiData); 34 | 35 | double latestPrediction = predictions[0].back(); 36 | 37 | if (latestPrediction > historicalData.back().close) 38 | { 39 | return SignalResult(latestPrediction); 40 | } 41 | else 42 | { 43 | return SignalResult(-latestPrediction); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/layouts/main-layout/sidebar/index.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import Drawer from '@mui/material/Drawer'; 3 | import DrawerItems from './DrawerItems'; 4 | 5 | interface SidebarProps { 6 | mobileOpen: boolean; 7 | setMobileOpen: React.Dispatch>; 8 | setIsClosing: React.Dispatch>; 9 | } 10 | 11 | const Sidebar = ({ mobileOpen, setMobileOpen, setIsClosing }: SidebarProps) => { 12 | const handleDrawerClose = () => { 13 | setIsClosing(true); 14 | setMobileOpen(false); 15 | }; 16 | 17 | const handleDrawerTransitionEnd = () => { 18 | setIsClosing(false); 19 | }; 20 | 21 | return ( 22 | 28 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | ); 44 | }; 45 | 46 | export default Sidebar; 47 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/top-cards/earnings/index.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import Stack from '@mui/material/Stack'; 3 | import Paper from '@mui/material/Paper'; 4 | import Typography from '@mui/material/Typography'; 5 | import IconifyIcon from 'components/base/IconifyIcon'; 6 | 7 | interface EarningsProps { 8 | earnings: number; 9 | } 10 | 11 | const Earnings = ({ earnings }: EarningsProps) => { 12 | return ( 13 | 19 | 20 | 28 | 29 | 30 | 31 | 32 | Earnings 33 | 34 | 35 | ${earnings.toFixed(2)} 36 | 37 | 38 | 39 | 40 | ); 41 | }; 42 | 43 | export default Earnings; 44 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/total-spent/index.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import Stack from '@mui/material/Stack'; 3 | import Paper from '@mui/material/Paper'; 4 | import Typography from '@mui/material/Typography'; 5 | import IconifyIcon from 'components/base/IconifyIcon'; 6 | import TotalSpentChart from './TotalSpentChart'; 7 | 8 | const TotalSpent = () => { 9 | return ( 10 | 11 | 12 | 13 | 14 | Total Spent 15 | 16 | 17 | $682.5 18 | 19 | 20 | 28 | 29 | 30 | 31 | 32 | 36 | 37 | ); 38 | }; 39 | 40 | export default TotalSpent; 41 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/earnings/index.tsx: -------------------------------------------------------------------------------- 1 | import Chip from '@mui/material/Chip'; 2 | import Paper from '@mui/material/Paper'; 3 | import Stack from '@mui/material/Stack'; 4 | import Typography from '@mui/material/Typography'; 5 | import IconifyIcon from 'components/base/IconifyIcon'; 6 | import EarningsChart from './EarningsChart'; 7 | 8 | const Earnings = () => { 9 | return ( 10 | 11 | 21 | 22 | 23 | 24 | 25 | This month earnings 26 | 27 | 28 | $682.5 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | ); 38 | }; 39 | 40 | export default Earnings; 41 | -------------------------------------------------------------------------------- /DataBroker-Server/include/Utilities/Bar.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BAR_HPP 2 | #define BAR_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include "./OHLCV.hpp" 8 | 9 | class Bar { 10 | public: 11 | std::string time; 12 | std::string symbol; 13 | double open; 14 | double high; 15 | double low; 16 | double close; 17 | long volume; 18 | 19 | // Constructor that initializes all member variables 20 | explicit Bar(const std::string &sys) 21 | : symbol(sys), open(0.0), high(0.0), low(0.0), close(0.0), volume(0) {} 22 | 23 | /** 24 | * @brief Populates the Bar object from a JSON value. 25 | * 26 | * @param json The JSON value containing the bar data. 27 | */ 28 | void fromJson(const Json::Value &json) { 29 | time = json["t"].asString(); 30 | open = json["o"].asDouble(); 31 | high = json["h"].asDouble(); 32 | low = json["l"].asDouble(); 33 | close = json["c"].asDouble(); 34 | volume = json["v"].asInt64(); 35 | } 36 | 37 | /** 38 | * @brief Prints the Bar object data to the standard output. 39 | */ 40 | void print() const { 41 | std::cout << "Time: " << time 42 | << ", Symbol: " << symbol 43 | << ", Open: " << open 44 | << ", High: " << high 45 | << ", Low: " << low 46 | << ", Close: " << close 47 | << ", Volume: " << volume << std::endl; 48 | } 49 | }; 50 | 51 | #endif // BAR_HPP 52 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/OBV.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/OBV.hpp" 2 | #include 3 | 4 | SignalResult OBV::calculateSignal() 5 | { 6 | if (historicalData.empty()) 7 | { 8 | throw std::runtime_error("No historical data available to calculate OBV."); 9 | } 10 | 11 | std::vector obvValues; 12 | double obv = 0.0; 13 | 14 | for (size_t i = 1; i < historicalData.size(); ++i) 15 | { 16 | if (historicalData[i].close > historicalData[i - 1].close) 17 | { 18 | obv += historicalData[i].volume; 19 | } 20 | else if (historicalData[i].close < historicalData[i - 1].close) 21 | { 22 | obv -= historicalData[i].volume; 23 | } 24 | obvValues.push_back(obv); 25 | } 26 | 27 | signals.push_back(SignalResult(obvValues)); 28 | return SignalResult(signals.back()); 29 | } 30 | 31 | std::vector OBV::calculate(const std::vector &data) 32 | { 33 | std::vector obvValues; 34 | if (data.empty()) 35 | return obvValues; 36 | 37 | double obv = 0.0; 38 | 39 | for (size_t i = 1; i < data.size(); ++i) 40 | { 41 | if (data[i].close > data[i - 1].close) 42 | obv += data[i].volume; 43 | else if (data[i].close < data[i - 1].close) 44 | obv -= data[i].volume; 45 | 46 | obvValues.push_back(obv); 47 | } 48 | 49 | return obvValues; 50 | } -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/VWAP.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/VWAP.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | SignalResult VWAP::calculateSignal() 7 | { 8 | if (historicalData.empty()) 9 | { 10 | throw std::runtime_error("Historical data is empty."); 11 | } 12 | 13 | std::vector vwapValues; 14 | double cumulativeVolume = 0.0; 15 | double cumulativePriceVolume = 0.0; 16 | 17 | for (const auto &bar : historicalData) 18 | { 19 | double priceVolume = bar.close * bar.volume; 20 | cumulativeVolume += bar.volume; 21 | cumulativePriceVolume += priceVolume; 22 | 23 | double vwap = cumulativePriceVolume / cumulativeVolume; 24 | vwapValues.push_back(vwap); 25 | signals.push_back(SignalResult(vwap)); 26 | } 27 | 28 | return SignalResult(vwapValues); 29 | } 30 | 31 | std::vector VWAP::calculate(const std::vector &data) 32 | { 33 | if (data.empty()) 34 | return {}; 35 | 36 | std::vector vwapValues; 37 | double cumulativeVolume = 0.0; 38 | double cumulativePriceVolume = 0.0; 39 | 40 | for (const auto &bar : data) 41 | { 42 | double priceVolume = bar.close * bar.volume; 43 | cumulativeVolume += bar.volume; 44 | cumulativePriceVolume += priceVolume; 45 | 46 | double vwap = cumulativePriceVolume / cumulativeVolume; 47 | vwapValues.push_back(vwap); 48 | } 49 | 50 | return vwapValues; 51 | } -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/inputs/InputBase.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const InputBase: Components>['MuiInputBase'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | border: 1, 8 | borderStyle: 'solid', 9 | borderColor: theme.palette.info.main, 10 | borderRadius: theme.shape.borderRadius, 11 | backgroundColor: `${theme.palette.info.light} !important`, 12 | fontSize: theme.typography.subtitle2.fontSize, 13 | color: theme.palette.text.secondary, 14 | padding: theme.spacing(1.25, 2), 15 | letterSpacing: 0.5, 16 | 17 | '&:focus-within': { 18 | borderColor: theme.palette.primary.main, 19 | }, 20 | 21 | '&:before, &:after': { 22 | display: 'none', 23 | }, 24 | }), 25 | colorSecondary: ({ theme }) => ({ 26 | backgroundColor: `${theme.palette.info.dark} !important`, 27 | }), 28 | sizeSmall: ({ theme }) => ({ 29 | padding: theme.spacing(1, 1.25), 30 | paddingLeft: `${theme.spacing(1.75)} !important`, 31 | fontSize: theme.typography.caption.fontSize, 32 | }), 33 | input: ({ theme }) => ({ 34 | '&::placeholder': { 35 | color: theme.palette.text.secondary, 36 | opacity: 1, 37 | }, 38 | }), 39 | inputSizeSmall: ({ theme }) => ({ 40 | marginBottom: theme.spacing(0.2), 41 | }), 42 | }, 43 | }; 44 | 45 | export default InputBase; -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/ReplayMemory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct Transition 13 | { 14 | torch::Tensor state; 15 | torch::Tensor action; 16 | torch::Tensor next_state; 17 | torch::Tensor reward; 18 | 19 | Transition(torch::Tensor s, torch::Tensor a, torch::Tensor ns, torch::Tensor r) 20 | : state(s), action(a), next_state(ns), reward(r) {} 21 | }; 22 | 23 | class ReplayMemory 24 | { 25 | public: 26 | explicit ReplayMemory(size_t capacity) : capacity(capacity) {} 27 | 28 | void push(const Transition &transition) 29 | { 30 | if (memory.size() >= capacity) 31 | { 32 | memory.pop_front(); 33 | } 34 | memory.push_back(transition); 35 | } 36 | 37 | std::vector sample(size_t batch_size) 38 | { 39 | std::vector batch; 40 | std::random_device rd; 41 | std::mt19937 gen(rd()); 42 | 43 | for (size_t i = 0; i < batch_size && i < memory.size(); ++i) 44 | { 45 | std::uniform_int_distribution<> dis(0, memory.size() - 1); 46 | batch.push_back(memory[dis(gen)]); 47 | } 48 | return batch; 49 | } 50 | 51 | size_t size() const { return memory.size(); } 52 | 53 | private: 54 | size_t capacity; 55 | std::deque memory; 56 | }; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/layouts/main-layout/sidebar/list-items/ListItem.tsx: -------------------------------------------------------------------------------- 1 | import { MenuItem } from 'routes/sitemap'; 2 | import Link from '@mui/material/Link'; 3 | import ListItemIcon from '@mui/material/ListItemIcon'; 4 | import ListItemButton from '@mui/material/ListItemButton'; 5 | import ListItemText from '@mui/material/ListItemText'; 6 | import IconifyIcon from 'components/base/IconifyIcon'; 7 | import { updateActiveState } from 'routes/sitemap'; 8 | 9 | const ListItem = ({ id, subheader, icon, path, active }: MenuItem) => { 10 | const handleClick = () => { 11 | updateActiveState(id); 12 | }; 13 | 14 | return ( 15 | 27 | 28 | {icon && ( 29 | 36 | )} 37 | 38 | 46 | 47 | ); 48 | }; 49 | 50 | export default ListItem; 51 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianGARCHTrading.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianGARCHTrading.hpp" 2 | #include 3 | 4 | std::vector BayesianGARCHTrading::estimateGARCH(const std::vector &data, int period) 5 | { 6 | if (data.size() < period) 7 | throw std::invalid_argument("Insufficient data to estimate GARCH model."); 8 | 9 | std::vector volatilities; 10 | double omega = 0.1; // Constant term 11 | double alpha = 0.2; 12 | double beta = 0.7; 13 | 14 | double lastVariance = data[0].close * data[0].close; 15 | 16 | for (size_t i = 1; i < data.size(); ++i) 17 | { 18 | double return_t = (data[i].close - data[i - 1].close) / data[i - 1].close; 19 | lastVariance = omega + alpha * return_t * return_t + beta * lastVariance; 20 | volatilities.push_back(std::sqrt(lastVariance)); 21 | } 22 | 23 | return volatilities; 24 | } 25 | 26 | SignalResult BayesianGARCHTrading::calculateSignal() 27 | { 28 | if (historicalData.size() < period) 29 | return SignalResult(0.0); 30 | 31 | std::vector volatilities = estimateGARCH(historicalData, period); 32 | 33 | double latestVolatility = volatilities.back(); 34 | 35 | double threshold = 0.02; // Example threshold, can be adjusted 36 | 37 | if (latestVolatility > threshold) 38 | { 39 | return SignalResult(latestVolatility); 40 | } 41 | else 42 | { 43 | return SignalResult(-latestVolatility); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Computing-Server/include/Order-Manager-Core/order_manager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ORDERMANAGER_HPP 2 | #define ORDERMANAGER_HPP 3 | 4 | #include "order.hpp" 5 | #include "APIClient.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class OrderManager 13 | { 14 | private: 15 | APIClient apiClient; 16 | 17 | public: 18 | OrderManager() 19 | : apiClient(std::getenv("APCA_API_KEY_ID"), std::getenv("APCA_API_SECRET_KEY")) {} 20 | 21 | void createOrder(const std::string &side, const std::string &type, const std::string &timeInForce, 22 | const std::string &symbol, const std::string &qty, 23 | const std::optional &limitPrice, 24 | const std::optional &stopPrice, 25 | const std::optional &trailPrice, 26 | const std::optional &trailPercent); 27 | 28 | void processOrderQueue(); 29 | void getAllOrders(); 30 | void deleteAllOrders(); 31 | void getOrderById(const std::string &orderId); 32 | void deleteOrderById(const std::string &orderId); 33 | 34 | std::map getMarketInfo(); 35 | std::string getAllOpenPositions(); 36 | std::string closeAllPositions(); 37 | std::string getOpenPosition(const std::string &symbol); 38 | std::string closePosition(const std::string &symbol); 39 | 40 | private: 41 | Order parseOrderFromJson(const std::string &response); 42 | }; 43 | 44 | #endif -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "velocity-vortex", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 10 | "preview": "vite preview", 11 | "predeploy": "vite build && cp ./dist/index.html ./dist/404.html", 12 | "deploy": "gh-pages -d dist" 13 | }, 14 | "dependencies": { 15 | "@emotion/react": "^11.11.4", 16 | "@emotion/styled": "^11.11.5", 17 | "@mui/material": "^5.15.20", 18 | "@mui/x-data-grid": "^7.13.0", 19 | "echarts": "^5.5.1", 20 | "echarts-for-react": "^3.0.2", 21 | "react": "^18.2.0", 22 | "react-dom": "^18.2.0", 23 | "react-router-dom": "^6.23.1", 24 | "vite-plugin-checker": "^0.6.4", 25 | "vite-tsconfig-paths": "^4.3.2" 26 | }, 27 | "devDependencies": { 28 | "@iconify/react": "^5.0.1", 29 | "@types/react": "^18.3.3", 30 | "@types/react-dom": "^18.3.0", 31 | "@types/react-router-dom": "^5.3.3", 32 | "@typescript-eslint/eslint-plugin": "^7.2.0", 33 | "@typescript-eslint/parser": "^7.2.0", 34 | "@vitejs/plugin-react-swc": "^3.5.0", 35 | "eslint": "^8.57.0", 36 | "eslint-config-prettier": "^9.1.0", 37 | "eslint-plugin-prettier": "^5.1.3", 38 | "eslint-plugin-react-hooks": "^4.6.0", 39 | "eslint-plugin-react-refresh": "^0.4.6", 40 | "gh-pages": "^6.1.1", 41 | "prettier": "3.3.2", 42 | "typescript": "^5.2.2", 43 | "vite": "^5.2.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Order-Manager-Server/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "Scheduler/scheduler.hpp" 2 | #include "Executor-Manager-Core/executor_manager.hpp" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main() 9 | { 10 | zmq::context_t context(1); 11 | zmq::socket_t subscriber(context, ZMQ_SUB); 12 | 13 | std::string topic = ""; 14 | subscriber.connect("tcp://localhost:5555"); 15 | subscriber.setsockopt(ZMQ_SUBSCRIBE, topic.c_str(), topic.size()); 16 | 17 | ExecutorManager Executor_1; 18 | ExecutorManager Executor_2; 19 | ExecutorManager Executor_3; 20 | 21 | std::thread thread1(&ExecutorManager::processOrderQueue, &Executor_1); 22 | std::thread thread2(&ExecutorManager::processOrderQueue, &Executor_2); 23 | std::thread thread3(&ExecutorManager::processOrderQueue, &Executor_3); 24 | 25 | thread1.detach(); 26 | thread2.detach(); 27 | thread3.detach(); 28 | 29 | Scheduler scheduler; 30 | scheduler.Register_Provider("Alpaca", Executor_1.getOrderQueuePointer()); 31 | scheduler.Register_Provider("Polygon", Executor_2.getOrderQueuePointer()); 32 | scheduler.Register_Provider("TwelveData", Executor_3.getOrderQueuePointer()); 33 | 34 | zmq::message_t message; 35 | while (true) 36 | { 37 | subscriber.recv(message, zmq::recv_flags::none); 38 | std::string receivedMessage(static_cast(message.data()), message.size()); 39 | std::cout << "Received: " << receivedMessage << std::endl; 40 | scheduler.RoundRobin(receivedMessage); 41 | } 42 | 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Computing-Server/src/Utilities/Utilities.cpp: -------------------------------------------------------------------------------- 1 | #include "Utilities/Utilities.hpp" 2 | 3 | OHLCV barToOHLCV(const Bar& bar) { 4 | OHLCV ohlcv; 5 | ohlcv.open = bar.open; 6 | ohlcv.high = bar.high; 7 | ohlcv.low = bar.low; 8 | ohlcv.close = bar.close; 9 | ohlcv.volume = static_cast(bar.volume); 10 | ohlcv.timestamp = bar.time; 11 | 12 | return ohlcv; 13 | } 14 | 15 | Bar ohlcvToBar(const OHLCV& ohlcv, const std::string& symbol) { 16 | Bar bar(symbol); 17 | bar.open = ohlcv.open; 18 | bar.high = ohlcv.high; 19 | bar.low = ohlcv.low; 20 | bar.close = ohlcv.close; 21 | bar.volume = static_cast(ohlcv.volume); 22 | bar.time = ohlcv.timestamp; 23 | 24 | return bar; 25 | } 26 | 27 | OHLCV buildAggregatedCandle(const std::vector& candles) { 28 | OHLCV aggregatedCandle; 29 | if (candles.empty()) return aggregatedCandle; 30 | 31 | aggregatedCandle.open = candles.front().open; 32 | aggregatedCandle.close = candles.back().close; 33 | aggregatedCandle.high = std::max_element(candles.begin(), candles.end(), 34 | [](const OHLCV& a, const OHLCV& b) { return a.high < b.high; })->high; 35 | aggregatedCandle.low = std::min_element(candles.begin(), candles.end(), 36 | [](const OHLCV& a, const OHLCV& b) { return a.low < b.low; })->low; 37 | aggregatedCandle.volume = std::accumulate(candles.begin(), candles.end(), 0.0, 38 | [](double total, const OHLCV& candle) { return total + candle.volume; }); 39 | aggregatedCandle.timestamp = candles.back().timestamp; 40 | 41 | return aggregatedCandle; 42 | } 43 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianMomentumTrading.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianMomentumTrading.hpp" 2 | #include 3 | #include 4 | 5 | std::vector BayesianMomentumTrading::calculateMomentum(const std::vector &data, int period) 6 | { 7 | std::vector momentumProbabilities; 8 | 9 | if (data.size() < period) 10 | return momentumProbabilities; 11 | 12 | for (size_t i = period - 1; i < data.size(); ++i) 13 | { 14 | double prior = 0.5; 15 | double likelihoodUp = 1.0; 16 | double likelihoodDown = 1.0; 17 | 18 | for (size_t j = i - period + 1; j <= i; ++j) 19 | { 20 | double priceChange = data[j].close - data[j].open; 21 | likelihoodUp *= std::exp(priceChange / 100.0); 22 | likelihoodDown *= std::exp(-priceChange / 100.0); 23 | } 24 | 25 | double posteriorUp = (likelihoodUp * prior) / (likelihoodUp * prior + likelihoodDown * (1 - prior)); 26 | momentumProbabilities.push_back(posteriorUp); 27 | } 28 | 29 | return momentumProbabilities; 30 | } 31 | 32 | SignalResult BayesianMomentumTrading::calculateSignal() 33 | { 34 | if (historicalData.size() < period) 35 | return SignalResult(0.0); 36 | 37 | std::vector momentumProbabilities = calculateMomentum(historicalData, period); 38 | 39 | if (!momentumProbabilities.empty()) 40 | { 41 | return SignalResult(momentumProbabilities.back()); 42 | } 43 | else 44 | { 45 | return SignalResult(0.0); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianTrendDetection.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianTrendDetection.hpp" 2 | 3 | std::vector BayesianTrendDetection::calculate(const std::vector &data, int period) 4 | { 5 | std::vector trendProbabilities; 6 | 7 | if (data.size() < period) 8 | return trendProbabilities; 9 | 10 | for (size_t i = period - 1; i < data.size(); ++i) 11 | { 12 | double prior = 0.5; // Assuming an equal probability for trend and non-trend initially 13 | double likelihoodTrend = 1.0; 14 | double likelihoodNoTrend = 1.0; 15 | 16 | for (size_t j = i - period + 1; j <= i; ++j) 17 | { 18 | double priceChange = data[j].close - data[j].open; 19 | likelihoodTrend *= std::exp(priceChange / 100.0); 20 | likelihoodNoTrend *= std::exp(-priceChange / 100.0); 21 | } 22 | 23 | double posteriorTrend = (likelihoodTrend * prior) / (likelihoodTrend * prior + likelihoodNoTrend * (1 - prior)); 24 | trendProbabilities.push_back(posteriorTrend); 25 | } 26 | 27 | return trendProbabilities; 28 | } 29 | 30 | SignalResult BayesianTrendDetection::calculateSignal() 31 | { 32 | if (historicalData.size() < period) 33 | return SignalResult(0.0); 34 | 35 | std::vector trendProbabilities = calculate(historicalData, period); 36 | 37 | if (!trendProbabilities.empty()) 38 | { 39 | return SignalResult(trendProbabilities.back()); 40 | } 41 | else 42 | { 43 | return SignalResult(0.0); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianSVM.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianSVM.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | std::vector BayesianSVM::applySVM(const std::vector &data, int period) 7 | { 8 | std::vector svmScores; 9 | 10 | if (data.size() < period) 11 | return svmScores; 12 | 13 | for (size_t i = period - 1; i < data.size(); ++i) 14 | { 15 | double svmScore = 0.0; 16 | double prior = 0.5; // Initial prior probability 17 | 18 | 19 | for (size_t j = i - period + 1; j <= i; ++j) 20 | { 21 | double priceChange = data[j].close - data[j].open; 22 | svmScore += priceChange; 23 | } 24 | 25 | // Bayesian posterior adjustment 26 | double likelihoodPositive = std::exp(svmScore / 100.0); 27 | double likelihoodNegative = std::exp(-svmScore / 100.0); 28 | 29 | double posterior = (likelihoodPositive * prior) / 30 | (likelihoodPositive * prior + likelihoodNegative * (1 - prior)); 31 | 32 | svmScores.push_back(posterior > 0.5 ? posterior : -posterior); 33 | } 34 | 35 | return svmScores; 36 | } 37 | 38 | SignalResult BayesianSVM::calculateSignal() 39 | { 40 | if (historicalData.size() < period) 41 | return SignalResult(0.0); 42 | 43 | std::vector svmScores = applySVM(historicalData, period); 44 | 45 | if (!svmScores.empty()) 46 | { 47 | return SignalResult(svmScores.back()); 48 | } 49 | else 50 | { 51 | return SignalResult(0.0); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/Trade.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TRADE_HPP 2 | #define TRADE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Trade { 10 | public: 11 | std::string symbol; 12 | double price; 13 | long size; 14 | std::string timestamp; 15 | std::vector conditions; 16 | int identifier; 17 | std::string exchange; 18 | std::string tradeCondition; 19 | 20 | Trade(std::string sys):symbol{sys}{} 21 | 22 | void fromJson(const Json::Value& json) { 23 | price = json["p"].asDouble(); 24 | size = json["s"].asInt64(); 25 | timestamp = json["t"].asString(); 26 | 27 | if (json.isMember("c") && json["c"].isArray()) { 28 | for (const auto& condition : json["c"]) { 29 | conditions.push_back(condition.asString()); 30 | } 31 | } 32 | 33 | identifier = json["i"].asInt(); 34 | exchange = json["x"].asString(); 35 | tradeCondition = json["z"].asString(); 36 | } 37 | 38 | void print() const { 39 | std::cout << "Symbol: " << symbol 40 | << ", Price: " << price 41 | << ", Size: " << size 42 | << ", Timestamp: " << timestamp 43 | << ", Identifier: " << identifier 44 | << ", Exchange: " << exchange 45 | << ", Trade Condition: " << tradeCondition 46 | << ", Conditions: "; 47 | 48 | for (const auto& condition : conditions) { 49 | std::cout << condition << " "; 50 | } 51 | std::cout << std::endl; 52 | } 53 | }; 54 | 55 | #endif -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/time_series_models/GARCH.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/time_series_models/GARCH.hpp" 2 | #include 3 | #include 4 | 5 | std::vector GARCH::fitGARCH(const std::vector &returns) 6 | { 7 | 8 | if (returns.size() < p + q) 9 | throw std::invalid_argument("Insufficient data to fit GARCH model."); 10 | 11 | std::vector conditionalVariances(returns.size(), 0.0); 12 | double omega = 0.1; 13 | double alphaSum = 0.7; 14 | double betaSum = 0.2; 15 | 16 | for (size_t t = 1; t < returns.size(); ++t) 17 | { 18 | conditionalVariances[t] = omega + 19 | alphaSum * (returns[t - 1] * returns[t - 1]) + 20 | betaSum * conditionalVariances[t - 1]; 21 | } 22 | 23 | return conditionalVariances; 24 | } 25 | 26 | SignalResult GARCH::calculateSignal() 27 | { 28 | if (historicalData.empty()) 29 | return SignalResult(0.0); 30 | 31 | // Calculate returns from historical data 32 | std::vector returns; 33 | for (size_t i = 1; i < historicalData.size(); ++i) 34 | { 35 | double returnVal = (historicalData[i].close - historicalData[i - 1].close) / historicalData[i - 1].close; 36 | returns.push_back(returnVal); 37 | } 38 | 39 | std::vector conditionalVariances = fitGARCH(returns); 40 | 41 | double latestVariance = conditionalVariances.back(); 42 | 43 | if (latestVariance > 0.01) // Example threshold 44 | { 45 | return SignalResult(latestVariance); 46 | } 47 | else 48 | { 49 | return SignalResult(-latestVariance); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/data-display/Chip.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const Chip: Components>['MuiChip'] = { 5 | styleOverrides: { 6 | root: { 7 | margin: 0, 8 | fontWeight: 700, 9 | }, 10 | sizeSmall: ({ theme }) => ({ 11 | height: 24, 12 | padding: theme.spacing(0, 1), 13 | fontSize: theme.typography.caption.fontSize, 14 | }), 15 | sizeMedium: ({ theme }) => ({ 16 | height: 28, 17 | padding: theme.spacing(0, 1.25), 18 | fontSize: theme.typography.body2.fontSize, 19 | }), 20 | colorPrimary: ({ theme }) => ({ 21 | color: theme.palette.text.primary, 22 | backgroundColor: theme.palette.info.light, 23 | }), 24 | colorSuccess: ({ theme }) => ({ 25 | color: theme.palette.success.main, 26 | backgroundColor: theme.palette.transparent.success.main, 27 | }), 28 | colorWarning: ({ theme }) => ({ 29 | color: theme.palette.warning.main, 30 | backgroundColor: theme.palette.transparent.warning.main, 31 | }), 32 | colorError: ({ theme }) => ({ 33 | color: theme.palette.error.main, 34 | backgroundColor: theme.palette.transparent.error.main, 35 | }), 36 | iconSmall: { 37 | width: 12, 38 | margin: '0 !important', 39 | }, 40 | iconMedium: { 41 | width: 16, 42 | margin: '0 !important', 43 | }, 44 | labelSmall: { 45 | padding: 0, 46 | textTransform: 'capitalize', 47 | }, 48 | labelMedium: { 49 | padding: 0, 50 | textTransform: 'capitalize', 51 | }, 52 | }, 53 | }; 54 | 55 | export default Chip; -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/indicator/Indicator.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "Utilities/OHLCV.hpp" 9 | #include 10 | #include "Utilities/SignalResult.hpp" 11 | 12 | class Indicator 13 | { 14 | protected: 15 | std::vector historicalData; 16 | std::vector signals; 17 | int period; 18 | std::string name; 19 | 20 | public: 21 | Indicator(const std::string &indicatorName, int period) 22 | : name(indicatorName), period(period) {} 23 | 24 | virtual ~Indicator() = default; 25 | 26 | void addData(const OHLCV &data) 27 | { 28 | historicalData.push_back(data); 29 | } 30 | 31 | virtual SignalResult calculateSignal() = 0; 32 | const std::vector &getHistoricalSignals() const 33 | { 34 | return signals; 35 | } 36 | 37 | void reset() 38 | { 39 | historicalData.clear(); 40 | signals.clear(); 41 | } 42 | 43 | const std::string &getName() const { return name; } 44 | int getPeriod() const { return period; } 45 | int getDataSize() const { return historicalData.size(); } 46 | int getSignalSize() const { return signals.size(); } 47 | 48 | virtual void adjustParameters(int newPeriod) 49 | { 50 | period = newPeriod; 51 | } 52 | 53 | void backtest(const std::vector &historicalPrices) 54 | { 55 | reset(); 56 | for (const OHLCV &data : historicalPrices) 57 | { 58 | addData(data); 59 | SignalResult signal = calculateSignal(); 60 | signals.push_back(signal); 61 | } 62 | } 63 | }; -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianDecisionTreeTrading.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianDecisionTreeTrading.hpp" 2 | #include 3 | #include 4 | 5 | std::vector BayesianDecisionTreeTrading::evaluateDecisionTree(const std::vector &data, int period) 6 | { 7 | std::vector decisionScores; 8 | 9 | if (data.size() < period) 10 | return decisionScores; 11 | 12 | for (size_t i = period - 1; i < data.size(); ++i) 13 | { 14 | // Simplified decision rules based on closing prices 15 | double upwardProbability = 0.5; 16 | double downwardProbability = 0.5; 17 | 18 | // Decision nodes 19 | for (size_t j = i - period + 1; j <= i; ++j) 20 | { 21 | if (data[j].close > data[j].open) 22 | upwardProbability *= 1.1; 23 | else 24 | downwardProbability *= 1.1; 25 | } 26 | 27 | double posteriorUp = upwardProbability / (upwardProbability + downwardProbability); 28 | double posteriorDown = downwardProbability / (upwardProbability + downwardProbability); 29 | 30 | decisionScores.push_back(posteriorUp - posteriorDown); 31 | } 32 | 33 | return decisionScores; 34 | } 35 | 36 | SignalResult BayesianDecisionTreeTrading::calculateSignal() 37 | { 38 | if (historicalData.size() < period) 39 | return SignalResult(0.0); 40 | 41 | std::vector decisionScores = evaluateDecisionTree(historicalData, period); 42 | 43 | if (!decisionScores.empty()) 44 | { 45 | return SignalResult(decisionScores.back()); 46 | } 47 | else 48 | { 49 | return SignalResult(0.0); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/top-cards/Total_Trades/index.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import Stack from '@mui/material/Stack'; 3 | import Paper from '@mui/material/Paper'; 4 | import Typography from '@mui/material/Typography'; 5 | import IconifyIcon from 'components/base/IconifyIcon'; 6 | import ClientChart from './ClientChart'; 7 | 8 | interface TotalTradesProps { 9 | trades: number; 10 | } 11 | 12 | const Total_Trades: React.FC = ({ trades }) => { 13 | return ( 14 | 20 | 21 | ({ 27 | background: `linear-gradient(135deg, ${theme.palette.gradients.primary.state} 0%, ${theme.palette.gradients.primary.main} 100%)`, 28 | })} 29 | borderRadius="50%" 30 | > 31 | 32 | 33 | 34 | 35 | Total Trades 36 | 37 | 38 | {trades} 39 | 40 | 41 | 42 | 43 | 44 | 45 | ); 46 | }; 47 | 48 | export default Total_Trades; 49 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/EMA.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/EMA.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | SignalResult EMA::calculateSignal() 7 | { 8 | if (historicalData.empty()) 9 | { 10 | throw std::runtime_error("Not enough data to calculate EMA."); 11 | } 12 | 13 | std::vector ema(historicalData.size(), 0.0); 14 | double multiplier = 2.0 / (period + 1); 15 | double sum = 0.0; 16 | for (std::size_t i = 0; i < period && i < historicalData.size(); ++i) 17 | { 18 | sum += historicalData[i].close; 19 | } 20 | 21 | if (period > 0 && historicalData.size() > 0) 22 | { 23 | ema[period - 1] = sum / period; 24 | } 25 | for (std::size_t i = period; i < historicalData.size(); ++i) 26 | { 27 | ema[i] = ((historicalData[i].close - ema[i - 1]) * multiplier) + ema[i - 1]; 28 | } 29 | 30 | signals.push_back(SignalResult(ema)); 31 | return SignalResult(ema.back()); 32 | } 33 | 34 | std::vector EMA::calculate(const std::vector &data, std::size_t period) 35 | { 36 | if (data.empty()) 37 | return {}; 38 | 39 | std::vector ema(data.size(), 0.0); 40 | double multiplier = 2.0 / (period + 1); 41 | 42 | double sum = 0.0; 43 | for (std::size_t i = 0; i < period && i < data.size(); ++i) 44 | { 45 | sum += data[i].close; 46 | } 47 | 48 | if (period > 0 && data.size() > 0) 49 | { 50 | ema[period - 1] = sum / period; 51 | } 52 | 53 | for (std::size_t i = period; i < data.size(); ++i) 54 | { 55 | ema[i] = ((data[i].close - ema[i - 1]) * multiplier) + ema[i - 1]; 56 | } 57 | 58 | return ema; 59 | } -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/FibonacciRetracement.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/FibonacciRetracement.hpp" 2 | #include 3 | #include 4 | 5 | SignalResult FibonacciRetracement::calculateSignal() 6 | { 7 | if (historicalData.empty()) 8 | { 9 | throw std::runtime_error("Historical data is empty."); 10 | } 11 | 12 | double maxPrice = historicalData[0].high; 13 | double minPrice = historicalData[0].low; 14 | 15 | for (const auto &bar : historicalData) 16 | { 17 | if (bar.high > maxPrice) maxPrice = bar.high; 18 | if (bar.low < minPrice) minPrice = bar.low; 19 | } 20 | 21 | double difference = maxPrice - minPrice; 22 | std::vector levels = { 23 | maxPrice, 24 | maxPrice - difference * 0.236, 25 | maxPrice - difference * 0.382, 26 | maxPrice - difference * 0.618, 27 | minPrice 28 | }; 29 | 30 | signals.push_back(SignalResult(levels)); 31 | return SignalResult(signals.back()); 32 | } 33 | 34 | std::vector FibonacciRetracement::calculate(const std::vector &data) 35 | { 36 | if (data.empty()) return {}; 37 | 38 | double maxPrice = data[0].high; 39 | double minPrice = data[0].low; 40 | 41 | for (const auto &bar : data) 42 | { 43 | if (bar.high > maxPrice) maxPrice = bar.high; 44 | if (bar.low < minPrice) minPrice = bar.low; 45 | } 46 | 47 | double difference = maxPrice - minPrice; 48 | std::vector levels = { 49 | maxPrice, 50 | maxPrice - difference * 0.236, 51 | maxPrice - difference * 0.382, 52 | maxPrice - difference * 0.618, 53 | minPrice 54 | }; 55 | 56 | return levels; 57 | } -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/Quote.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QUOTE_HPP 2 | #define QUOTE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Quote { 10 | public: 11 | std::string symbol; 12 | double bidPrice; 13 | long bidSize; 14 | std::string bidExchange; 15 | double askPrice; 16 | long askSize; 17 | std::string askExchange; 18 | std::string timestamp; 19 | std::vector conditions; 20 | 21 | Quote(std::string sys):symbol{sys}{} 22 | 23 | void fromJson(const Json::Value& json) { 24 | bidPrice = json["bp"].asDouble(); 25 | bidSize = json["bs"].asInt64(); 26 | bidExchange = json["bx"].asString(); 27 | askPrice = json["ap"].asDouble(); 28 | askSize = json["as"].asInt64(); 29 | askExchange = json["ax"].asString(); 30 | timestamp = json["t"].asString(); 31 | 32 | for (const auto& condition : json["c"]) { 33 | conditions.push_back(condition.asString()); 34 | } 35 | } 36 | 37 | void print() const { 38 | std::cout << "Symbol: " << symbol 39 | << ", Bid Price: " << bidPrice 40 | << ", Bid Size: " << bidSize 41 | << ", Bid Exchange: " << bidExchange 42 | << ", Ask Price: " << askPrice 43 | << ", Ask Size: " << askSize 44 | << ", Ask Exchange: " << askExchange 45 | << ", Timestamp: " << timestamp 46 | << ", Conditions: "; 47 | 48 | for (const auto& condition : conditions) { 49 | std::cout << condition << " "; 50 | } 51 | std::cout << std::endl; 52 | } 53 | }; 54 | 55 | #endif -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/buttons/Button.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const Button: Components>['MuiButton'] = { 5 | defaultProps: { 6 | disableElevation: true, 7 | }, 8 | styleOverrides: { 9 | root: ({ theme }) => ({ 10 | color: theme.palette.info.light, 11 | borderRadius: theme.shape.borderRadius * 10, 12 | textTransform: 'initial', 13 | }), 14 | text: ({ theme }) => ({ 15 | color: theme.palette.text.disabled, 16 | backgroundColor: 'transparent !important', 17 | }), 18 | containedPrimary: ({ theme }) => ({ 19 | color: theme.palette.info.light, 20 | backgroundColor: theme.palette.primary.main, 21 | '&:hover': { backgroundColor: theme.palette.primary.main }, 22 | }), 23 | containedSecondary: ({ theme }) => ({ 24 | color: theme.palette.text.primary, 25 | backgroundColor: theme.palette.info.dark, 26 | '&:hover': { backgroundColor: theme.palette.info.dark }, 27 | }), 28 | sizeLarge: ({ theme }) => ({ 29 | padding: theme.spacing(1.125, 3), 30 | fontSize: theme.typography.h6.fontSize, 31 | fontWeight: 600, 32 | }), 33 | sizeMedium: ({ theme }) => ({ 34 | padding: theme.spacing(1, 2), 35 | fontSize: theme.typography.body1.fontSize, 36 | fontWeight: 600, 37 | }), 38 | sizeSmall: ({ theme }) => ({ 39 | padding: theme.spacing(0.875, 1.5), 40 | fontSize: theme.typography.caption.fontSize, 41 | fontWeight: 700, 42 | }), 43 | startIcon: { 44 | marginRight: 10, 45 | }, 46 | endIcon: { 47 | marginLeft: 6, 48 | }, 49 | }, 50 | }; 51 | 52 | export default Button; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/spent-this-month/index.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import Paper from '@mui/material/Paper'; 3 | import Stack from '@mui/material/Stack'; 4 | import Typography from '@mui/material/Typography'; 5 | import IconifyIcon from 'components/base/IconifyIcon'; 6 | import SpentThisMonthChart from './SpentThisMonthChart'; 7 | 8 | const SpentThisMonth = () => { 9 | return ( 10 | 11 | 12 | 13 | 14 | Spent this month 15 | 16 | 17 | $682.5 18 | 19 | 20 | 21 | 22 | On track 23 | 24 | 25 | 26 | 27 | 28 | 33 | 34 | +2.45% 35 | 36 | 37 | 38 | 39 | 43 | 44 | ); 45 | }; 46 | 47 | export default SpentThisMonth; 48 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianAnomalyDetection.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianAnomalyDetection.hpp" 2 | #include 3 | #include 4 | 5 | std::vector BayesianAnomalyDetection::detectAnomalies(const std::vector &data, int period) 6 | { 7 | std::vector anomalyScores; 8 | 9 | if (data.size() < period) 10 | return anomalyScores; 11 | 12 | for (size_t i = period - 1; i < data.size(); ++i) 13 | { 14 | double mean = std::accumulate(data.begin() + i - period + 1, data.begin() + i + 1, 0.0, 15 | [](double sum, const OHLCV &val) 16 | { return sum + val.close; }) / 17 | period; 18 | 19 | double variance = 0.0; 20 | for (size_t j = i - period + 1; j <= i; ++j) 21 | { 22 | double diff = data[j].close - mean; 23 | variance += diff * diff; 24 | } 25 | variance /= period; 26 | 27 | double stdDev = std::sqrt(variance); 28 | double zScore = (data[i].close - mean) / stdDev; 29 | double anomalyProbability = std::exp(-0.5 * zScore * zScore) / (stdDev * std::sqrt(2 * M_PI)); 30 | anomalyScores.push_back(1.0 - anomalyProbability); 31 | } 32 | 33 | return anomalyScores; 34 | } 35 | 36 | SignalResult BayesianAnomalyDetection::calculateSignal() 37 | { 38 | if (historicalData.size() < period) 39 | return SignalResult(0.0); 40 | 41 | std::vector anomalyScores = detectAnomalies(historicalData, period); 42 | 43 | if (!anomalyScores.empty()) 44 | { 45 | return SignalResult(anomalyScores.back()); 46 | } 47 | else 48 | { 49 | return SignalResult(0.0); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Computing-Server/include/Utilities/ModelTransfer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class ModelTransfer 10 | { 11 | public: 12 | static void transfer_parameters_in_memory(torch::nn::Module &source, torch::nn::Module &target, const torch::Device &device) 13 | { 14 | torch::NoGradGuard no_grad; 15 | auto source_params = source.named_parameters(); 16 | auto target_params = target.named_parameters(); 17 | 18 | for (const auto &val : source_params) 19 | { 20 | const auto &name = val.key(); 21 | const auto ¶m = val.value(); 22 | 23 | if (target_params.contains(name)) 24 | { 25 | target_params[name].copy_(param); 26 | } 27 | } 28 | 29 | auto source_buffers = source.named_buffers(); 30 | auto target_buffers = target.named_buffers(); 31 | 32 | for (const auto &val : source_buffers) 33 | { 34 | const auto &name = val.key(); 35 | const auto &buffer = val.value(); 36 | 37 | if (target_buffers.contains(name)) 38 | { 39 | target_buffers[name].copy_(buffer); 40 | } 41 | } 42 | } 43 | 44 | static void save_parameters_to_file(torch::nn::Module &model, const std::string &filename) 45 | { 46 | torch::serialize::OutputArchive archive; 47 | model.save(archive); 48 | archive.save_to(filename); 49 | } 50 | 51 | static void load_parameters(torch::nn::Module &model, const std::string &filename) 52 | { 53 | torch::serialize::InputArchive archive; 54 | archive.load_from(filename); 55 | model.load(archive); 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianStochasticVolatility.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianStochasticVolatility.hpp" 2 | #include 3 | 4 | std::vector BayesianStochasticVolatility::estimateVolatility(const std::vector &data, int period) 5 | { 6 | if (data.size() < period) 7 | throw std::invalid_argument("Insufficient data to estimate volatility."); 8 | 9 | std::vector volatilities; 10 | 11 | for (size_t i = period; i < data.size(); ++i) 12 | { 13 | double sumReturns = 0.0; 14 | for (size_t j = i - period; j < i; ++j) 15 | { 16 | double dailyReturn = (data[j + 1].close - data[j].close) / data[j].close; 17 | sumReturns += dailyReturn; 18 | } 19 | 20 | double meanReturn = sumReturns / period; 21 | double variance = 0.0; 22 | 23 | for (size_t j = i - period; j < i; ++j) 24 | { 25 | double dailyReturn = (data[j + 1].close - data[j].close) / data[j].close; 26 | variance += std::pow(dailyReturn - meanReturn, 2); 27 | } 28 | 29 | variance /= period; 30 | volatilities.push_back(std::sqrt(variance)); 31 | } 32 | 33 | return volatilities; 34 | } 35 | 36 | SignalResult BayesianStochasticVolatility::calculateSignal() 37 | { 38 | if (historicalData.size() < period) 39 | return SignalResult(0.0); 40 | 41 | std::vector volatilities = estimateVolatility(historicalData, period); 42 | double latestVolatility = volatilities.back(); 43 | 44 | double threshold = 0.02; // Example threshold, can be adjusted 45 | 46 | if (latestVolatility > threshold) 47 | { 48 | return SignalResult(latestVolatility); 49 | } 50 | else 51 | { 52 | return SignalResult(-latestVolatility); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /DataBroker-Server/include/Utilities/Trade.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TRADE_HPP 2 | #define TRADE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Trade 10 | { 11 | public: 12 | std::string symbol; 13 | double price; 14 | long size; 15 | std::string timestamp; 16 | std::vector conditions; 17 | int identifier; 18 | std::string exchange; 19 | std::string tradeCondition; 20 | 21 | explicit Trade(std::string sys) : symbol{sys} {} 22 | 23 | // Parses JSON data to populate the Trade object. 24 | // @param json: JSON object containing trade data. 25 | void fromJson(const Json::Value &json) 26 | { 27 | price = json["p"].asDouble(); 28 | size = json["s"].asInt64(); 29 | timestamp = json["t"].asString(); 30 | 31 | if (json.isMember("c") && json["c"].isArray()) 32 | { 33 | for (const auto &condition : json["c"]) 34 | { 35 | conditions.push_back(condition.asString()); 36 | } 37 | } 38 | 39 | identifier = json["i"].asInt(); 40 | exchange = json["x"].asString(); 41 | tradeCondition = json["z"].asString(); 42 | } 43 | 44 | // Prints the trade details to the standard output. 45 | void print() const 46 | { 47 | std::cout << "Symbol: " << symbol 48 | << ", Price: " << price 49 | << ", Size: " << size 50 | << ", Timestamp: " << timestamp 51 | << ", Identifier: " << identifier 52 | << ", Exchange: " << exchange 53 | << ", Trade Condition: " << tradeCondition 54 | << ", Conditions: "; 55 | 56 | for (const auto &condition : conditions) 57 | { 58 | std::cout << condition << " "; 59 | } 60 | std::cout << std::endl; 61 | } 62 | }; 63 | 64 | #endif // TRADE_HPP -------------------------------------------------------------------------------- /Computing-Server/include/Data-Fetcher-Core/WebSocket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace beast = boost::beast; 14 | namespace http = beast::http; 15 | namespace websocket = beast::websocket; 16 | namespace net = boost::asio; 17 | namespace ssl = boost::asio::ssl; 18 | using tcp = boost::asio::ip::tcp; 19 | 20 | class WebSocket : public std::enable_shared_from_this 21 | { 22 | tcp::resolver resolver_; 23 | websocket::stream> ws_; 24 | beast::flat_buffer buffer_; 25 | std::string host_; 26 | std::string text_; 27 | bool connected_; 28 | bool authenticated_; 29 | std::atomic reading_; 30 | std::mutex websocket_mutex_; 31 | std::atomic stop_reading_; 32 | std::string Stock; 33 | 34 | protected: 35 | virtual void processMessage(const Json::Value &message) = 0; 36 | 37 | public: 38 | explicit WebSocket(net::io_context &ioc, ssl::context &ctx); 39 | ~WebSocket(); 40 | 41 | void run(const char *host, const char *port, const char *text, std::string stock_); 42 | 43 | private: 44 | void on_resolve(beast::error_code ec, tcp::resolver::results_type results); 45 | void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep); 46 | void on_ssl_handshake(beast::error_code ec); 47 | void on_handshake(beast::error_code ec); 48 | void on_auth_write(beast::error_code ec, std::size_t bytes_transferred); 49 | void on_write(beast::error_code ec, std::size_t bytes_transferred); 50 | void on_read(beast::error_code ec, std::size_t bytes_transferred); 51 | void sendAuthMessage(); 52 | void subscribeToChannels(); 53 | void doRead(); 54 | }; 55 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/time_series_models/ARIMA.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/time_series_models/ARIMA.hpp" 2 | #include 3 | 4 | std::vector ARIMA::fitARIMA(const std::vector &data, int p, int d, int q) 5 | { 6 | if (data.size() < p + d + q) 7 | throw std::invalid_argument("Insufficient data to fit ARIMA model."); 8 | 9 | std::vector differencedData; 10 | std::vector predictions; 11 | 12 | for (size_t i = d; i < data.size(); ++i) 13 | { 14 | differencedData.push_back(data[i].close - data[i - d].close); 15 | } 16 | 17 | std::vector arTerms(p, 0.0); 18 | std::vector maTerms(q, 0.0); 19 | 20 | for (size_t i = p; i < differencedData.size(); ++i) 21 | { 22 | double arSum = 0.0; 23 | for (int j = 1; j <= p; ++j) 24 | { 25 | arSum += arTerms[j - 1] * differencedData[i - j]; 26 | } 27 | arTerms.push_back(arSum); 28 | } 29 | 30 | for (size_t i = q; i < differencedData.size(); ++i) 31 | { 32 | double maSum = 0.0; 33 | for (int j = 1; j <= q; ++j) 34 | { 35 | maSum += maTerms[j - 1] * (differencedData[i - j] - arTerms[i - j]); 36 | } 37 | maTerms.push_back(maSum); 38 | } 39 | 40 | for (size_t i = 0; i < differencedData.size(); ++i) 41 | { 42 | predictions.push_back(arTerms[i] + maTerms[i]); 43 | } 44 | 45 | return predictions; 46 | } 47 | 48 | SignalResult ARIMA::calculateSignal() 49 | { 50 | if (historicalData.size() < p + d + q) 51 | return SignalResult(0.0); 52 | 53 | std::vector predictions = fitARIMA(historicalData, p, d, q); 54 | double latestPrediction = predictions.back(); 55 | 56 | if (latestPrediction > historicalData.back().close) 57 | { 58 | return SignalResult(latestPrediction); 59 | } 60 | else 61 | { 62 | return SignalResult(-latestPrediction); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /DataBroker-Server/include/Utilities/Quote.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QUOTE_HPP 2 | #define QUOTE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Quote 10 | { 11 | public: 12 | std::string symbol; 13 | double bid_price; 14 | long bid_size; 15 | std::string bid_exchange; 16 | double ask_price; 17 | long ask_size; 18 | std::string ask_exchange; 19 | std::string timestamp; 20 | std::vector conditions; 21 | 22 | explicit Quote(std::string sys) : symbol{sys} {} 23 | 24 | // Parses JSON object to populate Quote fields. 25 | // Input: json - JSON object containing quote data. 26 | void FromJson(const Json::Value &json) 27 | { 28 | bid_price = json["bp"].asDouble(); 29 | bid_size = json["bs"].asInt64(); 30 | bid_exchange = json["bx"].asString(); 31 | ask_price = json["ap"].asDouble(); 32 | ask_size = json["as"].asInt64(); 33 | ask_exchange = json["ax"].asString(); 34 | timestamp = json["t"].asString(); 35 | 36 | for (const auto &condition : json["c"]) 37 | { 38 | conditions.push_back(condition.asString()); 39 | } 40 | } 41 | 42 | // Prints the Quote details to the standard output. 43 | void Print() const 44 | { 45 | std::cout << "Symbol: " << symbol 46 | << ", Bid Price: " << bid_price 47 | << ", Bid Size: " << bid_size 48 | << ", Bid Exchange: " << bid_exchange 49 | << ", Ask Price: " << ask_price 50 | << ", Ask Size: " << ask_size 51 | << ", Ask Exchange: " << ask_exchange 52 | << ", Timestamp: " << timestamp 53 | << ", Conditions: "; 54 | 55 | for (const auto &condition : conditions) 56 | { 57 | std::cout << condition << " "; 58 | } 59 | std::cout << std::endl; 60 | } 61 | }; 62 | 63 | #endif // QUOTE_HPP -------------------------------------------------------------------------------- /Computing-Server/include/Data-Fetcher-Core/DataFetcher.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DATAFETCHER_HPP 2 | #define DATAFETCHER_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "Utilities/Bar.hpp" 10 | #include "Utilities/Quote.hpp" 11 | #include "Utilities/Trade.hpp" 12 | 13 | class DataFetcher { 14 | public: 15 | DataFetcher(); 16 | 17 | 18 | std::string getHistoricalBars(const std::string& symbols, const std::string& timeframe, 19 | const std::string& start, const std::string& end); 20 | std::vector parseHistoricalBars(const std::string& jsonResponse,std::string sys); 21 | 22 | 23 | 24 | std::string getHistoricalQuotes(const std::string& symbols, const std::string& start, const std::string& end); 25 | std::vector parseHistoricalQuotes(const std::string& jsonResponse,std::string sys); 26 | 27 | 28 | 29 | std::string getHistoricalTrades(const std::string& symbols, const std::string& start, const std::string& end); 30 | std::vector parseHistoricalTrades(const std::string& jsonResponse,std::string sys); 31 | 32 | 33 | std::string getLatestBars(const std::string& symbol); 34 | Bar parseLatestBars(const std::string& jsonResponse,std::string sys); 35 | 36 | std::string getLatestQuotes(const std::string& symbols); 37 | Quote parseLatestQuotes(const std::string& jsonResponse,std::string sys); 38 | 39 | std::string getLatestTrades(const std::string& symbols); 40 | Trade parseLatestTrades(const std::string& jsonResponse,std::string sys); 41 | 42 | private: 43 | std::string apiKey; 44 | std::string secretKey; 45 | 46 | std::string urlEncode(const std::string& value); 47 | std::string formatRFC3339(const std::string& dateStr); 48 | static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* userp); 49 | std::string makeApiRequest(const std::string& url); 50 | }; 51 | 52 | #endif -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/transaction-history/index.tsx: -------------------------------------------------------------------------------- 1 | import { useState, ChangeEvent } from 'react'; 2 | import Box from '@mui/material/Box'; 3 | import Paper from '@mui/material/Paper'; 4 | import Stack from '@mui/material/Stack'; 5 | import TextField from '@mui/material/TextField'; 6 | import Typography from '@mui/material/Typography'; 7 | import InputAdornment from '@mui/material/InputAdornment'; 8 | import IconifyIcon from 'components/base/IconifyIcon'; 9 | import TransactionHistoryTable from './TransactionHistoryTable'; 10 | 11 | interface TransactionHistoryProps { 12 | title: string; 13 | } 14 | 15 | const TransactionHistory = ({ title }: TransactionHistoryProps) => { 16 | const [searchText, setSearchText] = useState(''); 17 | 18 | const handleInputChange = (e: ChangeEvent) => { 19 | setSearchText(e.target.value); 20 | }; 21 | 22 | return ( 23 | 24 | 31 | 32 | {title} 33 | 34 | 44 | 45 | 46 | ), 47 | }} 48 | /> 49 | 50 | 51 | 52 | 53 | 54 | 55 | ); 56 | }; 57 | 58 | export default TransactionHistory; 59 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianModelAveragingTrading.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianModelAveragingTrading.hpp" 2 | #include 3 | 4 | double BayesianModelAveragingTrading::computeModelAverage(const std::vector &modelPredictions, const std::vector &weights) 5 | { 6 | if (modelPredictions.size() != weights.size() || modelPredictions.empty()) 7 | throw std::invalid_argument("Model predictions and weights must be the same size and not empty."); 8 | 9 | double weightedSum = 0.0; 10 | double totalWeight = 0.0; 11 | 12 | for (size_t i = 0; i < modelPredictions.size(); ++i) 13 | { 14 | weightedSum += modelPredictions[i] * weights[i]; 15 | totalWeight += weights[i]; 16 | } 17 | 18 | return weightedSum / totalWeight; // Calculate the weighted average 19 | } 20 | 21 | SignalResult BayesianModelAveragingTrading::calculateSignal() 22 | { 23 | if (historicalData.size() < period) 24 | return SignalResult(0.0); 25 | 26 | 27 | std::vector modelPredictions; 28 | std::vector weights; 29 | 30 | for (size_t i = 0; i < historicalData.size() - period; ++i) 31 | { 32 | 33 | double model1Prediction = (historicalData[i + period - 1].close - historicalData[i].close) / historicalData[i].close; 34 | double model2Prediction = (historicalData[i + period - 1].volume - historicalData[i].volume) / historicalData[i].volume; 35 | 36 | modelPredictions.push_back(model1Prediction); 37 | modelPredictions.push_back(model2Prediction); 38 | 39 | weights.push_back(0.5); // Weight for model 1 40 | weights.push_back(0.5); // Weight for model 2 41 | } 42 | 43 | double averagedPrediction = computeModelAverage(modelPredictions, weights); 44 | 45 | if (averagedPrediction > 0) 46 | { 47 | return SignalResult(averagedPrediction); 48 | } 49 | else 50 | { 51 | return SignalResult(-averagedPrediction); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianCausalInferenceTrading.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianCausalInferenceTrading.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | std::map BayesianCausalInferenceTrading::performCausalInference(const std::vector &data, int period) 7 | { 8 | std::map causalEffects; 9 | 10 | if (data.size() < period) 11 | return causalEffects; 12 | 13 | double totalUpMoves = 0, totalDownMoves = 0; 14 | double totalVolumeIncrease = 0, totalVolumeDecrease = 0; 15 | 16 | for (size_t i = 1; i < data.size(); ++i) 17 | { 18 | if (data[i].close > data[i - 1].close) 19 | { 20 | totalUpMoves++; 21 | if (data[i].volume > data[i - 1].volume) 22 | totalVolumeIncrease++; 23 | } 24 | else 25 | { 26 | totalDownMoves++; 27 | if (data[i].volume < data[i - 1].volume) 28 | totalVolumeDecrease++; 29 | } 30 | } 31 | 32 | double pUpGivenVolumeIncrease = totalVolumeIncrease / totalUpMoves; 33 | double pDownGivenVolumeDecrease = totalVolumeDecrease / totalDownMoves; 34 | 35 | causalEffects["P(Up|VolumeIncrease)"] = pUpGivenVolumeIncrease; // P(Price Up | Volume Increase) 36 | causalEffects["P(Down|VolumeDecrease)"] = pDownGivenVolumeDecrease; // P(Price Down | Volume Decrease) 37 | 38 | return causalEffects; 39 | } 40 | 41 | SignalResult BayesianCausalInferenceTrading::calculateSignal() 42 | { 43 | if (historicalData.size() < period) 44 | return SignalResult(0.0); 45 | 46 | auto causalEffects = performCausalInference(historicalData, period); 47 | 48 | if (causalEffects["P(Up|VolumeIncrease)"] > causalEffects["P(Down|VolumeDecrease)"]) 49 | { 50 | return SignalResult(causalEffects["P(Up|VolumeIncrease"]); 51 | } 52 | else 53 | { 54 | return SignalResult(-causalEffects["P(Down|VolumeDecrease"]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/tasks/index.tsx: -------------------------------------------------------------------------------- 1 | import Box from '@mui/material/Box'; 2 | import Stack from '@mui/material/Stack'; 3 | import Paper from '@mui/material/Paper'; 4 | import Button from '@mui/material/Button'; 5 | import Typography from '@mui/material/Typography'; 6 | import IconifyIcon from 'components/base/IconifyIcon'; 7 | 8 | interface TasksProps { 9 | id: number | string; 10 | task: string; 11 | schedule: string; 12 | } 13 | 14 | const tasks: TasksProps[] = [ 15 | { 16 | id: 1, 17 | task: 'Meet w/ Simmmple', 18 | schedule: '01:00 PM - 02:00 PM', 19 | }, 20 | { 21 | id: 2, 22 | task: 'Fitness Training', 23 | schedule: '02:00 PM - 03:00 PM', 24 | }, 25 | { 26 | id: 3, 27 | task: 'Reading time', 28 | schedule: '03:00 PM - 04:00 PM', 29 | }, 30 | ]; 31 | 32 | const Tasks = () => { 33 | return ( 34 | 35 | 36 | 27 May 37 | 38 | 39 | {tasks.map((item) => { 40 | return ( 41 | 42 | 43 | 44 | 45 | 46 | {item.task} 47 | 48 | 49 | {item.schedule} 50 | 51 | 52 | 53 | ); 54 | })} 55 | 56 | 57 | 65 | 66 | 67 | ); 68 | }; 69 | 70 | export default Tasks; 71 | -------------------------------------------------------------------------------- /Monitoring-Server/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, jsonify 2 | import os 3 | import sqlite3 4 | 5 | app = Flask(__name__) 6 | 7 | DATA_FOLDER = '/media/sf_QuantWhiz-AlgoEngine/Velocity-Vortex/IO-Server/build/database' 8 | 9 | 10 | @app.route('/') 11 | def index(): 12 | 13 | db_files = [f for f in os.listdir(DATA_FOLDER) if f.endswith('.db')] 14 | return render_template('index.html', db_files=db_files) 15 | 16 | 17 | @app.route('/data/') 18 | def get_data(filename): 19 | file_path = os.path.join(DATA_FOLDER, filename) 20 | 21 | # Check if file exists and has a .db extension 22 | if os.path.exists(file_path) and filename.endswith('.db'): 23 | try: 24 | # Connect to the SQLite database 25 | conn = sqlite3.connect(file_path) 26 | cursor = conn.cursor() 27 | 28 | # Query to retrieve table names (assuming you want to display them) 29 | cursor.execute( 30 | "SELECT name FROM sqlite_master WHERE type='table';") 31 | tables = cursor.fetchall() 32 | 33 | # For demonstration, fetching the first 10 rows of the first table 34 | if tables: 35 | table_name = tables[0][0] # Use the first table for example 36 | cursor.execute(f"SELECT * FROM {table_name} LIMIT 10;") 37 | rows = cursor.fetchall() 38 | 39 | # Get column names 40 | column_names = [description[0] 41 | for description in cursor.description] 42 | data = [dict(zip(column_names, row)) for row in rows] 43 | 44 | conn.close() 45 | return jsonify(data) 46 | else: 47 | return jsonify([]) # No tables in the database 48 | 49 | except sqlite3.Error as e: 50 | return jsonify({"error": str(e)}) 51 | 52 | return jsonify([]) # File not found or invalid format 53 | 54 | 55 | if __name__ == '__main__': 56 | app.run(host="0.0.0.0", port=5000, debug=True) 57 | 58 | 59 | -------------------------------------------------------------------------------- /Computing-Server/include/AlgoEngine-Core/Reinforcement_models/Agent_Deep_Q-Learning.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "AlgoEngine-Core/Reinforcement_models/Deep_Q-Learning.hpp" 10 | #include "Utilities/ModelTransfer.hpp" 11 | #include "Utilities/ReplayMemory.hpp" 12 | #include 13 | #include 14 | #include 15 | 16 | class Agent 17 | { 18 | public: 19 | Agent(int replay_mem_size = 10000, 20 | int batch_size = 40, 21 | double gamma = 0.98, 22 | double eps_start = 1.0, 23 | double eps_end = 0.12, 24 | int eps_steps = 300, 25 | double learning_rate = 0.001, 26 | int input_dim = 24, 27 | int action_number = 3, 28 | bool is_double_dqn = true); 29 | 30 | torch::Tensor select_action(torch::Tensor state); 31 | void optimize_model(); 32 | void store_transition(torch::Tensor state, torch::Tensor action, 33 | torch::Tensor next_state, torch::Tensor reward); 34 | void update_target_network(); 35 | 36 | private: 37 | void optimize_double_dqn(const torch::Tensor &states, torch::Tensor &next_state_values, 38 | const std::vector &non_final_mask, 39 | const std::vector &next_states); 40 | void optimize_regular_dqn(torch::Tensor &next_state_values, 41 | const std::vector &non_final_mask, 42 | const std::vector &next_states); 43 | 44 | int replay_mem_size; 45 | int batch_size; 46 | double gamma; 47 | double eps_start; 48 | double eps_end; 49 | int eps_steps; 50 | std::unique_ptr policy_net; 51 | std::unique_ptr target_net; 52 | torch::optim::Adam optimizer; 53 | ReplayMemory memory; 54 | std::mt19937 rng; 55 | int steps_done; 56 | bool is_double_dqn; 57 | torch::Device device; 58 | }; 59 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/credit-balance/CreditBalanceChart.tsx: -------------------------------------------------------------------------------- 1 | import { useMemo } from 'react'; 2 | import { SxProps, useTheme } from '@mui/material'; 3 | import * as echarts from 'echarts/core'; 4 | import ReactEchart from 'components/base/ReactEchart'; 5 | import { CanvasRenderer } from 'echarts/renderers'; 6 | import { LineChart } from 'echarts/charts'; 7 | 8 | import { 9 | TitleComponent, 10 | TooltipComponent, 11 | GridComponent, 12 | LegendComponent, 13 | } from 'echarts/components'; 14 | 15 | echarts.use([ 16 | LineChart, 17 | TitleComponent, 18 | TooltipComponent, 19 | GridComponent, 20 | LegendComponent, 21 | CanvasRenderer, 22 | ]); 23 | 24 | interface CreditBalanceChartProps { 25 | data: number[]; 26 | sx?: SxProps; 27 | } 28 | 29 | const CreditBalanceChart = ({ data, ...rest }: CreditBalanceChartProps) => { 30 | const theme = useTheme(); 31 | 32 | const option = useMemo( 33 | () => ({ 34 | grid: { 35 | top: 10, 36 | bottom: 10, 37 | left: 5, 38 | right: 5, 39 | containerLabel: true, 40 | }, 41 | xAxis: { 42 | type: 'category', 43 | data: ['', '', '', '', ''], 44 | axisTick: { 45 | show: false, 46 | }, 47 | axisLine: { 48 | show: false, 49 | }, 50 | boundaryGap: 0, 51 | }, 52 | yAxis: { 53 | type: 'value', 54 | min: 10, 55 | minInterval: 1, 56 | axisLabel: { 57 | show: false, 58 | }, 59 | splitLine: { 60 | show: false, 61 | }, 62 | }, 63 | series: [ 64 | { 65 | data, 66 | type: 'line', 67 | smooth: true, 68 | showSymbol: false, 69 | lineStyle: { 70 | color: theme.palette.info.light, 71 | width: 2, 72 | type: 'solid', 73 | cap: 'round', 74 | }, 75 | }, 76 | ], 77 | }), 78 | [theme, data], 79 | ); 80 | 81 | return ; 82 | }; 83 | 84 | export default CreditBalanceChart; 85 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianCorrelationEstimation.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianCorrelationEstimation.hpp" 2 | #include 3 | #include 4 | 5 | std::vector BayesianCorrelationEstimation::calculate(const std::vector &data1, const std::vector &data2, int period) 6 | { 7 | std::vector correlations; 8 | 9 | if (data1.size() < period || data2.size() < period) 10 | return correlations; 11 | 12 | for (size_t i = period - 1; i < data1.size(); ++i) 13 | { 14 | double mean1 = std::accumulate(data1.begin() + i - period + 1, data1.begin() + i + 1, 0.0, 15 | [](double sum, const OHLCV &val) { return sum + val.close; }) / period; 16 | double mean2 = std::accumulate(data2.begin() + i - period + 1, data2.begin() + i + 1, 0.0, 17 | [](double sum, const OHLCV &val) { return sum + val.close; }) / period; 18 | 19 | 20 | double covariance = 0.0, variance1 = 0.0, variance2 = 0.0; 21 | for (size_t j = i - period + 1; j <= i; ++j) 22 | { 23 | double diff1 = data1[j].close - mean1; 24 | double diff2 = data2[j].close - mean2; 25 | covariance += diff1 * diff2; 26 | variance1 += diff1 * diff1; 27 | variance2 += diff2 * diff2; 28 | } 29 | 30 | covariance /= period; 31 | variance1 = std::sqrt(variance1 / period); 32 | variance2 = std::sqrt(variance2 / period); 33 | double correlation = (covariance / (variance1 * variance2)); 34 | correlations.push_back(correlation); 35 | } 36 | 37 | return correlations; 38 | } 39 | 40 | SignalResult BayesianCorrelationEstimation::calculateSignal() 41 | { 42 | if (historicalData.size() < period) 43 | return SignalResult(0.0); 44 | 45 | std::vector correlationEstimates = calculate(historicalData, historicalData, period); 46 | 47 | if (!correlationEstimates.empty()) 48 | { 49 | return SignalResult(correlationEstimates.back()); 50 | } 51 | else 52 | { 53 | return SignalResult(0.0); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/ATR.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/ATR.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | SignalResult ATR::calculateSignal() 7 | { 8 | 9 | if (historicalData.size() < 2) 10 | { 11 | throw std::runtime_error("Not enough data to calculate ATR."); 12 | } 13 | 14 | double high = historicalData[historicalData.size() - 2].high; 15 | double low = historicalData[historicalData.size() - 2].low; 16 | double close = historicalData.back().close; 17 | 18 | double tr = std::max({high - low, std::abs(high - previousClose), std::abs(low - previousClose)}); 19 | previousClose = close; 20 | 21 | if (signals.empty()) 22 | { 23 | signals.push_back(tr); 24 | } 25 | else 26 | { 27 | double atr = (signals.back().getSingleValue() * (period - 1) + tr) / period; 28 | signals.push_back(atr); 29 | } 30 | 31 | return SignalResult(signals.back()); 32 | } 33 | 34 | std::vector ATR::calculate(const std::vector &ohlcvData, int period) 35 | { 36 | if (ohlcvData.size() < period) 37 | { 38 | throw std::runtime_error("Not enough data to calculate ATR."); 39 | } 40 | 41 | std::vector atrValues; 42 | std::vector trueRanges; 43 | 44 | for (size_t i = 1; i < ohlcvData.size(); ++i) 45 | { 46 | double tr = std::max({ohlcvData[i].high - ohlcvData[i].low, 47 | std::abs(ohlcvData[i].high - ohlcvData[i - 1].close), 48 | std::abs(ohlcvData[i].low - ohlcvData[i - 1].close)}); 49 | trueRanges.push_back(tr); 50 | } 51 | 52 | double sum = 0.0; 53 | for (size_t i = 0; i < trueRanges.size(); ++i) 54 | { 55 | if (i < period) 56 | { 57 | sum += trueRanges[i]; 58 | if (i == period - 1) 59 | { 60 | atrValues.push_back(sum / period); 61 | } 62 | } 63 | else 64 | { 65 | double atr = (atrValues.back() * (period - 1) + trueRanges[i]) / period; 66 | atrValues.push_back(atr); 67 | } 68 | } 69 | 70 | return atrValues; 71 | } -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/SMA.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/SMA.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | SignalResult SMA::calculateSignal() 7 | { 8 | if (historicalData.size() < period) 9 | { 10 | throw std::runtime_error("Not enough data to calculate SMA."); 11 | } 12 | 13 | double sum = 0.0; 14 | size_t start = historicalData.size() - period; 15 | if (historicalData.size() > PARALLEL_THRESHOLD) 16 | { 17 | sum = std::transform_reduce( 18 | std::execution::par, 19 | historicalData.begin() + start, 20 | historicalData.end(), 21 | 0.0, 22 | std::plus<>{}, 23 | [](const OHLCV &data) 24 | { return data.close; }); 25 | } 26 | else 27 | { 28 | for (size_t i = start; i < historicalData.size(); ++i) 29 | { 30 | sum += historicalData[i].close; 31 | } 32 | } 33 | 34 | double sma = sum / period; 35 | signals.push_back(SignalResult(sma)); 36 | return signals.back(); 37 | } 38 | 39 | std::vector SMA::calculate(const std::vector &historicalData, int period) 40 | { 41 | std::vector result; 42 | if (historicalData.size() < period) 43 | { 44 | throw std::runtime_error("Not enough data to calculate SMA."); 45 | } 46 | 47 | for (size_t i = period - 1; i < historicalData.size(); ++i) 48 | { 49 | double sum = 0.0; 50 | 51 | if (historicalData.size() > PARALLEL_THRESHOLD) 52 | { 53 | sum = std::transform_reduce( 54 | std::execution::par, 55 | historicalData.begin() + (i - period + 1), 56 | historicalData.begin() + i + 1, 57 | 0.0, 58 | std::plus<>{}, 59 | [](const OHLCV &data) 60 | { return data.close; }); 61 | } 62 | else 63 | { 64 | for (size_t j = i - period + 1; j <= i; ++j) 65 | { 66 | sum += historicalData[j].close; 67 | } 68 | } 69 | result.push_back(sum / period); 70 | } 71 | return result; 72 | } -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/components/data-grid/DataGrid.tsx: -------------------------------------------------------------------------------- 1 | import { Theme } from '@mui/material'; 2 | import { Components } from '@mui/material/styles/components'; 3 | 4 | const DataGrid: Components>['MuiDataGrid'] = { 5 | styleOverrides: { 6 | root: ({ theme }) => ({ 7 | border: 'none', 8 | borderRadius: '0 !important', 9 | '--DataGrid-rowBorderColor': theme.palette.info.main, 10 | '&:hover, &:focus': { 11 | '*::-webkit-scrollbar, *::-webkit-scrollbar-thumb': { 12 | visibility: 'visible', 13 | }, 14 | }, 15 | '& .MuiDataGrid-scrollbar--vertical': { 16 | visibility: 'hidden', 17 | }, 18 | '& .MuiDataGrid-scrollbarFiller': { 19 | minWidth: 0, 20 | }, 21 | }), 22 | row: { 23 | '&:hover': { backgroundColor: 'transparent' }, 24 | }, 25 | cell: ({ theme }) => ({ 26 | padding: 0, 27 | color: theme.palette.primary.darker, 28 | fontSize: theme.typography.body2.fontSize, 29 | fontWeight: 500, 30 | '&:focus-within': { 31 | outline: 'none !important', 32 | }, 33 | }), 34 | cellCheckbox: ({ theme }) => ({ 35 | paddingLeft: theme.spacing(2.25), 36 | }), 37 | columnHeaderCheckbox: ({ theme }) => ({ 38 | '& .MuiDataGrid-columnHeaderTitleContainer': { 39 | paddingLeft: theme.spacing(2.25), 40 | }, 41 | }), 42 | columnHeader: { 43 | border: 0, 44 | padding: 0, 45 | height: '3rem !important', 46 | '&:focus-within': { 47 | outline: 'none !important', 48 | }, 49 | }, 50 | columnHeaderTitle: ({ theme }) => ({ 51 | color: theme.palette.text.primary, 52 | fontSize: theme.typography.body2.fontSize, 53 | fontWeight: `${theme.typography.caption.fontWeight} !important`, 54 | }), 55 | iconButtonContainer: () => ({ 56 | '& .MuiIconButton-root': { 57 | backgroundColor: 'transparent !important', 58 | border: 'none', 59 | }, 60 | }), 61 | columnSeparator: { 62 | display: 'none', 63 | }, 64 | selectedRowCount: { 65 | display: 'none', 66 | }, 67 | footerContainer: () => ({ 68 | border: 'none', 69 | }), 70 | }, 71 | }; 72 | 73 | export default DataGrid; -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/top-cards/Total_Trades/ClientChart.tsx: -------------------------------------------------------------------------------- 1 | import { useMemo } from 'react'; 2 | import { SxProps, useTheme } from '@mui/material'; 3 | import * as echarts from 'echarts/core'; 4 | import ReactEchart from 'components/base/ReactEchart'; 5 | import { CanvasRenderer } from 'echarts/renderers'; 6 | import { LineChart } from 'echarts/charts'; 7 | 8 | import { 9 | TitleComponent, 10 | TooltipComponent, 11 | GridComponent, 12 | LegendComponent, 13 | } from 'echarts/components'; 14 | 15 | echarts.use([ 16 | LineChart, 17 | TitleComponent, 18 | TooltipComponent, 19 | GridComponent, 20 | LegendComponent, 21 | CanvasRenderer, 22 | ]); 23 | 24 | interface ClientChartProps { 25 | data: number[]; 26 | sx?: SxProps; 27 | } 28 | 29 | const ClientChart = ({ data, ...rest }: ClientChartProps) => { 30 | const theme = useTheme(); 31 | 32 | const option = useMemo( 33 | () => ({ 34 | grid: { 35 | top: 10, 36 | bottom: 10, 37 | left: 5, 38 | right: 5, 39 | containerLabel: true, 40 | }, 41 | xAxis: { 42 | type: 'category', 43 | data: ['', '', '', '', ''], 44 | axisTick: { 45 | show: false, 46 | }, 47 | axisLine: { 48 | show: false, 49 | }, 50 | boundaryGap: 0, 51 | }, 52 | yAxis: { 53 | type: 'value', 54 | min: 10, 55 | minInterval: 1, 56 | axisLabel: { 57 | show: false, 58 | }, 59 | splitLine: { 60 | show: false, 61 | }, 62 | }, 63 | series: [ 64 | { 65 | data, 66 | type: 'line', 67 | smooth: true, 68 | showSymbol: false, 69 | lineStyle: { 70 | color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [ 71 | { offset: 1, color: 'rgba(84, 112, 198, 0.2)' }, 72 | { offset: 0, color: 'rgba(84, 112, 198, 1)' }, 73 | ]), 74 | width: 3, 75 | type: 'solid', 76 | cap: 'round', 77 | }, 78 | }, 79 | ], 80 | }), 81 | [theme, data], 82 | ); 83 | 84 | return ; 85 | }; 86 | 87 | export default ClientChart; 88 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/balance/index.tsx: -------------------------------------------------------------------------------- 1 | import IconifyIcon from 'components/base/IconifyIcon'; 2 | import Paper from '@mui/material/Paper'; 3 | import Stack from '@mui/material/Stack'; 4 | import Typography from '@mui/material/Typography'; 5 | import FormControl from '@mui/material/FormControl'; 6 | import BalanceChart from './BalanceChart'; 7 | 8 | const Balance = ({ title }: { title: string }) => { 9 | let base: number = +new Date(1968, 9, 3); 10 | const oneDay: number = 24 * 3600 * 1000; 11 | const date: string[] = []; 12 | const chartData: number[] = [Math.random() * 300]; 13 | for (let i = 1; i < 20; i++) { 14 | const now: Date = new Date((base += oneDay)); 15 | date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/')); 16 | chartData.push(Math.round((Math.random() - 0.5) * 20 + chartData[i - 1])); 17 | } 18 | 19 | return ( 20 | 21 | 22 | 27 | 28 | {title} 29 | 30 | 31 | 32 | 33 | On track 34 | 35 | 36 | 37 | 38 | 50 | 51 | 52 | 57 | 58 | ); 59 | }; 60 | 61 | export default Balance; 62 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/top-cards/activity/ActivityChart.tsx: -------------------------------------------------------------------------------- 1 | import { useMemo } from 'react'; 2 | import { SxProps, useTheme } from '@mui/material'; 3 | import * as echarts from 'echarts/core'; 4 | import ReactEchart from 'components/base/ReactEchart'; 5 | import { CanvasRenderer } from 'echarts/renderers'; 6 | import { LineChart } from 'echarts/charts'; 7 | 8 | import { 9 | TitleComponent, 10 | TooltipComponent, 11 | GridComponent, 12 | LegendComponent, 13 | } from 'echarts/components'; 14 | 15 | echarts.use([ 16 | LineChart, 17 | TitleComponent, 18 | TooltipComponent, 19 | GridComponent, 20 | LegendComponent, 21 | CanvasRenderer, 22 | ]); 23 | 24 | interface ActivityChartProps { 25 | data: number[]; 26 | sx?: SxProps; 27 | } 28 | 29 | const ActivityChart = ({ data, ...rest }: ActivityChartProps) => { 30 | const theme = useTheme(); 31 | 32 | const option = useMemo( 33 | () => ({ 34 | grid: { 35 | top: 10, 36 | bottom: 10, 37 | left: 5, 38 | right: 5, 39 | containerLabel: true, 40 | }, 41 | xAxis: { 42 | type: 'category', 43 | data: ['', '', '', '', ''], 44 | axisTick: { 45 | show: false, 46 | }, 47 | axisLine: { 48 | show: false, 49 | }, 50 | boundaryGap: 0, 51 | }, 52 | yAxis: { 53 | type: 'value', 54 | min: 10, 55 | minInterval: 1, 56 | axisLabel: { 57 | show: false, 58 | }, 59 | splitLine: { 60 | show: false, 61 | }, 62 | }, 63 | series: [ 64 | { 65 | data, 66 | type: 'line', 67 | smooth: true, 68 | showSymbol: false, 69 | lineStyle: { 70 | color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [ 71 | { offset: 1, color: 'rgba(84, 112, 198, 0.2)' }, 72 | { offset: 0, color: theme.palette.info.light }, 73 | ]), 74 | width: 3, 75 | type: 'solid', 76 | cap: 'round', 77 | }, 78 | }, 79 | ], 80 | }), 81 | [theme, data], 82 | ); 83 | 84 | return ; 85 | }; 86 | 87 | export default ActivityChart; 88 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/theme/palette.ts: -------------------------------------------------------------------------------- 1 | import { PaletteColorOptions, PaletteOptions } from '@mui/material/styles'; 2 | import { 3 | gray, 4 | red, 5 | green, 6 | blue, 7 | skyblue, 8 | purple, 9 | yellow, 10 | white, 11 | transparentRed, 12 | transparentGreen, 13 | transparentYellow, 14 | } from './colors'; 15 | 16 | declare module '@mui/material/styles' { 17 | interface PaletteOptions { 18 | neutral?: PaletteColorOptions; 19 | transparent?: { 20 | success: PaletteColorOptions; 21 | warning: PaletteColorOptions; 22 | error: PaletteColorOptions; 23 | }; 24 | gradients?: { 25 | primary: PaletteColorOptions; 26 | }; 27 | } 28 | interface SimplePaletteColorOptions { 29 | lighter?: string; 30 | darker?: string; 31 | state?: string; 32 | } 33 | interface Palette { 34 | neutral: PaletteColor; 35 | gradients: { 36 | primary: PaletteColor; 37 | }; 38 | transparent: { 39 | success: PaletteColor; 40 | warning: PaletteColor; 41 | error: PaletteColor; 42 | }; 43 | } 44 | interface PaletteColor { 45 | lighter: string; 46 | darker: string; 47 | state: string; 48 | } 49 | } 50 | 51 | const palette: PaletteOptions = { 52 | neutral: { 53 | main: gray[500], 54 | }, 55 | primary: { 56 | main: purple[500], 57 | }, 58 | secondary: { 59 | light: skyblue[500], 60 | main: blue[500], 61 | }, 62 | info: { 63 | light: white[100], 64 | main: white[200], 65 | dark: white[300], 66 | }, 67 | success: { 68 | main: green[500], 69 | }, 70 | warning: { 71 | main: yellow[500], 72 | }, 73 | error: { 74 | main: red[500], 75 | }, 76 | text: { 77 | primary: blue[500], 78 | secondary: blue[400], 79 | disabled: gray[500], 80 | }, 81 | gradients: { 82 | primary: { 83 | main: purple[500], 84 | state: purple[300], 85 | }, 86 | }, 87 | transparent: { 88 | success: { 89 | main: transparentGreen[500], 90 | }, 91 | warning: { 92 | main: transparentYellow[500], 93 | }, 94 | error: { 95 | main: transparentRed[500], 96 | }, 97 | }, 98 | }; 99 | 100 | export default palette; 101 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/RSI.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/RSI.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | SignalResult RSI::calculateSignal() 8 | { 9 | if (historicalData.size() < period) 10 | { 11 | throw std::runtime_error("Not enough data to calculate RSI."); 12 | } 13 | 14 | double gain = 0.0; 15 | double loss = 0.0; 16 | 17 | for (size_t i = 1; i < historicalData.size(); ++i) 18 | { 19 | double change = historicalData[i].close - historicalData[i - 1].close; 20 | if (change > 0) 21 | { 22 | gain += change; 23 | } 24 | else 25 | { 26 | loss -= change; 27 | } 28 | } 29 | 30 | gain /= period; 31 | loss /= period; 32 | 33 | if (loss == 0) 34 | { 35 | return SignalResult(100.0); 36 | } 37 | 38 | double rs = gain / loss; 39 | double rsi = 100.0 - (100.0 / (1.0 + rs)); 40 | 41 | signals.push_back(SignalResult(rsi)); 42 | return signals.back(); 43 | } 44 | 45 | std::vector RSI::calculate(const std::vector &historicalData, std::size_t period) 46 | { 47 | if (historicalData.size() < period) 48 | { 49 | throw std::runtime_error("Not enough data to calculate RSI."); 50 | } 51 | 52 | std::vector rsiValues; 53 | 54 | for (size_t i = period; i < historicalData.size(); ++i) 55 | { 56 | double gain = 0.0; 57 | double loss = 0.0; 58 | 59 | for (size_t j = i - period + 1; j <= i; ++j) 60 | { 61 | double change = historicalData[j].close - historicalData[j - 1].close; 62 | if (change > 0) 63 | { 64 | gain += change; 65 | } 66 | else 67 | { 68 | loss -= change; 69 | } 70 | } 71 | 72 | gain /= period; 73 | loss /= period; 74 | 75 | double rsi; 76 | if (loss == 0) 77 | { 78 | rsi = 100.0; 79 | } 80 | else 81 | { 82 | double rs = gain / loss; 83 | rsi = 100.0 - (100.0 / (1.0 + rs)); 84 | } 85 | 86 | rsiValues.push_back(rsi); 87 | } 88 | 89 | return rsiValues; 90 | } -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/time_series_models/SARIMA.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/time_series_models/SARIMA.hpp" 2 | #include 3 | 4 | std::vector SARIMA::fitSARIMA(const std::vector &data, int p, int d, int q, int P, int D, int Q, int s) 5 | { 6 | if (data.size() < p + d + q + P + D + Q + s) 7 | throw std::invalid_argument("Insufficient data to fit SARIMA model."); 8 | 9 | std::vector differencedData; 10 | std::vector seasonalDifferencedData; 11 | std::vector predictions; 12 | 13 | for (size_t i = d; i < data.size(); ++i) 14 | { 15 | differencedData.push_back(data[i].close - data[i - d].close); 16 | } 17 | 18 | for (size_t i = s + D; i < differencedData.size(); ++i) 19 | { 20 | seasonalDifferencedData.push_back(differencedData[i] - seasonalDifferencedData[i - s]); 21 | } 22 | 23 | std::vector arTerms(p, 0.0); 24 | std::vector maTerms(q, 0.0); 25 | 26 | for (size_t i = p; i < seasonalDifferencedData.size(); ++i) 27 | { 28 | double arSum = 0.0; 29 | for (int j = 1; j <= p; ++j) 30 | { 31 | arSum += arTerms[j - 1] * seasonalDifferencedData[i - j]; 32 | } 33 | arTerms.push_back(arSum); 34 | } 35 | 36 | for (size_t i = q; i < seasonalDifferencedData.size(); ++i) 37 | { 38 | double maSum = 0.0; 39 | for (int j = 1; j <= q; ++j) 40 | { 41 | maSum += maTerms[j - 1] * (seasonalDifferencedData[i - j] - arTerms[i - j]); 42 | } 43 | maTerms.push_back(maSum); 44 | } 45 | 46 | for (size_t i = 0; i < seasonalDifferencedData.size(); ++i) 47 | { 48 | predictions.push_back(arTerms[i] + maTerms[i]); 49 | } 50 | 51 | return predictions; 52 | } 53 | 54 | SignalResult SARIMA::calculateSignal() 55 | { 56 | if (historicalData.size() < p + d + q + P + D + Q + s) 57 | return SignalResult(0.0); 58 | 59 | std::vector predictions = fitSARIMA(historicalData, p, d, q, P, D, Q, s); 60 | double latestPrediction = predictions.back(); 61 | if (latestPrediction > historicalData.back().close) 62 | { 63 | return SignalResult(latestPrediction); 64 | } 65 | else 66 | { 67 | return SignalResult(-latestPrediction); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/layouts/main-layout/sidebar/DrawerItems.tsx: -------------------------------------------------------------------------------- 1 | import { fontFamily } from 'theme/typography'; 2 | import Link from '@mui/material/Link'; 3 | import Box from '@mui/material/Box'; 4 | import List from '@mui/material/List'; 5 | import Stack from '@mui/material/Stack'; 6 | import ButtonBase from '@mui/material/ButtonBase'; 7 | import Typography from '@mui/material/Typography'; 8 | import ListItem from './list-items/ListItem'; 9 | import CollapseListItem from './list-items/CollapseListItem'; 10 | import Image from 'components/base/Image'; 11 | import LogoImg from 'assets/images/logo.png'; 12 | import sitemap from 'routes/sitemap'; 13 | 14 | const DrawerItems = () => { 15 | return ( 16 | <> 17 | 30 | 31 | logo 32 | 33 | 41 | Velocity Vortex 42 | 43 | 51 | Dashboard 52 | 53 | 54 | 55 | 56 | 57 | 58 | {sitemap.map((route) => 59 | route.items ? ( 60 | 61 | ) : ( 62 | 63 | ), 64 | )} 65 | 66 | 67 | ); 68 | }; 69 | 70 | export default DrawerItems; 71 | -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/statistical models/BayesianKernelRegression.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/statistical_models/BayesianKernelRegression.hpp" 2 | #include 3 | #include 4 | 5 | std::chrono::system_clock::time_point BayesianKernelRegression::parseTimestamp(const std::string ×tamp) 6 | { 7 | std::istringstream ss(timestamp); 8 | std::tm t = {}; 9 | ss >> std::get_time(&t, "%Y-%m-%dT%H:%M:%S"); 10 | if (ss.fail()) 11 | { 12 | throw std::runtime_error("Failed to parse timestamp"); 13 | } 14 | return std::chrono::system_clock::from_time_t(std::mktime(&t)); 15 | } 16 | 17 | std::vector BayesianKernelRegression::performRegression(const std::vector &data, int period) 18 | { 19 | std::vector regressionResults; 20 | 21 | if (data.size() < period) 22 | return regressionResults; 23 | 24 | const double bandwidth = 1.0; 25 | for (size_t i = period - 1; i < data.size(); ++i) 26 | { 27 | double weightedSum = 0.0; 28 | double weightTotal = 0.0; 29 | 30 | for (size_t j = i - period + 1; j <= i; ++j) 31 | { 32 | 33 | auto time1 = parseTimestamp(data[i].timestamp); 34 | auto time2 = parseTimestamp(data[j].timestamp); 35 | auto diff = std::chrono::duration(time1 - time2).count(); 36 | 37 | double distance = std::abs(diff); 38 | double weight = std::exp(-distance * distance / (2 * bandwidth * bandwidth)); 39 | 40 | weightedSum += weight * data[j].close; 41 | weightTotal += weight; 42 | } 43 | 44 | double prediction = weightedSum / weightTotal; 45 | double bayesianAdjustment = std::exp(-std::abs(data[i].close - prediction) / bandwidth); 46 | regressionResults.push_back(prediction * bayesianAdjustment); 47 | } 48 | 49 | return regressionResults; 50 | } 51 | 52 | SignalResult BayesianKernelRegression::calculateSignal() 53 | { 54 | if (historicalData.size() < period) 55 | return SignalResult(0.0); 56 | 57 | std::vector regressionResults = performRegression(historicalData, period); 58 | 59 | if (!regressionResults.empty()) 60 | { 61 | return SignalResult(regressionResults.back()); 62 | } 63 | else 64 | { 65 | return SignalResult(0.0); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Computing-Server/include/Orderbook/order_book.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ORDERBOOK_H 2 | #define ORDERBOOK_H 3 | 4 | #include "./order_.hpp" 5 | #include "./transactions.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | struct LevelInfo 12 | { 13 | Price price_; 14 | Quantity quantity_; 15 | }; 16 | using LevelInfos = std::vector; 17 | 18 | class OrderbookLevelInfos 19 | { 20 | public: 21 | OrderbookLevelInfos(const LevelInfos &bids, const LevelInfos &asks); 22 | 23 | /** 24 | * @brief Gets the bid levels information. 25 | * @return Bid levels information. 26 | */ 27 | const LevelInfos &GetBids() const; 28 | 29 | /** 30 | * @brief Gets the ask levels information. 31 | * @return Ask levels information. 32 | */ 33 | const LevelInfos &GetAsks() const; 34 | 35 | private: 36 | LevelInfos bids_; 37 | LevelInfos asks_; 38 | }; 39 | 40 | class Orderbook 41 | { 42 | public: 43 | Trades_ AddOrder(OrderPointer order); 44 | void CancelOrder(OrderId orderId); 45 | Trades_ ModifyOrder(OrderPointer order); 46 | std::size_t Size() const; 47 | OrderbookLevelInfos GetOrderInfos() const; 48 | bool CanMatch(Side side, Price price) const; 49 | std::pair executeMarketMakingStrategy(int CounterId, double bid_price, double ask_price, Quantity bid_quantity, Quantity ask_quantity); 50 | void setSpreadThreshold(double threshold); 51 | void setImbalanceThreshold(double threshold); 52 | void setPositionLimit(int limit); 53 | void setMaxpositionsize(int siz); 54 | void setMaxTradeSize(int max_trade_size); 55 | int getCurrentPosition() const; 56 | 57 | private: 58 | struct OrderEntry 59 | { 60 | OrderPointer order_; 61 | std::list::iterator location_; 62 | }; 63 | 64 | std::map, std::greater> bids_; 65 | std::map, std::less> asks_; 66 | std::unordered_map orders_; 67 | double spread_threshold_{0.02}; 68 | double imbalance_threshold_{0.65}; 69 | int position_limit_{1000}; 70 | int current_position_{0}; 71 | int max_position_size_{0}; 72 | int max_trade_size_{0}; 73 | 74 | std::vector last_trades_; 75 | std::map entry_prices_; 76 | mutable std::mutex orderbook_mutex; 77 | Trades_ MatchOrders(); 78 | }; 79 | 80 | #endif -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/BollingerBands.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/BollingerBands.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | SignalResult BollingerBands::calculateSignal() 9 | { 10 | if (historicalData.size() < period) 11 | { 12 | throw std::runtime_error("Not enough data to calculate Bollinger Bands."); 13 | } 14 | 15 | auto [upperBand, lowerBand] = calculate(); 16 | 17 | signals.push_back(upperBand); 18 | signals.push_back(lowerBand); 19 | 20 | return SignalResult(0); 21 | } 22 | 23 | std::pair BollingerBands::calculate() const 24 | { 25 | if (historicalData.size() < period) 26 | { 27 | throw std::runtime_error("Not enough data to calculate Bollinger Bands."); 28 | } 29 | double sum = std::accumulate( 30 | historicalData.end() - period, historicalData.end(), 0.0, 31 | [](double acc, const OHLCV& data) { return acc + data.close; }); 32 | 33 | double sq_sum = std::accumulate( 34 | historicalData.end() - period, historicalData.end(), 0.0, 35 | [](double acc, const OHLCV& data) { return acc + data.close * data.close; }); 36 | 37 | double mean = sum / period; 38 | double variance = (sq_sum / period) - (mean * mean); 39 | double stdDev = std::sqrt(variance); 40 | 41 | double upperBand = mean + numStdDev * stdDev; 42 | double lowerBand = mean - numStdDev * stdDev; 43 | 44 | return {upperBand, lowerBand}; 45 | } 46 | 47 | std::pair BollingerBands::calculate(const std::vector &prices, int period, double numStdDev) 48 | { 49 | if (prices.size() < period) 50 | { 51 | throw std::runtime_error("Not enough data to calculate Bollinger Bands."); 52 | } 53 | double sum = std::accumulate( 54 | prices.end() - period, prices.end(), 0.0); 55 | 56 | double sq_sum = std::accumulate( 57 | prices.end() - period, prices.end(), 0.0, 58 | [](double acc, double price) { return acc + price * price; }); 59 | 60 | double mean = sum / period; 61 | double variance = (sq_sum / period) - (mean * mean); 62 | double stdDev = std::sqrt(variance); 63 | 64 | double upperBand = mean + numStdDev * stdDev; 65 | double lowerBand = mean - numStdDev * stdDev; 66 | 67 | return {upperBand, lowerBand}; 68 | } -------------------------------------------------------------------------------- /Computing-Server/src/AlgoEngine-Core/indicators/APO.cpp: -------------------------------------------------------------------------------- 1 | #include "AlgoEngine-Core/algorithm/APO.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | SignalResult APO::calculateSignal() 7 | { 8 | 9 | if (historicalData.size() < period || historicalData.size() < longPeriod) 10 | { 11 | throw std::runtime_error("Not enough data to calculate APO."); 12 | } 13 | 14 | double shortMultiplier = 2.0 / (period + 1); 15 | double shortEMA = historicalData.back().close; 16 | for (size_t i = historicalData.size() - period; i < historicalData.size(); ++i) 17 | { 18 | shortEMA = ((historicalData[i].close - shortEMA) * shortMultiplier) + shortEMA; 19 | } 20 | 21 | double longMultiplier = 2.0 / (longPeriod + 1); 22 | double longEMA = historicalData.back().close; 23 | for (size_t i = historicalData.size() - longPeriod; i < historicalData.size(); ++i) 24 | { 25 | longEMA = ((historicalData[i].close - longEMA) * longMultiplier) + longEMA; 26 | } 27 | 28 | double apoValue = shortEMA - longEMA; 29 | signals.push_back(apoValue); 30 | return SignalResult(signals.back()); 31 | } 32 | 33 | std::vector APO::calculate(const std::vector &ohlcvData, int shortPeriod, int longPeriod) 34 | { 35 | std::vector apoValues; 36 | 37 | if (ohlcvData.size() < std::max(shortPeriod, longPeriod)) 38 | { 39 | throw std::runtime_error("Not enough data to calculate APO."); 40 | } 41 | 42 | std::vector shortEMA(ohlcvData.size(), 0.0); 43 | std::vector longEMA(ohlcvData.size(), 0.0); 44 | 45 | double shortMultiplier = 2.0 / (shortPeriod + 1); 46 | shortEMA[0] = ohlcvData[0].close; 47 | for (size_t i = 1; i < ohlcvData.size(); ++i) 48 | { 49 | shortEMA[i] = ((ohlcvData[i].close - shortEMA[i - 1]) * shortMultiplier) + shortEMA[i - 1]; 50 | } 51 | 52 | double longMultiplier = 2.0 / (longPeriod + 1); 53 | longEMA[0] = ohlcvData[0].close; 54 | for (size_t i = 1; i < ohlcvData.size(); ++i) 55 | { 56 | longEMA[i] = ((ohlcvData[i].close - longEMA[i - 1]) * longMultiplier) + longEMA[i - 1]; 57 | } 58 | 59 | for (size_t i = std::max(shortPeriod, longPeriod) - 1; i < ohlcvData.size(); ++i) 60 | { 61 | double apoValue = shortEMA[i] - longEMA[i]; 62 | apoValues.push_back(apoValue); 63 | } 64 | 65 | return apoValues; 66 | } -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/transactions/index.tsx: -------------------------------------------------------------------------------- 1 | import Paper from '@mui/material/Paper'; 2 | import Stack from '@mui/material/Stack'; 3 | import Button from '@mui/material/Button'; 4 | import Typography from '@mui/material/Typography'; 5 | import IconifyIcon from 'components/base/IconifyIcon'; 6 | 7 | interface TransactionProps { 8 | id: number | string; 9 | type: string; 10 | date: string; 11 | icon: string; 12 | color: string; 13 | } 14 | 15 | const transactions: TransactionProps[] = [ 16 | { 17 | id: 1, 18 | type: 'Public Transport', 19 | date: '22 September 2020', 20 | icon: 'ic:outline-directions-bus-filled', 21 | color: 'primary.main', 22 | }, 23 | { 24 | id: 2, 25 | type: 'Grocery Store', 26 | date: '18 September 2020', 27 | icon: 'ic:outline-shopping-basket', 28 | color: 'success.main', 29 | }, 30 | { 31 | id: 3, 32 | type: 'Public Transport', 33 | date: '22 September 2020', 34 | icon: 'ic:outline-subscriptions', 35 | color: 'warning.main', 36 | }, 37 | ]; 38 | 39 | const Transactions = () => { 40 | return ( 41 | 42 | 43 | Your transactions 44 | 45 | 46 | {transactions.map((item) => ( 47 | 48 | 56 | 57 | 58 | 59 | 60 | {item.type} 61 | 62 | 63 | {item.date} 64 | 65 | 66 | 67 | ))} 68 | 69 | 70 | 78 | 79 | 80 | ); 81 | }; 82 | 83 | export default Transactions; 84 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/routes/router.tsx: -------------------------------------------------------------------------------- 1 | import { Suspense, lazy } from 'react'; 2 | import { Outlet, createBrowserRouter } from 'react-router-dom'; 3 | import MainLayout from 'layouts/main-layout'; 4 | import Splash from 'components/loader/Splash'; 5 | import PageLoader from 'components/loader/PageLoader'; 6 | import Logs from 'pages/Logs/Logs'; 7 | import Portfolio from 'pages/portfolio/Portfolio'; 8 | 9 | const App = lazy(() => import('App')); 10 | const Dashboard = lazy(() => import('pages/dashboard/Dashbaord')); 11 | 12 | const router = createBrowserRouter( 13 | [ 14 | { 15 | element: ( 16 | }> 17 | 18 | 19 | ), 20 | children: [ 21 | { 22 | path: '/', 23 | element: ( 24 | 25 | }> 26 | 27 | 28 | 29 | ), 30 | children: [ 31 | { 32 | index: true, 33 | element: , 34 | }, 35 | ], 36 | }, 37 | ], 38 | }, 39 | 40 | { 41 | element: ( 42 | }> 43 | 44 | 45 | ), 46 | children: [ 47 | { 48 | path: '/logs', 49 | element: ( 50 | 51 | }> 52 | 53 | 54 | 55 | ), 56 | children: [ 57 | { 58 | index: true, 59 | element: , 60 | }, 61 | ], 62 | }, 63 | ], 64 | }, 65 | 66 | { 67 | element: ( 68 | }> 69 | 70 | 71 | ), 72 | children: [ 73 | { 74 | path: '/Portfolio', 75 | element: ( 76 | 77 | }> 78 | 79 | 80 | 81 | ), 82 | children: [ 83 | { 84 | index: true, 85 | element: , 86 | }, 87 | ], 88 | }, 89 | ], 90 | }, 91 | ], 92 | { 93 | basename: '/Velocity-Vortex', 94 | }, 95 | ); 96 | 97 | export default router; 98 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/components/sections/dashboard/earnings/EarningsChart.tsx: -------------------------------------------------------------------------------- 1 | import { useMemo } from 'react'; 2 | import { SxProps, useTheme } from '@mui/material'; 3 | import * as echarts from 'echarts/core'; 4 | import ReactEchart from 'components/base/ReactEchart'; 5 | import { CanvasRenderer } from 'echarts/renderers'; 6 | import { LineChart } from 'echarts/charts'; 7 | 8 | import { 9 | TitleComponent, 10 | TooltipComponent, 11 | GridComponent, 12 | LegendComponent, 13 | } from 'echarts/components'; 14 | 15 | echarts.use([ 16 | LineChart, 17 | TitleComponent, 18 | TooltipComponent, 19 | GridComponent, 20 | LegendComponent, 21 | CanvasRenderer, 22 | ]); 23 | 24 | interface ClientChartProps { 25 | data: number[]; 26 | sx?: SxProps; 27 | } 28 | 29 | const EarningsChart = ({ data, ...rest }: ClientChartProps) => { 30 | const theme = useTheme(); 31 | 32 | const option = useMemo( 33 | () => ({ 34 | tooltip: { 35 | trigger: 'axis', 36 | formatter: 'Earnings: ${c}', 37 | }, 38 | grid: { 39 | top: 40, 40 | bottom: 70, 41 | left: 0, 42 | right: 0, 43 | containerLabel: true, 44 | }, 45 | xAxis: { 46 | type: 'category', 47 | data: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], 48 | axisTick: { 49 | show: false, 50 | }, 51 | axisLine: { 52 | show: false, 53 | }, 54 | boundaryGap: 0, 55 | }, 56 | yAxis: { 57 | type: 'value', 58 | min: 10, 59 | minInterval: 1, 60 | axisLabel: { 61 | show: false, 62 | }, 63 | splitLine: { 64 | show: false, 65 | }, 66 | }, 67 | series: [ 68 | { 69 | data, 70 | type: 'line', 71 | smooth: true, 72 | showSymbol: false, 73 | symbol: 'none', 74 | lineStyle: { 75 | width: 3, 76 | type: 'solid', 77 | cap: 'round', 78 | color: theme.palette.primary.main, 79 | }, 80 | areaStyle: { 81 | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ 82 | { offset: 0, color: 'rgba(84, 112, 198, 0.5)' }, 83 | { offset: 1, color: 'rgba(84, 112, 198, 0)' }, 84 | ]), 85 | }, 86 | }, 87 | ], 88 | }), 89 | [theme, data], 90 | ); 91 | 92 | return ; 93 | }; 94 | 95 | export default EarningsChart; 96 | -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/layouts/main-layout/topbar/index.tsx: -------------------------------------------------------------------------------- 1 | import Link from '@mui/material/Link'; 2 | import Stack from '@mui/material/Stack'; 3 | import Toolbar from '@mui/material/Toolbar'; 4 | import TextField from '@mui/material/TextField'; 5 | import ButtonBase from '@mui/material/ButtonBase'; 6 | import IconButton from '@mui/material/IconButton'; 7 | import InputAdornment from '@mui/material/InputAdornment'; 8 | import IconifyIcon from 'components/base/IconifyIcon'; 9 | import Image from 'components/base/Image'; 10 | import LogoImg from 'assets/images/logo.png'; 11 | 12 | interface TopbarProps { 13 | isClosing: boolean; 14 | mobileOpen: boolean; 15 | setMobileOpen: React.Dispatch>; 16 | } 17 | 18 | const Topbar = ({ isClosing, mobileOpen, setMobileOpen }: TopbarProps) => { 19 | const handleDrawerToggle = () => { 20 | if (!isClosing) { 21 | setMobileOpen(!mobileOpen); 22 | } 23 | }; 24 | 25 | return ( 26 | 33 | 34 | 40 | logo 41 | 42 | 43 | 44 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | , 67 | }} 68 | /> 69 | 70 | 71 | ); 72 | }; 73 | 74 | export default Topbar; 75 | -------------------------------------------------------------------------------- /Computing-Server/src/Risk-Analysis-Core/CorrelationAnalyzer.cpp: -------------------------------------------------------------------------------- 1 | #include "Risk-Analysis-Core/CorrelationAnalyzer.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void CorrelationAnalyzer::load_price_data(std::map> historicalData) 9 | { 10 | 11 | // stock_symbols = {"AAPL", "MSFT", "GOOGL"}; 12 | // price_data["AAPL"] = {150.0, 152.0, 153.0, 155.0, 154.0}; 13 | // price_data["MSFT"] = {250.0, 251.0, 253.0, 252.0, 251.0}; 14 | // price_data["GOOGL"] = {2800.0, 2825.0, 2830.0, 2805.0, 2810.0}; 15 | 16 | for (auto x : historicalData) 17 | { 18 | price_data[x.first] = x.second; 19 | } 20 | } 21 | 22 | double CorrelationAnalyzer::calculate_correlation(const std::string &stock1, const std::string &stock2) 23 | { 24 | if (price_data.find(stock1) == price_data.end() || price_data.find(stock2) == price_data.end()) 25 | { 26 | std::cerr << "Stock symbol not found." << std::endl; 27 | return 0.0; 28 | } 29 | 30 | const std::vector &prices1 = price_data[stock1]; 31 | const std::vector &prices2 = price_data[stock2]; 32 | 33 | if (prices1.size() != prices2.size()) 34 | { 35 | std::cerr << "Price data lengths do not match." << std::endl; 36 | return 0.0; 37 | } 38 | 39 | double mean1 = std::accumulate(prices1.begin(), prices1.end(), 0.0) / prices1.size(); 40 | double mean2 = std::accumulate(prices2.begin(), prices2.end(), 0.0) / prices2.size(); 41 | 42 | double covariance = 0.0; 43 | double variance1 = 0.0; 44 | double variance2 = 0.0; 45 | 46 | for (size_t i = 0; i < prices1.size(); ++i) 47 | { 48 | covariance += (prices1[i] - mean1) * (prices2[i] - mean2); 49 | variance1 += (prices1[i] - mean1) * (prices1[i] - mean1); 50 | variance2 += (prices2[i] - mean2) * (prices2[i] - mean2); 51 | } 52 | 53 | covariance /= prices1.size(); 54 | variance1 /= prices1.size(); 55 | variance2 /= prices2.size(); 56 | 57 | return covariance / (std::sqrt(variance1) * std::sqrt(variance2)); 58 | } 59 | 60 | std::vector> CorrelationAnalyzer::get_correlation_matrix() 61 | { 62 | size_t n = stock_symbols.size(); 63 | std::vector> correlation_matrix(n, std::vector(n, 0.0)); 64 | 65 | for (size_t i = 0; i < n; ++i) 66 | { 67 | for (size_t j = 0; j < n; ++j) 68 | { 69 | correlation_matrix[i][j] = calculate_correlation(stock_symbols[i], stock_symbols[j]); 70 | } 71 | } 72 | 73 | return correlation_matrix; 74 | } -------------------------------------------------------------------------------- /Monitoring-Server/Front-End/src/layouts/main-layout/sidebar/list-items/CollapseListItem.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { MenuItem } from 'routes/sitemap'; 3 | import Box from '@mui/material/Box'; 4 | import Link from '@mui/material/Link'; 5 | import List from '@mui/material/List'; 6 | import Collapse from '@mui/material/Collapse'; 7 | import ListItemIcon from '@mui/material/ListItemIcon'; 8 | import ListItemText from '@mui/material/ListItemText'; 9 | import ListItemButton from '@mui/material/ListItemButton'; 10 | import IconifyIcon from 'components/base/IconifyIcon'; 11 | 12 | const CollapseListItem = ({ subheader, active, items, icon }: MenuItem) => { 13 | const [open, setOpen] = useState(false); 14 | 15 | const handleClick = () => { 16 | setOpen(!open); 17 | }; 18 | 19 | return ( 20 | 21 | 22 | 23 | {icon && ( 24 | 30 | )} 31 | 32 | 40 | 48 | 49 | 50 | 51 | 52 | {items?.map((route) => { 53 | return ( 54 | 60 | 68 | 69 | ); 70 | })} 71 | 72 | 73 | 74 | ); 75 | }; 76 | 77 | export default CollapseListItem; 78 | --------------------------------------------------------------------------------