Skip to content

Commit 349a0af

Browse files
authored
Merge pull request #320 from minos-framework/restyled/0.6.0
Restyle 0.6.0
2 parents 1e830fd + 1e8d5d5 commit 349a0af

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

tutorials/stock-wallet/microservices/stocks/src/commands/services.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import logging
22

33
import pendulum
4+
from polygon import (
5+
RESTClient,
6+
)
7+
48
from minos.aggregate import (
59
Event,
610
)
@@ -15,7 +19,6 @@
1519
from ..aggregates import (
1620
StocksAggregate,
1721
)
18-
from polygon import RESTClient
1922

2023
logger = logging.getLogger(__name__)
2124

@@ -31,8 +34,9 @@ async def set_stock_ticker(self, request: Request):
3134

3235
def call_remote(self, ticker, from_: str, to_: str):
3336
with RESTClient("") as client:
34-
resp = client.stocks_equities_aggregates(ticker, 1, "hour", from_, to_, adjusted=True, sort="asc",
35-
limit=50000)
37+
resp = client.stocks_equities_aggregates(
38+
ticker, 1, "hour", from_, to_, adjusted=True, sort="asc", limit=50000
39+
)
3640
return resp.results
3741

3842
@enroute.periodic.event("* * * * *")
@@ -43,16 +47,15 @@ async def get_stock_values(self, request: Request):
4347
if len(tickers) > 0:
4448
for ticker in tickers:
4549
ticker_updated = pendulum.parse(ticker["updated"])
46-
results = await self.call_remote(ticker["ticker"],
47-
now_minus_one_month.to_date_string(),
48-
now.to_date_string())
50+
results = await self.call_remote(
51+
ticker["ticker"], now_minus_one_month.to_date_string(), now.to_date_string()
52+
)
4953
for result in results:
5054
result_date = pendulum.parse(result["t"])
5155
difference_ticker_result = ticker_updated.diff(result_date).in_hours()
5256
if difference_ticker_result < 0:
5357
await StocksAggregate.update_time_ticker(ticker["uuid"], result_date.to_datetime_string())
5458
when = result_date.to_datetime_string()
55-
await StocksAggregate.add_quotes(ticker["uuid"], {"close": result['c'],
56-
"volume": result['v'],
57-
"when": when})
58-
59+
await StocksAggregate.add_quotes(
60+
ticker["uuid"], {"close": result["c"], "volume": result["v"], "when": when}
61+
)

tutorials/stock-wallet/microservices/stocks/tests/test_commands/test_services.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import unittest
33

44
import pendulum
5-
65
from src import (
76
Stocks,
87
StocksCommandService,
@@ -39,6 +38,5 @@ async def test_get_remote_quotes(self):
3938
self.assertIsInstance(response, list)
4039

4140

42-
4341
if __name__ == "__main__":
4442
unittest.main()

0 commit comments

Comments
 (0)