-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>17.0</VCProjectVersion> | ||
<Keyword>Win32Proj</Keyword> | ||
<ProjectGuid>{a3fc9383-2eb8-4446-b8f9-7d5725159458}</ProjectGuid> | ||
<RootNamespace>CryptoTradingBot</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="CryptoTradingBot.cpp" /> | ||
<ClCompile Include="tradingbot.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="tradingbot.h" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <Windows.h> | ||
#include <Wininet.h> | ||
#include <random> | ||
#include <math.h> | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
|
||
|
||
namespace inet | ||
{ | ||
std::string read_url(std::string url); | ||
DWORD post_request(std::string url, std::string request, DWORD* code, std::string* response); | ||
bool webstatus_check(const std::string& szAddress, DWORD* pdwWebStat); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
|
||
#include <iostream> | ||
#include <Windows.h> | ||
|
||
#include "tradingbot.h" | ||
|
||
int main() | ||
{ | ||
int send_id; | ||
std::string webhook; | ||
std::string token, user_id; | ||
|
||
std::string info = "[Crypto-Trading Bot] - by Trandor"; | ||
SetConsoleTitleA(info.c_str()); | ||
|
||
HANDLE hfile = CreateFileA(("settings.txt"), FILE_ALL_ACCESS, NULL, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | ||
DWORD file_size = GetFileSize(hfile, nullptr); | ||
if (hfile == NULL || hfile == INVALID_HANDLE_VALUE || file_size < 10) { | ||
CloseHandle(hfile); | ||
int t = 0; | ||
gt: | ||
std::cout << ("choose where to send the information\n1 - Discord\n2 - Telegram\n"); | ||
std::cin >> t; | ||
if (t == 1) { | ||
|
||
std::string webhook = ""; | ||
std::cout << ("enter the server's webhook:\n"); | ||
std::cin >> webhook; | ||
hfile = CreateFileA(("settings.txt"), FILE_ALL_ACCESS, NULL, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); | ||
std::string write = ("discord\n") + webhook; | ||
WriteFile(hfile, write.c_str(), write.size(), nullptr, nullptr); | ||
CloseHandle(hfile); | ||
} | ||
else if (t == 2) { | ||
|
||
std::string token = "", user = ""; | ||
std::cout << ("enter the telegram bot token:\n"); | ||
std::cin >> token; | ||
std::cout << ("enter your user id:\n"); | ||
std::cin >> user; | ||
std::string write = ("telegram\n") + token + ("\n") + user; | ||
WriteFile(hfile, write.c_str(), write.size(), nullptr, nullptr); | ||
CloseHandle(hfile); | ||
|
||
} | ||
else { | ||
goto gt; | ||
} | ||
std::cout << ("Saved!\n\n"); | ||
} | ||
else | ||
{ | ||
std::cout << ("your settings are loaded\n\n"); | ||
} | ||
|
||
std::cout << ("start searching and calculating?(Y\\n)\n"); | ||
while (!GetAsyncKeyState('Y')) { | ||
Sleep(1); | ||
} | ||
system(("cls")); | ||
tradingbot bot(send_id, webhook, token, user_id); | ||
|
||
while (true) | ||
{ | ||
std::cout << ("recognize cryptocurrency prices (from Binance)...\n"); | ||
bot.get_crypto_prices(); | ||
|
||
std::cout << ("looking for strong price movements in a short period of time...\n"); | ||
|
||
std::vector<crypto> movements = bot.get_strong_movements(); | ||
if (movements.size() == 0) { | ||
std::cout << ("no major price movements yet.\n"); | ||
} | ||
else { | ||
bot.send_info(ID_MOVEMENT, &movements); | ||
} | ||
|
||
std::cout << ("parsing cryptocurrency news...\n"); | ||
std::vector<news> crypto_news = bot.parse_news(); | ||
|
||
if (crypto_news.size() > 0) { | ||
bot.send_info(ID_NEWS, &crypto_news); | ||
} | ||
|
||
std::cout << ("looking for signals...\n"); | ||
std::vector<std::string> signals = bot.get_signals(); | ||
|
||
if (signals.size() > 0) { | ||
bot.send_info(ID_SIGNALS, &signals); | ||
} | ||
|
||
std::cout << ("view whale wallet transactions...\n"); | ||
std::vector<transaction> whale_transactions = bot.get_new_whale_transactions(); | ||
|
||
if (whale_transactions.size() > 0) { | ||
bot.send_info(ID_WHALE, &whale_transactions); | ||
} | ||
|
||
std::cout << ("repetition in 2 minutes\n"); | ||
Sleep(120); | ||
std::cout << "\n\n"; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "tradingbot.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include "inet.h" | ||
|
||
#define ID_MOVEMENT 1 | ||
#define ID_NEWS 2 | ||
#define ID_SIGNALS 3 | ||
#define ID_WHALE 4 | ||
|
||
struct crypto { | ||
std::string name; | ||
float price; | ||
float change; | ||
float per_min; | ||
}; | ||
|
||
struct news { | ||
std::string caption; | ||
std::string text; | ||
time_t creation_time; | ||
}; | ||
|
||
struct transaction { | ||
std::string sender; | ||
crypto cryptocurrency; | ||
float count; | ||
float total_price; | ||
time_t time; | ||
|
||
}; | ||
|
||
class tradingbot | ||
{ | ||
public: | ||
tradingbot(int send_id, std::string webhook, std::string token, std::string user_id); | ||
|
||
void get_crypto_prices(); | ||
std::vector<crypto> get_strong_movements(); | ||
std::vector<news> parse_news(); | ||
std::vector<std::string> get_signals(); | ||
std::vector<transaction> get_new_whale_transactions(); | ||
|
||
bool send_info(int info_id, void* data); | ||
|
||
private: | ||
int send_id; | ||
std::string webhook; | ||
std::string token, user_id; | ||
|
||
std::vector<crypto> cryptocurrencies; | ||
|
||
}; | ||
|