Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. cortezkwan
    3. Topics
    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 7
    • Best 1
    • Groups 0
    • Blog

    Topics created by cortezkwan

    • C

      Strategy with pre-trained neural network weights
      Support • • cortezkwan

      3
      0
      Votes
      3
      Posts
      280
      Views

      C

      @support Thanks.

    • C

      How to create a strategy with pandas dataframe
      Strategy help • • cortezkwan

      2
      0
      Votes
      2
      Posts
      217
      Views

      V

      @cortezkwan

      Hello

      I think these examples can help you.

      https://quantiacs.com/documentation/en/examples/quick_start.html#an-example-using-pandas

      def get_price_pct_change(prices): prices_pandas= prices.to_pandas() assets= data.coords["asset"].values for asset in assets: prices_pandas[asset]= prices_pandas[asset].pct_change() return prices_pandas prices= data.sel(field="close") * 1.0 prices_pct_change= get_price_pct_change(prices).unstack().to_xarray()

      How to create a dataset yourself

      import pandas as pd import xarray as xr import numpy as np class Fields: OPEN = "open" LOW = "low" HIGH = "high" CLOSE = "close" VOL = "vol" DIVS = "divs" SPLIT = "split" SPLIT_CUMPROD = "split_cumprod" IS_LIQUID = 'is_liquid' f = Fields class Dimensions: TIME = 'time' FIELD = 'field' ASSET = 'asset' ds = Dimensions dims = (ds.FIELD, ds.TIME, ds.ASSET) def get_base_df(): try_result = {"schema": {"fields": [{"name": "time", "type": "datetime"}, {"name": "open", "type": "integer"}, {"name": "close", "type": "integer"}, {"name": "low", "type": "integer"}, {"name": "high", "type": "integer"}, {"name": "vol", "type": "integer"}, {"name": "divs", "type": "integer"}, {"name": "split", "type": "integer"}, {"name": "split_cumprod", "type": "integer"}, {"name": "is_liquid", "type": "integer"}], "primaryKey": ["time"], "pandas_version": "0.20.0"}, "data": [ {"time": "2021-01-30T00:00:00.000Z", "open": 1, "close": 2, "low": 1, "high": 2, "vol": 1000, "divs": 0, "split": 0, "split_cumprod": 0, "is_liquid": 1}, {"time": "2021-01-31T00:00:00.000Z", "open": 2, "close": 3, "low": 2, "high": 3, "vol": 1000, "divs": 0, "split": 0, "split_cumprod": 0, "is_liquid": 1}, {"time": "2021-02-01T00:00:00.000Z", "open": 3, "close": 4, "low": 3, "high": 4, "vol": 1000, "divs": 0, "split": 0, "split_cumprod": 0, "is_liquid": 1}, {"time": "2021-02-02T00:00:00.000Z", "open": 4, "close": 5, "low": 4, "high": 5, "vol": 1000, "divs": 0, "split": 0, "split_cumprod": 0, "is_liquid": 1}, {"time": "2021-02-03T00:00:00.000Z", "open": 5, "close": 6, "low": 5, "high": 6, "vol": 1000, "divs": 0, "split": 0, "split_cumprod": 0, "is_liquid": 1}, {"time": "2021-02-04T00:00:00.000Z", "open": 6, "close": 7, "low": 6, "high": 7, "vol": 1000, "divs": 0, "split": 0, "split_cumprod": 0, "is_liquid": 1}, {"time": "2021-02-05T00:00:00.000Z", "open": 7, "close": 8, "low": 7, "high": 8, "vol": 1000, "divs": 0, "split": 0, "split_cumprod": 0, "is_liquid": 1}, ]} columns = [Dimensions.TIME, f.OPEN, f.CLOSE, f.LOW, f.HIGH, f.VOL, f.DIVS, f.SPLIT, f.SPLIT_CUMPROD, f.IS_LIQUID] rows = try_result['data'] for r in rows: r['time'] = np.datetime64(r['time']) pandas = pd.DataFrame(columns=columns, data=rows) pandas.set_index(Dimensions.TIME, inplace=True) prices_array = pandas.to_xarray().to_array(Dimensions.FIELD) prices_array.name = "BTC_TEST" prices_array_r = xr.concat([prices_array], pd.Index(['BTC'], name='asset')) return prices_array_r weights = get_base_df() print(weights)
    • C

      Setup an environment at Google Colab
      Support • • cortezkwan

      5
      2
      Votes
      5
      Posts
      344
      Views

      C

      @support Great help! Thank you so much!

    • Documentation
    • About
    • Career
    • My account
    • Privacy policy
    • Terms and Conditions
    • Cookies policy
    Home
    Copyright © 2014 - 2021 Quantiacs LLC.
    Powered by NodeBB | Contributors