mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
fix: python test code in indicator
This commit is contained in:
parent
c18f684afd
commit
3d86330428
|
@ -13,7 +13,7 @@ import (
|
||||||
python:
|
python:
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
s = pd.Series(([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
s = pd.Series([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
||||||
ma1 = s.ewm(span=16).mean()
|
ma1 = s.ewm(span=16).mean()
|
||||||
ma2 = ma1.ewm(span=16).mean()
|
ma2 = ma1.ewm(span=16).mean()
|
||||||
result = (2 * ma1 - ma2)
|
result = (2 * ma1 - ma2)
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
python:
|
python:
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
s = pd.Series(([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
s = pd.Series([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
||||||
ma1 = s.ewm(span=8).mean()
|
ma1 = s.ewm(span=8).mean()
|
||||||
ma2 = s.ewm(span=16).mean()
|
ma2 = s.ewm(span=16).mean()
|
||||||
result = (2 * ma1 - ma2).ewm(span=4).mean()
|
result = (2 * ma1 - ma2).ewm(span=4).mean()
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
python:
|
python:
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
s = pd.Series(([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
s = pd.Series([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
||||||
ma1 = s.ewm(span=16).mean()
|
ma1 = s.ewm(span=16).mean()
|
||||||
ma2 = ma1.ewm(span=16).mean()
|
ma2 = ma1.ewm(span=16).mean()
|
||||||
ma3 = ma2.ewm(span=16).mean()
|
ma3 = ma2.ewm(span=16).mean()
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
python:
|
python:
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
s = pd.Series(([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
s = pd.Series([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
||||||
ma1 = s.ewm(span=16).mean()
|
ma1 = s.ewm(span=16).mean()
|
||||||
ma2 = ma1.ewm(span=16).mean()
|
ma2 = ma1.ewm(span=16).mean()
|
||||||
ma3 = ma2.ewm(span=16).mean()
|
ma3 = ma2.ewm(span=16).mean()
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
python:
|
python:
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
s = pd.Series(([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
s = pd.Series([0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9])
|
||||||
lag = int((16-1)/2)
|
lag = int((16-1)/2 + 0.5)
|
||||||
emadata = s + (s - s.shift(lag))
|
emadata = s + (s - s.shift(lag))
|
||||||
result = emadata.ewm(span=16).mean()
|
result = emadata.ewm(span=16).mean()
|
||||||
print(result)
|
print(result)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user