diff --git a/Exchange/Resources/Php/Exchange/ExchangeManager.php b/Exchange/Resources/Php/Exchange/ExchangeManager.php index df09781..e28e2b3 100644 --- a/Exchange/Resources/Php/Exchange/ExchangeManager.php +++ b/Exchange/Resources/Php/Exchange/ExchangeManager.php @@ -1,15 +1,22 @@ - \ No newline at end of file +logPrice($exchange, 0.0); + + // TODO: exchange selection + return new Binance($apiKey, $apiSecret); + } +} +?> diff --git a/Exchange/Resources/Php/Exchange/PriceLogger.php b/Exchange/Resources/Php/Exchange/PriceLogger.php new file mode 100644 index 0000000..0d51b17 --- /dev/null +++ b/Exchange/Resources/Php/Exchange/PriceLogger.php @@ -0,0 +1,26 @@ +logFile = __DIR__ . "/price_history.log"; + } + + public function logPrice(string $symbol, float $price): void + { + $timestamp = date("Y-m-d H:i:s"); + + $entry = "[" . $timestamp . "] " . $symbol . " => " . $price . PHP_EOL; + + try { + file_put_contents($this->logFile, $entry, FILE_APPEND); + } catch (\Exception $e) { + error_log("Price Logger Error: " . $e->getMessage()); + } + } +} diff --git a/README.md b/README.md index c12c1d5..c777ea7 100644 --- a/README.md +++ b/README.md @@ -116,3 +116,9 @@ class ExchangeName extends Exchange { Im not sure if i will continue to work on this project, but if people want me to i will probaly continue. For private support, Contact me via discord Rick404#8294. + + +## Contribution + +This project was improved as part of a learning contribution. +Contributor: Sneha Debnath