#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Hua Liang[Stupid ET] <et@everet.org>
#

import numpy as np

from funcat import *


def test_000001():
    from funcat.data.tushare_backend import TushareDataBackend
    set_data_backend(TushareDataBackend("2016-01-01"))

    T("20161216")
    S("000001.XSHG")
    assert np.equal(round(c.value, 2), 3122.98)
    assert np.equal(round(o[2].value, 2), 3149.38)
    assert np.equal(round((c - o).value, 2), 11.47)
    assert np.equal(round((c - o)[2].value, 2), -8.85)
    assert np.equal(round(((c / c[1] - 1) * 100).value, 2), 0.17)
    assert np.equal(round(MA(C, 60)[2].value, 2), 3131.08)
    assert COUNT(C > O, 5) == 2

@@ -335,17 +335,21 @@
 l(round(
-c
+CLOSE
 .value, 
@@ -387,17 +387,20 @@
 l(round(
-o
+OPEN
 %5B2%5D.valu
@@ -442,21 +442,28 @@
 (round((
-c - o
+CLOSE - OPEN
 ).value,
@@ -505,13 +505,20 @@
 nd((
-c - o
+CLOSE - OPEN
 )%5B2%5D
@@ -568,13 +568,21 @@
 d(((
-c / c
+CLOSE / CLOSE
 %5B1%5D 
@@ -640,16 +640,20 @@
 und(MA(C
+LOSE
 , 60)%5B2%5D
@@ -695,12 +695,19 @@
 NT(C
+LOSE
  %3E O
+PEN
 , 5)

update test