-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SMLP-013 Convert all used timestamps to timestamps with milliseconds
- Loading branch information
Showing
12 changed files
with
156 additions
and
19 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
''' This file run methods for data creation ''' | ||
from app.lib.api_exmo_client import ApiExmoClient | ||
from app.lib.data_fetcher import DataFetcher | ||
from app.lib.utils import current_timestamp, days | ||
|
||
from_timestamp = current_timestamp() - days(365) | ||
data_fetcher = DataFetcher(api_client = ApiExmoClient(resolution = 'D'), | ||
from_timestamp = from_timestamp, | ||
to_timestamp = current_timestamp(), | ||
batch_size_in_milliseconds = days(25)) | ||
|
||
data_fetcher = DataFetcher(api_client = ApiExmoClient(), fetch_interval_size = 60 * 1000) | ||
result = data_fetcher.update('BTC_USDT') | ||
|
||
print(f'{result=}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
''' This file contains unit tests for app/lib/utils.py ''' | ||
import unittest | ||
from datetime import datetime | ||
from app.lib.utils import current_timestamp | ||
|
||
class TestCurrentTimestamp(unittest.TestCase): | ||
''' This class runs all tests for current_timestamp method ''' | ||
def test_current_timestamp_returns_current_time(self): | ||
''' This case checks the result for a valid timestamp ''' | ||
expected_timestamp = int(datetime.now().timestamp() * 1000) | ||
self.assertEqual(current_timestamp(), expected_timestamp) |
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 @@ | ||
''' This file contains unit tests for app/lib/utils.py ''' | ||
import unittest | ||
from app.lib.utils import days | ||
|
||
class TestDays(unittest.TestCase): | ||
''' This class runs all tests for days method ''' | ||
def test_days_returns_zero(self): | ||
''' This case checks the result for a valid zero timestamp ''' | ||
self.assertEqual(days(0), 0) | ||
|
||
def test_days_returns_for_integer_argument(self): | ||
''' This case checks the correct result for integer argument ''' | ||
self.assertEqual(days(11), 950400000) | ||
|
||
def test_days_returns_for_float_argument(self): | ||
''' This case checks the correct result for float argument ''' | ||
self.assertEqual(days(1.45), 125280000) |
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 @@ | ||
''' This file contains unit tests for app/lib/utils.py ''' | ||
import unittest | ||
from app.lib.utils import hours | ||
|
||
class TestHours(unittest.TestCase): | ||
''' This class runs all tests for hours method ''' | ||
def test_hours_returns_zero(self): | ||
''' This case checks the result for a valid zero timestamp ''' | ||
self.assertEqual(hours(0), 0) | ||
|
||
def test_hours_returns_for_integer_argument(self): | ||
''' This case checks the correct result for integer argument ''' | ||
self.assertEqual(hours(11), 39600000) | ||
|
||
def test_hours_returns_for_float_argument(self): | ||
''' This case checks the correct result for float argument ''' | ||
self.assertEqual(hours(1.45), 5220000) |
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 @@ | ||
''' This file contains unit tests for app/lib/utils.py ''' | ||
import unittest | ||
from app.lib.utils import minutes | ||
|
||
class TestMinutes(unittest.TestCase): | ||
''' This class runs all tests for minutes method ''' | ||
def test_minutes_returns_zero(self): | ||
''' This case checks the result for a valid zero timestamp ''' | ||
self.assertEqual(minutes(0), 0) | ||
|
||
def test_minutes_returns_for_integer_argument(self): | ||
''' This case checks the correct result for integer argument ''' | ||
self.assertEqual(minutes(11), 660000) | ||
|
||
def test_minutes_returns_for_float_argument(self): | ||
''' This case checks the correct result for float argument ''' | ||
self.assertEqual(minutes(1.45), 87000) |
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 @@ | ||
''' This file contains unit tests for app/lib/utils.py ''' | ||
import unittest | ||
from app.lib.utils import seconds | ||
|
||
class TestSeconds(unittest.TestCase): | ||
''' This class runs all tests for seconds method ''' | ||
def test_seconds_returns_zero(self): | ||
''' This case checks the result for a valid zero timestamp ''' | ||
self.assertEqual(seconds(0), 0) | ||
|
||
def test_seconds_returns_for_integer_argument(self): | ||
''' This case checks the correct result for integer argument ''' | ||
self.assertEqual(seconds(11), 11000) | ||
|
||
def test_seconds_returns_for_float_argument(self): | ||
''' This case checks the correct result for float argument ''' | ||
self.assertEqual(seconds(1.45), 1450) |