Skip to content

Commit

Permalink
Merge pull request #17 from globophobe/fix/readme
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
globophobe authored Mar 7, 2023
2 parents bf013dd + ac284e2 commit 4d1d74c
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 197 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ python proxy.py trades

Then, configure a Cloud Workflow to collect data in the cloud. There is an example workflow in the [invoke tasks](https://github.com/globophobe/django-quant-candles/blob/main/demo/tasks.py).

<img src="https://raw.githubusercontent.com/globophobe/django-quant-candles/main/docs/assets/
diagrams_image.png" alt="Deployment example"/>

Environment
-----------

Expand Down
19 changes: 16 additions & 3 deletions demo/streamlit/sampling_techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def get_data_frames() -> dict[Any, DataFrame]:
return data_frames


style = mpf.make_mpf_style(base_mpf_style="nightclouds")

for candle, data_frame in get_data_frames().items():
from quant_candles.constants import Frequency
from quant_candles.models import AdaptiveCandle, TimeBasedCandle
Expand All @@ -64,14 +66,25 @@ def get_data_frames() -> dict[Any, DataFrame]:
title = f"{total_minutes} minutes, {total_candles} candles"
elif isinstance(candle, AdaptiveCandle):
sample_type = candle.json_data["sample_type"].capitalize()
title = f"{sample_type}, {total_candles} candles"
target_candles_per_day = candle.json_data["target_candles_per_day"]
moving_average_number_of_days = candle.json_data[
"moving_average_number_of_days"
]
title = (
f"{sample_type}, {total_candles} candles\n"
f"Target {target_candles_per_day} candles per day "
f"using {moving_average_number_of_days} day moving average"
)

fig, ax = mpf.plot(
data_frame,
title=title,
axtitle=title,
type="candle",
datetime_format="%Y-%m-%d",
ylabel="",
style=style,
show_nontrading=True,
figsize=(15, 10),
style="nightclouds",
returnfig=True,
)

Expand Down
Binary file removed docs/assets/diagrams_image.png
Binary file not shown.
Binary file removed docs/assets/django-pony.png
Binary file not shown.
Binary file modified docs/assets/volume-candles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/assets/workflows.png
Binary file not shown.
19 changes: 0 additions & 19 deletions docs/diagram.py

This file was deleted.

249 changes: 84 additions & 165 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ randomname = "*"
[tool.poetry.dev-dependencies]
black = "*"
coverage = "*"
diagrams = "*"
django-filter = "*"
django-semantic-admin = "*"
django-storages = {version = "*", extras = ["google"]}
Expand Down
11 changes: 8 additions & 3 deletions quant_candles/models/candles.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ def aggregate(
raise NotImplementedError

def get_data(
self, timestamp_from: datetime, timestamp_to: datetime, limit: int = 10000
self,
timestamp_from: datetime,
timestamp_to: datetime,
limit: Optional[int] = None,
) -> list:
"""Get data."""
query = (
Expand All @@ -198,13 +201,15 @@ def get_data(
.order_by("-timestamp")
.values("timestamp", "json_data")
)
candle_data = candle_data[:limit]
if limit:
candle_data = candle_data[:limit]
candle_read_only_data = (
CandleReadOnlyData.objects.filter(query)
.order_by("-timestamp")
.values("timestamp", "json_data")
)
candle_read_only_data = candle_read_only_data[: limit - candle_data.count()]
if limit:
candle_read_only_data = candle_read_only_data[: limit - candle_data.count()]
return list(chain(candle_data, candle_read_only_data))

def get_trade_data_summary(
Expand Down
4 changes: 1 addition & 3 deletions quant_candles/views/candles.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def get(self, request: Request, *args, **kwargs) -> Response:
params = serializer.validated_data
candle = self.get_object()
data = candle.get_data(
params["timestamp_from"],
params["timestamp_to"],
limit=params["limit"],
params["timestamp_from"], params["timestamp_to"], limit=params["limit"]
)
return Response(CandleDataSerializer(data, many=True).data)

0 comments on commit 4d1d74c

Please sign in to comment.