Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
alpha-mind
Project
Project
Details
Activity
Releases
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
Dr.李
alpha-mind
Commits
178d005b
Unverified
Commit
178d005b
authored
Mar 16, 2018
by
Dr.李
Committed by
GitHub
Mar 16, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4 from lion-sing/master
add internal borrow flag for outright management
parents
6af6574d
233c92ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
models.py
alphamind/data/dbmodel/models.py
+1
-0
sqlengine.py
alphamind/data/engines/sqlengine.py
+10
-4
No files found.
alphamind/data/dbmodel/models.py
View file @
178d005b
...
@@ -1938,6 +1938,7 @@ class Outright(Base):
...
@@ -1938,6 +1938,7 @@ class Outright(Base):
price_rule
=
Column
(
String
(
50
),
nullable
=
False
)
price_rule
=
Column
(
String
(
50
),
nullable
=
False
)
due_date
=
Column
(
DateTime
)
due_date
=
Column
(
DateTime
)
remark
=
Column
(
Text
,
nullable
=
True
)
remark
=
Column
(
Text
,
nullable
=
True
)
internal_borrow
=
Column
(
Boolean
,
server_default
=
text
(
"false"
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
alphamind/data/engines/sqlengine.py
View file @
178d005b
...
@@ -888,21 +888,27 @@ class SqlEngine(object):
...
@@ -888,21 +888,27 @@ class SqlEngine(object):
index
=
False
,
index
=
False
,
dtype
=
{
'weight'
:
sa
.
types
.
JSON
})
dtype
=
{
'weight'
:
sa
.
types
.
JSON
})
def
fetch_outright_status
(
self
,
ref_date
:
str
,
is_open
=
True
):
def
fetch_outright_status
(
self
,
ref_date
:
str
,
is_open
=
True
,
ignore_internal_borrow
=
False
):
table
=
Outright
table
=
Outright
if
is_open
:
if
is_open
:
id_filter
=
'notin_'
id_filter
=
'notin_'
else
:
else
:
id_filter
=
'in_'
id_filter
=
'in_'
if
ignore_internal_borrow
:
this_filter
=
[
table
.
internal_borrow
==
False
]
else
:
this_filter
=
[]
t
=
select
([
table
.
trade_id
])
.
\
t
=
select
([
table
.
trade_id
])
.
\
where
(
and_
(
table
.
trade_date
<=
ref_date
,
where
(
and_
(
table
.
trade_date
<=
ref_date
,
table
.
operation
==
'withdraw'
))
.
alias
(
't'
)
table
.
operation
==
'withdraw'
))
.
alias
(
't'
)
query
=
select
([
table
])
.
\
query
=
select
([
table
])
.
\
where
(
and_
(
getattr
(
table
.
trade_id
,
id_filter
)(
t
),
where
(
and_
(
*
([
getattr
(
table
.
trade_id
,
id_filter
)(
t
),
table
.
trade_date
<=
ref_date
,
table
.
trade_date
<=
ref_date
,
table
.
operation
==
'lend'
))
table
.
operation
==
'lend'
]
+
this_filter
)
))
df
=
pd
.
read_sql
(
query
,
self
.
engine
)
.
set_index
(
'trade_id'
)
df
=
pd
.
read_sql
(
query
,
self
.
engine
)
.
set_index
(
'trade_id'
)
del
df
[
'internal_borrow'
]
if
df
.
empty
:
if
df
.
empty
:
return
return
...
...
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