Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fish
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rongjun
fish
Commits
5d31a0df
Commit
5d31a0df
authored
Oct 08, 2018
by
rongjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
c11e6569
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
5 deletions
+35
-5
views.py
apps/market/views.py
+25
-5
models.py
apps/task/models.py
+10
-0
test_PyCTP.py
fish/test_PyCTP.py
+0
-0
No files found.
apps/market/views.py
View file @
5d31a0df
# coding=utf8
import
traceback
from
datetime
import
datetime
from
decimal
import
Decimal
from
django.db
import
IntegrityError
from
django.http.response
import
HttpResponse
from
apps.task.models
import
Task
from
apps.task.models
import
Task
,
TaskNotify
from
core.utils.email
import
send
from
django_q.tasks
import
async_task
from
core.utils
import
log
as
logger
def
cta
(
timestamp
,
last_price
,
task
):
...
...
@@ -12,19 +15,22 @@ def cta(timestamp, last_price, task):
_type
=
task
.
get
(
'type'
)
max_val
=
Decimal
(
task
.
get
(
'max_val'
))
min_val
=
Decimal
(
task
.
get
(
'min_val'
))
style
=
''
style
=
None
point
=
''
point_val
=
None
over
=
False
if
_type
==
'A'
:
if
max_val
==
min_val
:
if
last_price
>
min_val
:
style
=
'突破'
point
=
'预值'
point_val
=
min_val
over
=
True
else
:
if
last_price
<
min_val
:
style
=
'回调'
point
=
'突破原点'
point_val
=
min_val
over
=
True
m
=
max_val
-
min_val
p1
=
min_val
+
m
*
Decimal
(
'0.333'
)
...
...
@@ -32,20 +38,24 @@ def cta(timestamp, last_price, task):
if
last_price
>=
p1
:
style
=
'突破'
point
=
'0.333'
point_val
=
p1
if
last_price
>=
p2
:
style
=
'突破'
point
=
'0.382'
point_val
=
p2
over
=
True
if
_type
==
'D'
:
if
max_val
==
min_val
:
if
last_price
<
min_val
:
style
=
'突破'
point
=
'预值'
point_val
=
min_val
over
=
True
else
:
if
last_price
>
max_val
:
style
=
'回调'
point
=
'突破原点'
point_val
=
max_val
over
=
True
m
=
max_val
-
min_val
p1
=
max_val
-
m
*
Decimal
(
'0.333'
)
...
...
@@ -53,9 +63,11 @@ def cta(timestamp, last_price, task):
if
last_price
<=
p1
:
style
=
'突破'
point
=
'0.333'
point_val
=
p1
if
last_price
<=
p2
:
style
=
'突破'
point
=
'0.382'
point_val
=
p2
over
=
True
_title
=
'【{}{}】的提醒'
_content
=
'【{}】,镜像空间【{}-{}】,预期趋势【{}】;在【{}】【{}】点位为【{}】'
...
...
@@ -63,9 +75,17 @@ def cta(timestamp, last_price, task):
title
=
_title
.
format
(
style
,
point
)
content
=
_content
.
format
(
task
.
get
(
'name'
),
task
.
get
(
'max_val'
),
task
.
get
(
'min_val'
),
task
.
get
(
'type'
),
times
,
style
,
last_price
)
if
over
:
Task
.
remove_task
(
task
)
send
(
title
,
content
,
task
.
get
(
'emails'
))
if
style
:
try
:
TaskNotify
.
objects
.
create
(
task_id
=
task
.
get
(
'id'
),
point
=
point_val
)
if
over
:
Task
.
remove_task
(
task
)
send
(
title
,
content
,
task
.
get
(
'emails'
))
except
IntegrityError
:
pass
except
Exception
as
e
:
trace
=
traceback
.
format_exc
()
logger
.
error
(
trace
)
def
push
(
request
):
...
...
apps/task/models.py
View file @
5d31a0df
...
...
@@ -47,3 +47,12 @@ class Task(BaseModel):
def
remove_task
(
task
):
Task
.
objects
.
filter
(
pk
=
int
(
task
.
get
(
'id'
)))
.
update
(
active
=
False
)
Task
.
set_active_list
(
task
.
get
(
'instrument'
))
class
TaskNotify
(
BaseModel
):
task_id
=
models
.
IntegerField
()
point
=
models
.
CharField
(
max_length
=
200
)
class
Meta
:
ordering
=
[
'-id'
]
unique_together
=
(
'task_id'
,
'point'
)
\ No newline at end of file
fish/test_PyCTP.py
0 → 100644
View file @
5d31a0df
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment